I'm not sure, but i tried it long ago. Command->unregister(); does not remove the registration of that Command. So the best attempt to unregister/overwrite a command is by listening PlayerCommandPreprocessEvent, then get message from that event and check if specified command is executed. If true, cancel the event. PHP: public function onCommand(PlayerCommandPreprocessEvent $e){ $msg = $e->getMessage(); $cmd = substr($msg, 0, strpos($msg, " ")); if($cmd == "/example"){ //Attempt to execute command, example $e->setCancelled(); }}
has this been updated? I have many commands that most users cannot use, is there anyway to hide them with new API?
I'm not sure with Command->unregister(). Not the code I posted Use this: PHP: public function onCommand(PlayerCommandPreprocessEvent $e){ $msg = $e->getMessage(); $cmd = substr($msg, 0, strpos($msg, " ")); if($cmd == "/example"){ //Attempt to execute command, example $e->setCancelled(); }} Where, "/example" is the command you wanted to "remove"
I looked already, and now you please look at my post: I said, I'm not sure if Command->unregister() is working. I tried unregister long ago, it seems not to be worked
I have tested Command->unregister() before, the command does not removed. For my code, I'm pretty sure it's working.
It worked on a nukkit plugin i made (boo nukkit) https://github.com/TheDiamondYT1/Nu...yt/essentials/commands/EssentialsCommand.java
Where is unregister function I see only register https://github.com/pmmp/PocketMine-MP/blob/api3/network/src/pocketmine/command/SimpleCommandMap.php
unregister() is available at Command class, not CommandMap But, I'm not sure if Command->unregister() actually removes the command
unregister() is available at Command class, not CommandMap All VanillaCommand like /summon is extended with Command Class, so you can just execute unregister() directly. But, I'm not sure if Command->unregister() actually removes the command
Last time i check these 4 lines of code worked. Then just register your command the normal way. PHP: $map = $plugin->getServer()->getCommandMap(); $command = $map->getCommand($name); $command->setLabel($name . "_disabled"); $command->unregister($map);
Sorry copied it directly from my plugin (i only made for nukkit because it had no half decent plugins) i didnt realise it was java when i copied the code lol. EDIT: Converted to PHP code