Command code in separate class

ArnyFour

New Member
Hello everyone! I want the command code of my plugin to be in a separate class. How can this be done correctly? I watched a lot of sources of different plugins, but could not figure out how to do it.
 
Easiest way is to extend PluginCommand and use the onCommand method. Alternatively, you can also use setExecutor to specify a specific class to use.
 
Hello everyone! I want the command code of my plugin to be in a separate class. How can this be done correctly? I watched a lot of sources of different plugins, but could not figure out how to do it.
Create a new class and make it extend PluginCommand. Then, register it using the register method in CommandMap, which can be done with this.getServer().getCommandMap().register(Plugin, Command); in your main class.
 
Easiest way is to extend PluginCommand and use the onCommand method. Alternatively, you can also use setExecutor to specify a specific class to use.
Well, the familiar `setExecutor` method from the Spigot API. How to use it properly in Nukkit?
 
Difficult ... What is CommandBase for? Why CommandManager? No way easier? I apologize for such stupid and simple questions. Make command code in a separate class in Nukkit is a difficult task for me. :< ?
 
Difficult ... What is CommandBase for? Why CommandManager? No way easier? I apologize for such stupid and simple questions. Make command code in a separate class in Nukkit is a difficult task for me. :< ?
the easiest way is to extend Command class. It's just and example from a bit more complex project.
 
Back
Top