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

Blocking Commands?

Comments in 'Plugin Development' started by Radix, Aug 24, 2015.

  1. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    How can I block commands , period
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    onCommandPreProcessEvent
  3. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    Thx
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Please make sure you know the API. It's PlayerCommandPreprocessEvent.
    Last edited: Aug 25, 2015
  5. Pman1220
    Offline

    Pman1220 Active Member Plugin Developer

    Joined:
    Nov 21, 2013
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Pman1220
    Code:
    public function onProcess(PlayerCommandPreprocessEvent $event){
    if($event->getMessage() == "/command"){
    $event->getPlayer()->sendMessage("Sorry. This command is disabled");
    $event->setCancelled(true);
    }
    }
  6. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    Ahh , Thx so much
  7. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    501
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    What if you want to block the login command? Every player has different password!
    For example if you want to block the register command (SimpleAuth plugin):
    PHP:
    public function onCmd(PlayerCommandPreprocessEvent $event){
        if(
    in_array($event->getPlayer()->getName(), (array) $this->blocked_players)){
            
    $cmd explode(" "$event->getMessage());
            if(
    $cmd[0] == "/register") {
                
    $event->getPlayer()->sendTip("You are not able to use this command now!");
                
    $event->setCancelled(true);
            }
        }
    }
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Period? That means it isn't a question.
    Taha_The_Hacker likes this.

Share This Page

Advertisement