diff --git a/src/main/java/com/github/maxopoly/angelia_cmd/Main.java b/src/main/java/com/github/maxopoly/angelia_cmd/Main.java index f242248..4169a99 100644 --- a/src/main/java/com/github/maxopoly/angelia_cmd/Main.java +++ b/src/main/java/com/github/maxopoly/angelia_cmd/Main.java @@ -27,4 +27,12 @@ public static void main(String[] args) { CommandLineReader reader = new CommandLineReader(logger, connManager, connection.getPlayerName(), cmdHandler); reader.start(); } + + public static CommandHandler getCommandHandler() { + return cmdHandler; + } + + public static ActiveConnectionManager getConnectionManager() { + return connManager; + } } diff --git a/src/main/java/com/github/maxopoly/angelia_cmd/command_handling/CommandHandler.java b/src/main/java/com/github/maxopoly/angelia_cmd/command_handling/CommandHandler.java index 10cb558..41cf19d 100644 --- a/src/main/java/com/github/maxopoly/angelia_cmd/command_handling/CommandHandler.java +++ b/src/main/java/com/github/maxopoly/angelia_cmd/command_handling/CommandHandler.java @@ -53,6 +53,21 @@ public synchronized void registerCommand(Command command) { } } } + + public synchronized void unregisterCommand(Command command) { + String key = command.getIdentifier().toLowerCase(); + if (commands.get(key) == command) { + commands.remove(key); + } + if (command.getAlternativeIdentifiers() != null) { + for (String alt : command.getAlternativeIdentifiers()) { + key = alt.toLowerCase(); + if (commands.get(key) == command) { + commands.remove(key); + } + } + } + } public synchronized void handle(String input, ServerConnection connection) { if (input == null || input.equals("")) {