how to make this /command subcommand i know how to do a regular command /command but i want to know how to do subcommands
Yes, those would be in the array $args here; http://docs.pocketmine.net/d4/d5f/interfacepocketmine_1_1command_1_1_command_executor.html
When client sends a command it's one string Code: /time set day PocketMine explodes them by space and removes forward slash Command is now an array that looks like this Code: [0] => time, [1] => set, [2] => 'day' In this example array keys from 1 to 2 is args, why [0] isn't? Because it is a command Sub-command is [1] which is 'set' PHP: if(isset($args[1])){ # Make sure that user sent sub-command at all case(strtolower($args[1])){ # Case-insensitive case 'set': # Code to set time to $args[2] break; case default: break; }}
Code: 0 => "time", 1 => "set", 2 => "day" is wrong. "time" is the command name, $args starts at "set"
PHP: public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){ if($command->getName() == "command"){ if(isset($args[0])){ if($args[0] == "yourSubCommand") // In here, you put what you want the sub command to do. Example: $sender->sendMessage("You used a sub command!"); } } }}