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

QuietNoob plugin not doing what i intended..

Comments in 'Plugin Development' started by dxm_hippie, Apr 11, 2015.

  1. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    PHP:
    public function onPlayerChat(PlayerChatEvent $event){
    $player $event->getPlayer();
    if(!(
    $player->hasPermission("chat.public"))){
    $event->setCancelled(true);
    $player->sendMessage("You don't have permission to use the public chat!");
    }
    }
    This should work :p
    dxm_hippie likes this.
  2. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    PHP:
    <?php

    namespace CrazyHippie\QuietNoob;

    use 
    pocketmine\event\player\PlayerChatEvent;
    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->getServer()->getPluginManager()->registerEvents($this,$this);
    $this->getLogger()->info("§aEnabling ".$this->getDescription()->getFullName()."...");

        }

        public function 
    onDisable(){
    $this->getLogger()->info("§cDisabling ".$this->getDescription()->getFullName()."...");
    }

        public function 
    onPlayerChat(PlayerChatEvent $event){
       
            
    $player $event->getPlayer();
       
    If(!(
    $player->hasPermission("talk.noob"))) {
    $event->setCancelled(true);
    $player->sendMessage("[QuietNoob]You need to be a citizen to talk in\n public chat. Please type /how");

        }
    }

        public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
        if(
    strtolower($command->getName()) === "how"){
                 
    $sender->sendMessage("======================================");
                 
    $sender->sendMessage("You may become a citizen by voteing\nPlease type /warp vote for a tutorial.");
                 
    $sender->sendMessage("======================================");
    } else {
        return 
    true;
      }
        return 
    false;
        }
      }
    :) now i might start adding a config and getting a bit more advanced with it..its still basic ik but i feel i did good for a first plugin so far :p thanks for all the help again everyone! i think i want to config so i can make it more universal..this really is only set up for my server atm lol i want to figure it out myself tho :D
    AngelM701 likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Check the meaning of your return value. Returning false will make PocketMine send usage to the player afterwards.
  4. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    So I got the "return true" and "return false" backwords? when I was trying it without the return values it would only send the usage "usage: /how" but it dont do that with it set like this. Im honestly still am pretty clueless on the meaning for everything..I got most the basics for php I believe like what the "{" are used for and what not lol and a bit of other stuff im getting the hang of but loke I said I just started even looking at php files a few days ago :p am working on a PayCheck plugin to pay staff for time spent on the server. I should probably get this one done the right way first tho huh? lol I just wanna know it all XD
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    dxm_hippie Don't stop on one plugin Make 3 small per day as i do :D Making plugins repeatly will root in you'r brains like "Old Mc'Donalds Farm" song :D
    dxm_hippie likes this.
  6. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Is there somewhere I can find like a list of events and code and what its used for? ive looked at a few tutorials but I just really need a list of things like

    use pocketmine\Player; (show usage here)

    or

    public function onPlayerchat (usage here)

    somthing like that

    but im thinking that a tutorial like that might not be out there bc there are so many cases most things can be used for?
  7. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    You should look at the API docs.

    Sometimes I just look at the source.
    dxm_hippie likes this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Return values are checked by pocketmine, if casted to boolean your return value equals false (that includes 0 and null/void), it will send the usage message.
  9. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Ohh, so thats how i could possibly add /how 2 and /how 3 maybe? and if they type /how 4 and there is no how 4 that will be set to 0 so it shows the usage? am i warm? lol
  10. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
  11. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Anyone tell me why my PayCheck plugin wont add the config? i have the config in a resources file right after the main file..im not sure how to make it generate it on load tho.
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    public function onEnable(){
      
    $this->saveDefaultConfig();
      
    $config $this->getConfig();
      
    $this->blah $config->get("blah");
    }
  13. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    It must be in YourPluginMainFolder\resources\config.yml
  14. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Do i need to make a separate PHP file to handle timings? im working on that paycheck plugin i was talking about and i think i bit off more than i can chew lol should have kept it more simple until i got the hang of it /:

Share This Page

Advertisement