Brigadier Mojang API

Adds AsyncPlayerSendCommandsEvent
  - Allows modifying on a per command basis what command data they see.

Adds CommandRegisteredEvent
  - Allows manipulating the CommandNode to add more children/metadata for the client
This commit is contained in:
Aikar
2020-04-19 18:15:29 -04:00
parent 41218728d9
commit 05f977e3d1
6 changed files with 189 additions and 95 deletions

View File

@@ -0,0 +1,23 @@
--- a/com/mojang/brigadier/exceptions/CommandSyntaxException.java
+++ b/com/mojang/brigadier/exceptions/CommandSyntaxException.java
@@ -5,7 +5,7 @@
import com.mojang.brigadier.Message;
-public class CommandSyntaxException extends Exception {
+public class CommandSyntaxException extends Exception implements net.kyori.adventure.util.ComponentMessageThrowable { // Paper - Brigadier API
public static final int CONTEXT_AMOUNT = 10;
public static boolean ENABLE_COMMAND_STACK_TRACES = true;
public static BuiltInExceptionProvider BUILT_IN_EXCEPTIONS = new BuiltInExceptions();
@@ -73,4 +73,11 @@
public int getCursor() {
return cursor;
}
+
+ // Paper start - Brigadier API
+ @Override
+ public @org.jetbrains.annotations.Nullable net.kyori.adventure.text.Component componentMessage() {
+ return io.papermc.paper.brigadier.PaperBrigadier.componentFromMessage(this.message);
+ }
+ // Paper end - Brigadier API
}

View File

@@ -16,10 +16,11 @@
public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
private final Map<String, CommandNode<S>> children = new LinkedHashMap<>();
@@ -32,6 +34,13 @@
@@ -32,6 +34,14 @@
private final RedirectModifier<S> modifier;
private final boolean forks;
private Command<S> command;
+ public CommandNode<CommandSourceStack> clientNode; // Paper - Brigadier API
+ // CraftBukkit start
+ public void removeCommand(String name) {
+ this.children.remove(name);
@@ -30,7 +31,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 +70,17 @@
@@ -61,7 +71,17 @@
return this.modifier;
}