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

Solved Unregister "stop" command

Comments in 'Plugin Development' started by ahoj_truhliku, Jul 11, 2015.

  1. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    is it possible do this? :D because when i try unregister command "stop" it still works
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Try PlayerCommandPreProcessEvent and cancel the event when the command is /stop
  3. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    but i want to disable it from cosole
  4. Dinokiller
    Offline

    Dinokiller Notable Member

    Joined:
    Sep 22, 2013
    Posts:
    376
    Minecraft User:
    Dinokiller_
    Why would you want to disable the stop command?
  5. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    hosting stop my server, when i have more slots, using command "stop" xD i know it is bad idea
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Try this:
    PHP:
    public function onChat(PlayerCommandPreprocessEvent $event) {
            
    $player $event->getPlayer();
            
    $command explode(" "strtolower($event->getMessage()));
            if (
    $command[0] === "/stop") {
                if(!(
    $player instanceof Player)){
                    
    $event->setCancelled(true);
                }
            } 
        }
  7. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    but console is not player
  8. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    .. Do you even understand what I wrote?
    PHP:
    public function onChat(PlayerCommandPreprocessEvent $event) {
            
    $player $event->getPlayer();
            
    $command explode(" "strtolower($event->getMessage()));
            if (
    $command[0] === "/stop") { // Checks the command
                
    if(!($player instanceof Player)){ // Checks whether the Sender IS NOT a Player
                    
    $event->setCancelled(true);
                }
            }
        }
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Do you even understand what you wrote? He asked to disable stop directly, even to disable for console. Your function only disabled for players. PlayerCommandPreprocessEvent isn't fired for non-player commands. Otherwise what do you expect getPlayer to return for non-player? Read the docs.
    What if hosting used another way than /stop to stop the server? And what if you seriously want to stop the server?
  10. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    yes they stop my server when they see it but hosting doesn´t stop my server when stop command wont work i think
  11. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    I have one really cool suggestion:

    1) Extract PocketMine-MP.phar to folder
    2) Delete all files/ contents of files where is "stop" command
    3) Use pmt.mcpe.me(thanks PEMapModder) to create new phar
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You don't need to make a phar. Simply replace PocketMine-MP.phar with the src folder.
    Legoboy0215 likes this.
  13. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    You can do that?

Share This Page

Advertisement