Package group.worldstandard.pudel.api.command
package group.worldstandard.pudel.api.command
Text (prefix-based) command handling API.
This package provides interfaces and classes for creating and managing text-based commands. Text commands are triggered by a configurable prefix (e.g., "!") followed by the command name.
The preferred approach is to use the TextCommand
annotation on methods in your plugin class. For dynamic command registration,
implement TextCommandHandler.
Key Components:
CommandContext- Context provided to command handlersTextCommandHandler- Functional interface for command handlingCommandRegister- Interface for programmatic registrationCommandInfo- Annotation for command metadata on handler classes
Annotation-based Command:
@Plugin(name = "MyPlugin", version = "1.0.0", author = "Author")
public class MyPlugin {
@TextCommand(name = "greet", description = "Greet a user",
usage = "greet <name>", aliases = {"hi", "hello"})
public void greet(CommandContext context) {
String name = context.hasArgs() ? context.getArgsString() : "World";
context.reply("Hello, " + name + "!");
}
}
Programmatic Registration:
@OnEnable
public void onEnable(PluginContext context) {
context.registerCommand("ping", ctx -> ctx.reply("Pong!"));
}
- Since:
- 2.3.0
-
ClassDescriptionContext provided to text command handlers during command execution.Annotation for defining text command metadata on handler classes.Interface for programmatic text command registration and unregistration.Functional interface for handling text (prefix-based) commands.