diff --git a/src/java/mc/alk/arena/controllers/APIRegistrationController.java b/src/java/mc/alk/arena/controllers/APIRegistrationController.java index 99850197..573cd0a1 100644 --- a/src/java/mc/alk/arena/controllers/APIRegistrationController.java +++ b/src/java/mc/alk/arena/controllers/APIRegistrationController.java @@ -100,6 +100,7 @@ private boolean createFile(File pluginFile, String name, String cmd, InputStream private void setCommandToExecutor(JavaPlugin plugin, String wantedCommand, CommandExecutor executor) { if (!setCommandToExecutor(plugin, wantedCommand, executor, false)) { + Log.info("[BattleArena] Now registering command " + wantedCommand + " dynamically with Bukkit commandMap."); List aliases = new ArrayList(); ArenaBukkitCommand arenaCommand = new ArenaBukkitCommand(wantedCommand, "", "", aliases, BattleArena.getSelf(), executor); CommandController.registerCommand(arenaCommand); @@ -112,7 +113,7 @@ private static boolean setCommandToExecutor(JavaPlugin plugin, String command, C return true; } catch (Exception e) { if (displayError) { - Log.err(plugin.getName() + " command " + command + " was not found. Did you register it in your plugin.yml?"); + Log.err(plugin.getName() + " command " + command + " was not found in plugin.yml."); } return false; } diff --git a/src/java/mc/alk/arena/controllers/CommandController.java b/src/java/mc/alk/arena/controllers/CommandController.java index c5b1346f..9d91502a 100644 --- a/src/java/mc/alk/arena/controllers/CommandController.java +++ b/src/java/mc/alk/arena/controllers/CommandController.java @@ -11,41 +11,41 @@ public class CommandController { - public static CommandMap getCommandMap(){ - Version version = Util.getCraftBukkitVersion(); - final Class clazz; - try { - if (version.compareTo("0") == 0 || version.getVersion().equalsIgnoreCase("craftbukkit")){ - clazz = Class.forName("org.bukkit.craftbukkit.CraftServer"); - } else{ - clazz = Class.forName("org.bukkit.craftbukkit." + version.getVersion() + ".CraftServer"); - } - } catch (ClassNotFoundException e) { - Log.printStackTrace(e); - return null; - } - return getCommandMapFromServer(clazz); - } + public static CommandMap getCommandMap() { + Version version = Util.getCraftBukkitVersion(); + final Class clazz; + try { + if (version.compareTo("0") == 0 || version.getVersion().equalsIgnoreCase("craftbukkit")) { + clazz = Class.forName("org.bukkit.craftbukkit.CraftServer"); + } else { + clazz = Class.forName("org.bukkit.craftbukkit." + version.getVersion() + ".CraftServer"); + } + } catch (ClassNotFoundException e) { + Log.printStackTrace(e); + return null; + } + return getCommandMapFromServer(clazz); + } - private static CommandMap getCommandMapFromServer(Class serverClass){ - try { - if (serverClass.isAssignableFrom(Bukkit.getServer().getClass())) { - final Field f = serverClass.getDeclaredField("commandMap"); - f.setAccessible(true); - return (CommandMap) f.get(Bukkit.getServer()); - } - } catch (final SecurityException e) { - Log.err("You will need to disable the security manager to use dynamic commands"); - } catch (final Exception e) { - Log.printStackTrace(e); - } - return null; - } + private static CommandMap getCommandMapFromServer(Class serverClass) { + try { + if (serverClass.isAssignableFrom(Bukkit.getServer().getClass())) { + final Field f = serverClass.getDeclaredField("commandMap"); + f.setAccessible(true); + return (CommandMap) f.get(Bukkit.getServer()); + } + } catch (final SecurityException e) { + System.out.println("You will need to disable the security manager to use dynamic commands"); + } catch (final Exception e) { + Log.printStackTrace(e); + } + return null; + } - public static void registerCommand(final Command command) { - CommandMap commandMap = getCommandMap(); - if (commandMap != null){ - commandMap.register("/", command); - } - } + public static void registerCommand(final Command command) { + CommandMap commandMap = getCommandMap(); + if (commandMap != null) { + commandMap.register("/", command); + } + } }