Skip to content

Commit

Permalink
DynamicCommands: Add helper method for getting the dispatcher root node
Browse files Browse the repository at this point in the history
  • Loading branch information
mattco98 committed Dec 1, 2023
1 parent f4abb20 commit 4faf510
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/ctjs.api
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ public final class com/chattriggers/ctjs/api/commands/DynamicCommands : com/chat
public static final fun floatRange ()Lnet/minecraft/command/argument/NumberRangeArgumentType$FloatRangeArgumentType;
public static final fun gameMode ()Lnet/minecraft/command/argument/GameModeArgumentType;
public static final fun gameProfile ()Lcom/mojang/brigadier/arguments/ArgumentType;
public static final fun getDispatcherRoot ()Lcom/mojang/brigadier/tree/RootCommandNode;
public static final fun greedyString ()Lcom/mojang/brigadier/arguments/StringArgumentType;
public static final fun intRange ()Lnet/minecraft/command/argument/NumberRangeArgumentType$IntRangeArgumentType;
public static final fun integer ()Lcom/mojang/brigadier/arguments/IntegerArgumentType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ object DynamicCommands : CommandCollection() {
currentNode!!.method = method
}

/**
* A helper method for getting Fabric's client CommandDispatcher root node. This allows user
* commands to be redirected to the root node in the same way that "/execute run ..." does.
*
* As the result is a CommandNode, `.getChild(name)` can be used to access sub-command nodes
* to, for example, redirect to just `/advancement` instead of `/`.
*/
@JvmStatic
fun getDispatcherRoot() = Client.getConnection()?.commandDispatcher?.root

/////////////////////////
// Brigadier Arg Types //
/////////////////////////
Expand Down

0 comments on commit 4faf510

Please sign in to comment.