Hi , How can I register a command when running the plugin? (For example I want to register /hello command when the plugin enables) Can anyone show me an example? Thanks and best regards, EvolSoft
Thank you! Just another question: can I use the same class for different commands (not aliases)? (For example the class HelloCommand should have /hello and /ciao)
Yes. Example 1: Look at how PluginManager registers the commands at plugin.yml into PluginCommand. It is a doubleplusungood (Newspeak ) practice to declare dynamic classes, so PocketMine registers plugin.yml commands using the PluginCommand class instead, where PluginCommand returns the values according to the values as passed in its constructor params (from plugin.yml) and registers using them. Example 2: Look at how WorldEditArt registers both //pos1 and //po2. (They are of a subclass of pemapmodder\worldeditart\utils\subcommand\Subcommand instead of a pocketmine\command\Command, but pemapmodder\worldeditart\utils\subcommand main classes (Subcommand and SubcommandMap) were actually designed in the same model as Command and CommandMap except that they are in different contexts and different uses.
You need to import the ConsoleCommandSender class PHP: $this->getServer()->dispatchCommand(new ConsoleCommamdSender, "say Command here");
You're all the way wrong... What you're doing is dispatching a command creating a "New ConsoleCommandSender" class, and he is asking for "Registering Commands Dynamicallly"... For example, EssentialsPE
Whoops. I thought he meant dispatch a command. Idk, must have been reading it somewhere else at the same time.