feat: added unregister by node name
This commit is contained in:
parent
de3325164c
commit
ca906236b9
2 changed files with 13 additions and 6 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue