Expose command interface.
This commit is contained in:
@@ -44,6 +44,7 @@ public class MobArena extends JavaPlugin
|
|||||||
{
|
{
|
||||||
private Config config;
|
private Config config;
|
||||||
private ArenaMaster arenaMaster;
|
private ArenaMaster arenaMaster;
|
||||||
|
private CommandHandler commandHandler;
|
||||||
|
|
||||||
// Inventories from disconnects
|
// Inventories from disconnects
|
||||||
private Set<String> inventoriesToRestore;
|
private Set<String> inventoriesToRestore;
|
||||||
@@ -134,9 +135,9 @@ public class MobArena extends JavaPlugin
|
|||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
// Bind the /ma, /mobarena commands to MACommands.
|
// Bind the /ma, /mobarena commands to MACommands.
|
||||||
CommandHandler handler = new CommandHandler(this);
|
commandHandler = new CommandHandler(this);
|
||||||
getCommand("ma").setExecutor(handler);
|
getCommand("ma").setExecutor(commandHandler);
|
||||||
getCommand("mobarena").setExecutor(handler);
|
getCommand("mobarena").setExecutor(commandHandler);
|
||||||
|
|
||||||
PluginManager pm = this.getServer().getPluginManager();
|
PluginManager pm = this.getServer().getPluginManager();
|
||||||
pm.registerEvents(new MAGlobalListener(this, arenaMaster), this);
|
pm.registerEvents(new MAGlobalListener(this, arenaMaster), this);
|
||||||
@@ -229,6 +230,10 @@ public class MobArena extends JavaPlugin
|
|||||||
return arenaMaster;
|
return arenaMaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommandHandler getCommandHandler() {
|
||||||
|
return commandHandler;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateSettings(Config config) {
|
private void updateSettings(Config config) {
|
||||||
Set<String> arenas = config.getKeys("arenas");
|
Set<String> arenas = config.getKeys("arenas");
|
||||||
if (arenas == null) return;
|
if (arenas == null) return;
|
||||||
|
|||||||
@@ -201,12 +201,12 @@ public class CommandHandler implements CommandExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a single command.
|
* Register a command.
|
||||||
* The Command's CommandInfo annotation is queried to find its pattern
|
* The Command's CommandInfo annotation is queried to find its pattern
|
||||||
* string, which is used to map the commands.
|
* string, which is used to map the commands.
|
||||||
* @param c a Command
|
* @param c a Command
|
||||||
*/
|
*/
|
||||||
private void register(Class<? extends Command> c) {
|
public void register(Class<? extends Command> c) {
|
||||||
CommandInfo info = c.getAnnotation(CommandInfo.class);
|
CommandInfo info = c.getAnnotation(CommandInfo.class);
|
||||||
if (info == null) return;
|
if (info == null) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user