Skip to content

Commit

Permalink
Allow accessing commandhandler for registering custom commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxopoly committed Nov 19, 2018
1 parent 84e0964 commit c2b31e6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/github/maxopoly/angelia_cmd/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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("")) {
Expand Down

0 comments on commit c2b31e6

Please sign in to comment.