mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 10:35:18 +01:00
add commandmanager dynamic register class function
This commit is contained in:
parent
a9cc94e246
commit
2ca8925d14
@ -63,9 +63,8 @@ public class SongodaCore {
|
||||
|
||||
public SongodaCore(JavaPlugin javaPlugin) {
|
||||
piggybackedPlugin = javaPlugin;
|
||||
commandManager = new CommandManager(javaPlugin);
|
||||
CommandManager.registerCommandDynamically(piggybackedPlugin, "songoda", commandManager, commandManager);
|
||||
commandManager.addCommand(new SongodaCoreCommand(this))
|
||||
commandManager = new CommandManager(piggybackedPlugin);
|
||||
commandManager.registerCommandDynamically(new SongodaCoreCommand(this))
|
||||
.addSubCommand(new SongodaCoreDiagCommand(this));
|
||||
Bukkit.getPluginManager().registerEvents(loginListener, javaPlugin);
|
||||
}
|
||||
|
@ -55,6 +55,27 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
return all;
|
||||
}
|
||||
|
||||
public CommandManager registerCommandDynamically(String command) {
|
||||
CommandManager.registerCommandDynamically(plugin, command, this, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleNestedCommand registerCommandDynamically(AbstractCommand abstractCommand) {
|
||||
SimpleNestedCommand nested = new SimpleNestedCommand(abstractCommand);
|
||||
abstractCommand.getCommands().stream().forEach(cmd -> {
|
||||
CommandManager.registerCommandDynamically(plugin, cmd, this, this);
|
||||
commands.put(cmd.toLowerCase(), nested);
|
||||
PluginCommand pcmd = plugin.getCommand(cmd);
|
||||
if(pcmd != null) {
|
||||
pcmd.setExecutor(this);
|
||||
pcmd.setTabCompleter(this);
|
||||
} else {
|
||||
plugin.getLogger().warning("Failed to register command: /" + cmd);
|
||||
}
|
||||
});
|
||||
return nested;
|
||||
}
|
||||
|
||||
public SimpleNestedCommand addCommand(AbstractCommand abstractCommand) {
|
||||
SimpleNestedCommand nested = new SimpleNestedCommand(abstractCommand);
|
||||
abstractCommand.getCommands().stream().forEach(cmd -> {
|
||||
|
Loading…
Reference in New Issue
Block a user