Brigadier based command API
== AT == public net.minecraft.commands.arguments.blocks.BlockInput tag public net.minecraft.commands.arguments.DimensionArgument ERROR_INVALID_VALUE public net.minecraft.server.ReloadableServerResources registryLookup public net.minecraft.server.ReloadableServerResources Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Marc Baloup <marc.baloup@laposte.net>
This commit is contained in:
@@ -32,6 +32,24 @@
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -451,7 +459,7 @@
|
||||
}
|
||||
|
||||
private String getSmartUsage(final CommandNode<S> node, final S source, final boolean optional, final boolean deep) {
|
||||
- if (!node.canUse(source)) {
|
||||
+ if (source != null && !node.canUse(source)) { // Paper
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -465,7 +473,7 @@
|
||||
final String redirect = node.getRedirect() == this.root ? "..." : "-> " + node.getRedirect().getUsageText();
|
||||
return self + CommandDispatcher.ARGUMENT_SEPARATOR + redirect;
|
||||
} else {
|
||||
- final Collection<CommandNode<S>> children = node.getChildren().stream().filter(c -> c.canUse(source)).collect(Collectors.toList());
|
||||
+ final Collection<CommandNode<S>> children = node.getChildren().stream().filter(c -> source == null || c.canUse(source)).collect(Collectors.toList()); // Paper
|
||||
if (children.size() == 1) {
|
||||
final String usage = this.getSmartUsage(children.iterator().next(), source, childOptional, childOptional);
|
||||
if (usage != null) {
|
||||
@@ -537,10 +545,14 @@
|
||||
int i = 0;
|
||||
for (final CommandNode<S> node : parent.getChildren()) {
|
||||
|
||||
@@ -16,11 +16,13 @@
|
||||
|
||||
public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
|
||||
private final Map<String, CommandNode<S>> children = new LinkedHashMap<>();
|
||||
@@ -32,6 +34,14 @@
|
||||
@@ -32,6 +34,16 @@
|
||||
private final RedirectModifier<S> modifier;
|
||||
private final boolean forks;
|
||||
private Command<S> command;
|
||||
+ public CommandNode<CommandSourceStack> clientNode; // Paper - Brigadier API
|
||||
+ public CommandNode<io.papermc.paper.command.brigadier.CommandSourceStack> unwrappedCached = null; // Paper - Brigadier Command API
|
||||
+ public CommandNode<io.papermc.paper.command.brigadier.CommandSourceStack> wrappedCached = null; // Paper - Brigadier Command API
|
||||
+ // CraftBukkit start
|
||||
+ public void removeCommand(String name) {
|
||||
+ this.children.remove(name);
|
||||
@@ -31,7 +33,7 @@
|
||||
|
||||
protected CommandNode(final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
|
||||
this.command = command;
|
||||
@@ -61,7 +71,17 @@
|
||||
@@ -61,7 +73,17 @@
|
||||
return this.modifier;
|
||||
}
|
||||
|
||||
@@ -50,3 +52,15 @@
|
||||
return this.requirement.test(source);
|
||||
}
|
||||
|
||||
@@ -183,4 +205,11 @@
|
||||
}
|
||||
|
||||
public abstract Collection<String> getExamples();
|
||||
+ // Paper start - Brigadier Command API
|
||||
+ public void clearAll() {
|
||||
+ this.children.clear();
|
||||
+ this.literals.clear();
|
||||
+ this.arguments.clear();
|
||||
+ }
|
||||
+ // Paper end - Brigadier Command API
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user