mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-30 14:03:23 +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) {
|
public SongodaCore(JavaPlugin javaPlugin) {
|
||||||
piggybackedPlugin = javaPlugin;
|
piggybackedPlugin = javaPlugin;
|
||||||
commandManager = new CommandManager(javaPlugin);
|
commandManager = new CommandManager(piggybackedPlugin);
|
||||||
CommandManager.registerCommandDynamically(piggybackedPlugin, "songoda", commandManager, commandManager);
|
commandManager.registerCommandDynamically(new SongodaCoreCommand(this))
|
||||||
commandManager.addCommand(new SongodaCoreCommand(this))
|
|
||||||
.addSubCommand(new SongodaCoreDiagCommand(this));
|
.addSubCommand(new SongodaCoreDiagCommand(this));
|
||||||
Bukkit.getPluginManager().registerEvents(loginListener, javaPlugin);
|
Bukkit.getPluginManager().registerEvents(loginListener, javaPlugin);
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,27 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
return all;
|
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) {
|
public SimpleNestedCommand addCommand(AbstractCommand abstractCommand) {
|
||||||
SimpleNestedCommand nested = new SimpleNestedCommand(abstractCommand);
|
SimpleNestedCommand nested = new SimpleNestedCommand(abstractCommand);
|
||||||
abstractCommand.getCommands().stream().forEach(cmd -> {
|
abstractCommand.getCommands().stream().forEach(cmd -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user