feat: added unregister by node name

This commit is contained in:
NgLoader 2022-07-15 23:49:32 +02:00
parent de3325164c
commit ca906236b9
No known key found for this signature in database
GPG key ID: 1D680A9FE35C0482
2 changed files with 13 additions and 6 deletions

View file

@ -100,12 +100,21 @@ public class CommandDispatcher<S> {
}
/**
* Utility method from unregister a command
* This method unregisteres a previously declared command
*
* @param command node from register function
* @param The name of the command to remove
*/
public void unregister(final String name) {
this.root.removeChild(name);
}
/**
* This method unregisteres a previously declared command
*
* @param An previously added node
*/
public void unregister(final LiteralCommandNode<S> node) {
this.root.removeChild(node);
this.unregister(node.getName());
}
/**

View file

@ -89,9 +89,7 @@ public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
}
}
public void removeChild(final CommandNode<S> node) {
String name = node.getName();
public void removeChild(String name) {
this.children.remove(name);
this.literals.remove(name);
this.arguments.remove(name);