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

trying to customise a few commands

Comments in 'Plugin Development' started by zombie_Power, Sep 22, 2015.

  1. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    PHP:
    <?php
       
    namespace Zombie_Power\me;
     
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\Player;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\player\PlayerCommandPreproeccessEvent;
     
    class 
    me extends PluginBase implements Listener{
       
        Public Function 
    onEnable (){
            
    $this->getServer()->getPluginManager->registerEvents($this$this);
        }
       
        Public Function 
    onChat(PlayerCommandPreprocessEvent $event){
            
    $player $event->getPlayer();
            
    $command explode(" "strtolower($event->getMessage()));
            if (
    $command[0] == "/me"){
            
    $event->setCancelled(true); //setCancelled will always have (true)
            
    $player->sendMesage("Server: This command has been blocked");   
     
     } elseif (
    $command[0] == "/help"){
            
    $event->setCancelled(true);
            
    $player->sendMessage("");
            
    $player->sendMessage(""); //add message inside ("")
            
    $player->sendMessage("");
            
    $player->sendMessage("");
       
    }
    }
    hey guys, i am new to Pocketmine API, i am trying to code to block commands like /me and customise /help, so it can broadcast, whatever i feed in (""), can someone please check it, it would be great.

    Thanks.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    1. please don't copy things blindly.
    2. read the comments.
    3. you don't need to (but it works when you do) pass a `true` with setCancelled(); it is the default value.
    CraftYourBukkit likes this.
  3. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    How are you so sure he copied? Was it the code?
    zombie_Power likes this.
  5. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    he was helping me on twitter:), just found that getPluginManager is a class member, so just needed to edit the code to getPluginManager():p
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    100% Code has been given by someone else. (Comments are too wierd)
  8. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    I was going to send this plugin to someone, so if he messed up anything, I added this quotes, as you can also see the second comments, which say to add lines in ("").

Share This Page

Advertisement