Package dev.jorel.commandapi
Class CommandAPIHandler<Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender,Source>
java.lang.Object
dev.jorel.commandapi.CommandAPIHandler<Argument,CommandSender,Source>
- Type Parameters:
Argument- The implementation of AbstractArgument being usedCommandSender- The class for running platform commandsSource- The class for running Brigadier commands
public class CommandAPIHandler<Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender,Source>
extends Object
The "brains" behind the CommandAPI.
Handles command registration
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.brigadier.Command<Source> generateCommand(Argument[] args, CommandAPIExecutor<CommandSender, AbstractCommandSender<? extends CommandSender>> executor, boolean converted) Generates a command to be registered by the CommandAPI.static FieldCaches a field using reflection if it is not already cached, then return the field of a given class.static FieldCaches a field using reflection if it is not already cached, then return the field of a given class.static CommandAPIHandler<?, ?, ?> static <CommandSource>
StringgetRawArgumentInput(com.mojang.brigadier.context.CommandContext<CommandSource> cmdCtx, String key) Returns the raw input for an argument for a given command context and its key.voidvoidonEnable()voidonLoad()void
-
Constructor Details
-
CommandAPIHandler
-
-
Method Details
-
getRawArgumentInput
public static <CommandSource> String getRawArgumentInput(com.mojang.brigadier.context.CommandContext<CommandSource> 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:
CommandSource- 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
-
onLoad
public void onLoad() -
onEnable
public void onEnable() -
onDisable
public void onDisable() -
getInstance
-
getPlatform
-
generateCommand
public com.mojang.brigadier.Command<Source> generateCommand(Argument[] args, CommandAPIExecutor<CommandSender, AbstractCommandSender<? extends CommandSender>> executor, boolean converted) Generates a command to be registered by the CommandAPI.- Parameters:
args- set of ordered argument pairs which contain the prompt text and their argument typesexecutor- code to be ran when the command is executedconverted- True if this command is being converted from another plugin, and false otherwise- Returns:
- a brigadier command which is registered internally
-
writeDispatcherToFile
public void writeDispatcherToFile() -
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
-
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 fieldmojangMappedName- the name of a field under Mojang mappings- Returns:
- a Field reference
-