diff --git a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java index 80caa0b53..9c3929106 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java @@ -47,9 +47,6 @@ public final class CommandRegistrationHelper { String commandName = skill.toString().toLowerCase(); String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase(); - List aliasList = new ArrayList(); - aliasList.add(localizedName); - PluginCommand command; // Make us play nice with Essentials @@ -60,7 +57,6 @@ public final class CommandRegistrationHelper { command = mcMMO.p.getCommand(commandName); } - command.setAliases(aliasList); command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName))); command.setPermission("mcmmo.commands." + commandName); command.setPermissionMessage(permissionsMessage); diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 4d3fd677a..be1189497 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -10,6 +10,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; @@ -347,4 +348,32 @@ public class PlayerListener implements Listener { event.setCancelled(true); } } + + /** + * Handle "ugly" aliasing /skillname commands, since setAliases doesn't work. + * + * @param event The event to watch + */ + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { + if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) { + String message = event.getMessage(); + String command = message.substring(1).split(" ")[0]; + String lowerCaseCommand = command.toLowerCase(); + + for (SkillType skill : SkillType.values()) { + String commandName = skill.toString().toLowerCase(); + String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase(); + + if (lowerCaseCommand.equals(localizedName)) { + break; + } + + if (lowerCaseCommand.equals(commandName)) { + event.setMessage(message.replace(command, localizedName)); + break; + } + } + } + } }