LiteCommands
LiteCommands copied to clipboard
Support a `@ExecuteDefault` in command clasases to show usage originally
Sometimes we want to display originally usages to players instead of auto-generated one,
so maybe we could support a annotation like @UsageExecute
used in command classes,
which will be called in "No command found" situtation, to replace the generated messages (by SchematicFormat
usually).
It looks like this:
package com.artformgames.plugin.tempflight.command;
import dev.rollczi.litecommands.annotations.argument.Arg;
import dev.rollczi.litecommands.annotations.command.Command;
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.description.Description;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import org.bukkit.command.CommandSender;
@Command(name = "sample")
public class SampleCommand {
@UsageExecute
void help(@Context CommandSender sender) {
sender.sendMessage("The command require xxx to execute,");
sender.sendMessage("Maybe you can use /sample set <value> ?");
}
@Execute(name = "sample")
@Description("Sample command")
@Permission("sample.permission")
void sample(@Context CommandSender sender) {
System.out.println("Sample command");
}
@Execute(name = "set")
@Description("Sample command")
@Permission("sample.permission")
void set(@Context CommandSender sender, @Arg Integer someValue) {
System.out.println("Sample command");
}
}