Just use a regular builder

This commit is contained in:
Nathan Adams
2014-09-16 14:47:19 +02:00
parent c73607ba36
commit dadedbb322
4 changed files with 28 additions and 72 deletions
@@ -10,16 +10,11 @@ import java.util.Map;
public class CommandDispatcher {
private final Map<String, Runnable> commands = Maps.newHashMap();
public CommandBuilder createCommand(final String name) {
return new CommandBuilder() {
@Override
public void onFinish() {
if (commands.containsKey(name)) {
throw new IllegalArgumentException("New command " + name + " conflicts with existing command " + name);
}
commands.put(name, getCommandExecutor());
}
};
public void register(CommandBuilder command) {
if (commands.containsKey(command.getName())) {
throw new IllegalArgumentException("New command " + command.getName() + " conflicts with existing command " + command.getName());
}
commands.put(command.getName(), command.getExecutor());
}
public void execute(String command) throws CommandException {