Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

an If-you-rather plugin

Comments in 'Plugin Development' started by FlamingGenius, Mar 5, 2016.

  1. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Got some free time thinking of making a would you rather game plugin useful maybe?

    p.s: Leaving good would you rather questions in the comments would be helpful :p

    Submitted plugin
    Anybody wanna take a gander at weather this will be approved or not

    Code:
    name: Would You Rather
    author: FlamingGenius
    main: FlamingGenius\wyr\main
    description: Simple would you rather game
    version: 1.0.0
    commands:
    wyr:
      description: Get a would you rather question
      usage: "/wyr"

    Code:
    questions[
    "Would you rather Eat a jar of peanut butter or Drink a jar of maple syrup?",
    "Would you rather live one life that lasts 1,000 years or live 10 lives that last 100 years each?",
    "Would you rather use eye drops made of vinegar or toilet paper made from sandpaper?",
    "Would you rather be without elbows or be without knees?",
    "Would you rather experience a sharp pain in your side each time someone says your name or have a bell sound each time you are aroused?",
    "Would you rather have a large 10 inch long belly button that swayed to music or have accordions for legs?",
    "Would you rather have to sneeze but not be able to or have something stuck in your eye for an entire year?",
    "Would you rather have a dragon or be a dragon?",
    "Would you rather have hair nowhere on your body or be very hairy all over and not be able to shave?",
    "Would you rather never be able to speak again or always have to say everything that is on your mind?",
    "Would you rather be able to read or be able to read minds (but be illiterate)?",
    "Would you rather be able to speak fluently every language in the world or be the best in the world at something of your choosing?",
    "Would you rather be in prison for five years in solitary confinement or not ever go to prison and not ever become rich?",
    "Would you rather wear a snow suit in the desert or be naked in Antarctica?",
    "Would you rather change the past or be able to see into the future?",
    "Would you rather have cookies or have French fries?",
    "Would you rather be good at sports or get good grades?",
    "Would you rather help clean up after dinner or help set the table before dinner?",
    "Would you rather get up early or stay up late?",
    "Would you rather be super fast or super strong?",
    "Would you rather be invisible or have the ability to fly?",
    "Would you rather be the smartest kid in school or the most popular kid in school?",
    "Would you rather eat your boogers or lick your shoe?",
    "Would you rather have bad breath or smelly feet?",
    "Would you rather be a police officer or be a firefighter?"
    ]

    PHP:
    <?
    namespace 
    FlamingGenius\wyr;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    class 
    main extends PluginBase implements Listener{
        public function 
    onEnable(){
            
    $this->saveDefaultConfig();
            
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
        }

        private function 
    getQuestion(){
            
    $questions $this->getConfig()->get("questions");
            
    $draw array_rand($questions);
       
            
    $question $questions[$draw];
            return 
    $question;
        }

        public function 
    onCommand(CommandSender $sender,Command $command,$label,array $args){
            
    $cmd $command->getName();
            if(
    $cmd === "wyr"){
                
    $this->getServer()->broadcastMessage($this->getQuestion());
            }
        }
    }
    ?>

    Feel free to contribute
    https://github.com/FlamingGenius/would-you-rather/blob/master/README.md
    Last edited: Mar 7, 2016
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Any plugin is useful to atleast 1 person. so i say go for it.
    FlamingGenius and applqpak like this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Your question would be more comprehensible if you write
    or
    instead.
  4. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    *bump*
  5. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Ummm... What should we do? Give some questions? Or correcting your code?
  6. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    theres nothing in my code to correct lol just dont know what else to add to it functionality wise
  7. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    What is this?
    PHP:
    $sender->broadcastMessage(getQuestion());
  8. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    returns a string which would be a "would you rather" question
  9. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    And your use statement is not complete yet, you need to use
    PHP:
    use pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
  10. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    okay you got me there in my rush i completly forgot those XD
  11. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    I think it should be
    PHP:
    $this->getServer()->broadcastMessage($this->getQuestion()); // You can call getServer() directly since your class extends PluginBase
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why does everyone like using a main class name "main"? Class names should start with an uppercase letter.
  13. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    hmm that would seem more practical lol OOP sucks XD
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Learn PHP!

    Where the first time this sentence has been said on the forums, it was me making the same mistake, thinking that in PHP I can call $this methods directly like in Java.
    Falk and jojoe77777 like this.
  15. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    What's the problem with that code?
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No. It was the problem that you fixed.
  17. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Cleaned this thread up.

    (Now please excuse me while I have an ironic and hypocritical off-topic rant about off-topic content: I don't know what has been happening in this section while I was gone, but I will enforce my standards on threads while I have time to moderate. This section is geared toward providing support and also facilitating discussion around key topics. In order to do this, discussions should remain focused on the original topic in order to satisfy the needs of the OP. We have a wonderful "off-topic" section and messaging system for all your random conversation needs. Discussions that stray from the topic in this section will be removed without warning. Users who repeatedly go "off-topic" will be warned formally. I will make a thread specifically about this soon, but I figured I would post here because there was an issue here.)

Share This Page

Advertisement