1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Block /plugins

Discussion in 'Facepalm' started by GamingPilot2, Dec 21, 2016.

  1. GamingPilot2

    GamingPilot2 Creeper

    Messages:
    3
    GitHub:
    gamingpilot2
    Hello!
    Someone can give me the code for block the /plugins command ?

    Thanks,
    GamingPilot2
     
  2. Magicode

    Magicode Baby Zombie

    Messages:
    183
    GitHub:
    magicode1
    YOu can change the permissions. I don't think there is a way currently to Block them without going into the Server software code.
     
  3. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    PHP:
    public function onCommandPreprocess(\pocketmine\event\player\PlayerCommandPreprocessEvent $event){
        
    $command explode(' 'strtolower($event->getMessage()));
        if(
    $command[0] === '/plugins'){
            
    $event->setCancelled();
        }
    }
    This should be in the facepalm section.

    Another (better) way is to use permissions.
     
    Last edited: Dec 22, 2016
    Magicode likes this.
  4. GamingPilot2

    GamingPilot2 Creeper

    Messages:
    3
    GitHub:
    gamingpilot2
    Thanks, i report to you if the command dosen't working
     
  5. GamingPilot2

    GamingPilot2 Creeper

    Messages:
    3
    GitHub:
    gamingpilot2
    I just tested and it does not work
    (no error, but the command display all loaded plugins)
     
  6. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    Where did you put the code? 99% you didn't register the listener...
     
  7. GamingPilot2

    GamingPilot2 Creeper

    Messages:
    3
    GitHub:
    gamingpilot2
    Can you explain?
     
  8. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    Show me the plugin.
     
  9. GamingPilot2

    GamingPilot2 Creeper

    Messages:
    3
    GitHub:
    gamingpilot2
    i send you the code
     
  10. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    Just do it here it would be better if we all can help
     
  11. GamingPilot2

    GamingPilot2 Creeper

    Messages:
    3
    GitHub:
    gamingpilot2
  12. Tester_master

    Tester_master Silverfish

    Messages:
    19
    you can block without going into the true source code
    as leet.cc has a plugin named BlockedCommands as you can block and unblock commands
    therefore showing we can do it without modifying pocketmines true source code
     
  13. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    Sorry my bad. I forgot explode returns an array.

    This is the fixed and working one:
    PHP:
    public function onCommandPreprocess(\pocketmine\event\player\PlayerCommandPreprocessEvent $event){
        
    $command explode(' 'strtolower($event->getMessage()));
        if(
    $command[0] === '/plugins'){
            
    $event->setCancelled();
        }
    }
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.