Package dev.jorel.commandapi
Class CommandAPIHandler<CommandSourceStack>
java.lang.Object
dev.jorel.commandapi.CommandAPIHandler<CommandSourceStack>
Handles the main backend of the CommandAPI. This constructs brigadier Command
objects, applies and generates arguments and handles suggestions. This also
handles permission registration for Bukkit, interactions for NMS and the
registration and unregistration of commands.
-
Method Summary
Modifier and TypeMethodDescriptionCaches a field using reflection if it is not already cached, then return the field of a given class.static CommandAPIHandler<?>Returns the Singleton instance of the CommandAPI's internal handlergetNMS()Returns an instance of NMSgetPaper()Returns an instance of PaperImplementationsstatic <CommandSourceStack>
StringgetRawArgumentInput(com.mojang.brigadier.context.CommandContext<CommandSourceStack> cmdCtx, String key) Returns the raw input for an argument for a given command context and its key.lookupPreviewable(List<String> path) Looks up the function to generate a chat preview for a path of nodes in the command tree.boolean
-
Method Details
-
getRawArgumentInput
public static <CommandSourceStack> String getRawArgumentInput(com.mojang.brigadier.context.CommandContext<CommandSourceStack> cmdCtx, String key) Returns the raw input for an argument for a given command context and its key. This effectively returns the string value that is currently typed for this argument- Type Parameters:
CommandSourceStack- the command source type- Parameters:
cmdCtx- the command context which is used to run this commandkey- the node name for the argument- Returns:
- the raw input string for this argument
-
getInstance
Returns the Singleton instance of the CommandAPI's internal handler- Returns:
- the Singleton instance of the CommandAPI's internal handler
-
getNMS
Returns an instance of NMS- Returns:
- an instance of NMS
-
getPaper
Returns an instance of PaperImplementations- Returns:
- an instance of PaperImplementations
-
lookupPreviewable
Looks up the function to generate a chat preview for a path of nodes in the command tree. This is a method internal to the CommandAPI and isn't expected to be used by plugin developers (but you're more than welcome to use it as you see fit).- Parameters:
path- a list of Strings representing the path (names of command nodes) to (and including) the previewable argument- Returns:
- a function that takes in a
PreviewInfoand returns aComponent. If such a function is not available, this will return a function that always returns null.
-
lookupPreviewableLegacyStatus
- Parameters:
path- a list of Strings representing the path (names of command nodes) to (and including) the previewable argument- Returns:
- Whether a previewable is legacy (non-Adventure) or not
-
getField
Caches a field using reflection if it is not already cached, then return the field of a given class. This will also make the field accessible.- Parameters:
clazz- the class where the field is declaredname- the name of the field- Returns:
- a Field reference
-