feat(bukkit/paper): add root command deletion support (#371)
This commit is contained in:
parent
17491c17c7
commit
2572b73c4b
10 changed files with 177 additions and 18 deletions
|
|
@ -439,7 +439,8 @@ public abstract class CommandManager<C> {
|
|||
// Mark the command for deletion.
|
||||
final CommandTree.Node<@Nullable CommandArgument<C, ?>> node = this.commandTree.getNamedNode(rootCommand);
|
||||
if (node == null) {
|
||||
throw new IllegalArgumentException(String.format("No root command named '%s' exists", rootCommand));
|
||||
// If the node doesn't exist, we don't really need to delete it...
|
||||
return;
|
||||
}
|
||||
|
||||
// The registration handler gets to act before we destruct the command.
|
||||
|
|
|
|||
|
|
@ -963,14 +963,10 @@ public final class CommandTree<C> {
|
|||
}
|
||||
|
||||
private boolean removeNode(final @NonNull Node<@Nullable CommandArgument<C, ?>> node) {
|
||||
if (node.isLeaf()) {
|
||||
if (this.getRootNodes().contains(node)) {
|
||||
this.internalTree.removeChild(node);
|
||||
} else {
|
||||
return node.getParent().removeChild(node);
|
||||
}
|
||||
if (this.getRootNodes().contains(node)) {
|
||||
this.internalTree.removeChild(node);
|
||||
} else {
|
||||
throw new IllegalStateException(String.format("Cannot delete intermediate node '%s'", node));
|
||||
return node.getParent().removeChild(node);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue