00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 package com.realtime.crossfire.jxclient.commands;
00023
00024 import java.util.HashMap;
00025 import java.util.Map;
00026 import org.jetbrains.annotations.NotNull;
00027 import org.jetbrains.annotations.Nullable;
00028
00033 public class Commands {
00034
00038 @NotNull
00039 private final Map<String, Command> commands = new HashMap<String, Command>();
00040
00045 public void addCommand(@NotNull final Command command) {
00046 if (commands.put(command.getCommandName(), command) != null) {
00047 throw new IllegalArgumentException("duplicate command: "+command.getCommandName());
00048 }
00049 }
00050
00057 @Nullable
00058 public Command findCommand(@NotNull final String commandName) {
00059 return commands.get(commandName.toLowerCase());
00060 }
00061
00062 }