diff --git a/src/java/com/threerings/crowd/chat/client/ChatDirector.java b/src/java/com/threerings/crowd/chat/client/ChatDirector.java index 625e3e005..9ddb9bc43 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatDirector.java +++ b/src/java/com/threerings/crowd/chat/client/ChatDirector.java @@ -396,7 +396,7 @@ public class ChatDirector extends BasicDirector args = text.substring(sidx + 1).trim(); } - HashMap possibleCommands = getCommandHandlers(command); + Map possibleCommands = getCommandHandlers(command); switch (possibleCommands.size()) { case 0: StringTokenizer tok = new StringTokenizer(text); @@ -948,10 +948,11 @@ public class ChatDirector extends BasicDirector } /** - * Returns a hashmap containing all command handlers that match the specified command (i.e. the - * specified command is a prefix of their registered command string). + * Returns a map containing all command handlers that match the specified command (i.e. the + * specified command is a prefix of their registered command string). If there's an exact + * match, only that match is returned, even if the command is a prefix of other handlers. */ - protected HashMap getCommandHandlers (String command) + protected Map getCommandHandlers (String command) { HashMap matches = Maps.newHashMap(); BodyObject user = (BodyObject)_ctx.getClient().getClientObject(); @@ -964,6 +965,11 @@ public class ChatDirector extends BasicDirector if (!handler.checkAccess(user)) { continue; } + if (cmd.equals(command)) {// If we hit an exact match, it wins + matches.clear(); + matches.put(cmd, handler); + return matches; + } matches.put(cmd, handler); } return matches; @@ -1144,7 +1150,7 @@ public class ChatDirector extends BasicDirector } // handle "/help help" and "/help someboguscommand" - HashMap possibleCommands = getCommandHandlers(hcmd); + Map possibleCommands = getCommandHandlers(hcmd); if (hcmd.equals("help") || possibleCommands.isEmpty()) { possibleCommands = getCommandHandlers(""); possibleCommands.remove("help"); // remove help from the list