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

Block other plugins commands?

Comments in 'Plugin Development' started by BalAnce, Jul 8, 2015.

  1. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    Can i stop another plugin from using a command. fo example EssentialsPE has a /kit command but its causing issues with another kit plugin i use can i block the /kit command from essentials or any plugin in general? If so an example would be greatly appreciated.
  2. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    If the plugin command use a permission then you could disable that permission
  3. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    then it will say they dont have permission.
  4. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Well, you could replace the command.
    PHP:

    $commands 
    $plugin->getServer->getCommandMap()->getCommands();

    $commands[$commandLabel] = new ReplacementCommand();

    $plugin->getServer->getCommandMap()->clearCommands();

    foreach(
    $commands as $key => $value)
    {
        
    $plugin->getServer->getCommandMap()->register($key$value);
    }


    BalAnce likes this.
  5. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    exactly what i was looking for im gonna try it out
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    From EssentialsPE:
    PHP:
    $command $Server->getCommandMap()->getCommand($commandNameString);
    $command->setLabel($commandNameString "_disabled");
    $command->unregister($Server->getCommandMap());
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Or you could just remove the command from EssentialsPE's source code.
  8. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Go to pmt.mcpe.me and find PHAR to ZIP and put the plugin's phar file there.
    after get the zip file open it and find plugin.yml .
    in plugin.yml there are the permissions. just edit them make it "op" for op permission or "true" for everyone to have a permission and "false" to make no one be able to run the command not even the Console.
  9. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    What's the point of that when he can just remove the command from the plugin.yml
    PEMapModder likes this.
  10. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    In the permissions like
    PHP:
    command blabla.command.{command}
    default : 
    true/false/op
    ok?

    anyway your server is cool Hotshot :)
  11. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Or else another way. make your own plugin and use
    PHP:
    use pocketmine\event\player\PlayerCommandPreprocessEvent;
    and add this to your plugin :

    PHP:
    public function onCmd(PlayerCommandPreprocessEvent $event){
        if(
    in_array($event->getPlayer()->getName(), (array) $this->config)){
            
    $cmd explode(" "$event->getMessage());
            if(
    $cmd[0] == "/command") {
                
    $event->getPlayer()->sendTip("You are not able to use this command now!");
                
    $event->setCancelled(true);
            }
        }
    }
    Ok?
  12. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Code:
    commands:
     home:
      description: Teleports you home /home will list homes /home <homename> will teleport you.
      usage: "/home or /home <homename>"
      permission: essentialstp.command.home
     sethome:
      description: Sets your home use names for multiple homes.
      usage: "/sethome <homename>"
      permission: essentialstp.command.sethome
    Take this as an example. Just remove one of the commands (Name, usage and permission) And the command should no longer exist.

    And thanks :)
  13. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PlayerCommandPreprocessEvent->setCancelled();
  14. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    i don't need to write PlayerCommandPreprocess just do $event becasue the event is selected in the Function.
  15. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Idea that you wrote above can be understood from one line. (and he is developer so he just needed a hint)

Share This Page

Advertisement