Adjusted Command Processing

Completion annotations have been moved to top level, from per method, for a much clearer understanding of how the annotation should be used.
This commit is contained in:
Paul Reilly
2023-07-23 02:15:12 -05:00
parent 2b12f4eebb
commit 6842cb2792
16 changed files with 71 additions and 66 deletions

View File

@ -37,6 +37,9 @@ import org.jetbrains.annotations.NotNull;
@Info(name = "cage", description = "Cage a player.",
usage = "/cage <player> <on|off> [material]")
@Permissive(perm = "datura.cage")
@Completion(args = {"%player%"}, index = 0)
@Completion(args = {"on", "off"}, index = 1)
@Completion(args = {"[material]"}, index = 2)
public class CageCommand extends Commander
{
protected CageCommand(final @NotNull JavaPlugin plugin)
@ -44,8 +47,6 @@ public class CageCommand extends Commander
super(plugin);
}
@Completion(args = {"%player%"}, index = 0)
@Completion(args = {"on", "off"}, index = 1)
@Subcommand(permission = "datura.cage", args = {Player.class, String.class})
public void cagePlayer(final CommandSender sender, final Player player, final String string)
{
@ -62,7 +63,6 @@ public class CageCommand extends Commander
}
}
@Completion(args = {"[material]"}, index = 2)
@Subcommand(permission = "datura.cage.custom", args = {Player.class, String.class, Material.class})
public void cagePlayer(final CommandSender sender, final Player player, final String string,
final Material material)

View File

@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
@Info(name = "cleardrops", description = "Clears all item drops in the world" + ".", usage = "/<command>", aliases =
{"cd", "clearitems", "ci", "wipeitems", "wi", "removedrops", "rd"})
@Permissive(perm = "datura.cleardrops")
@Completion(index = 0, args = {"%world%"})
public class ClearDropsCommand extends Commander
{
/**
@ -70,7 +71,6 @@ public class ClearDropsCommand extends Commander
}
@Subcommand(permission = "datura.cleardrops", args = {World.class})
@Completion(index = 0, args = {"%world%"})
public void clearDrops(final CommandSender sender, final World world)
{
Patchwork.getInstance()

View File

@ -17,6 +17,7 @@ import org.jetbrains.annotations.NotNull;
@Info(name = "clearentities", description = "Clears all entities in the world.", usage = "/<command> [world]",
aliases = {"ew", "ce", "entitywipe", "entityclear", "ec"})
@Permissive(perm = "datura.clearentities")
@Completion(index = 0, args = {"%world%"})
public class ClearEntitiesCommand extends Commander
{
/**
@ -57,7 +58,6 @@ public class ClearEntitiesCommand extends Commander
}
@Subcommand(permission = "datura.clearentities", args = {World.class})
@Completion(index = 0, args = {"%world%"})
public void clearEntities(final CommandSender sender, final World world)
{
int i = 0;

View File

@ -17,6 +17,8 @@ import org.jetbrains.annotations.NotNull;
@Info(name = "halt", description = "Halt a single player, or every player.", usage = "/<command> <player | all> <on, off>")
@Permissive(perm = "datura.halt")
@Completion(index = 0, args = {"%player%", "all"})
@Completion(index = 1, args = {"on", "off"})
public class HaltCommand extends Commander
{
private final Datura plugin = Shortcuts.provideModule(Datura.class);
@ -35,9 +37,6 @@ public class HaltCommand extends Commander
super(plugin);
}
@Completion(index = 0, args = {"%player%", "all"})
@Completion(index = 1, args = {"on", "off"})
@Subcommand(permission = "datura.halt", args = {Player.class, String.class})
public void haltPlayer(final CommandSender sender, final Player target, final String toggle)
{
@ -58,7 +57,6 @@ public class HaltCommand extends Commander
}
}
// No completion needed here since it's already registered.
@Subcommand(permission = "datura.halt.all", args = {String.class, String.class})
public void haltAll(final CommandSender sender, final String all, final String toggle)
{

View File

@ -13,6 +13,8 @@ import org.jetbrains.annotations.NotNull;
@Info(name = "locker", description = "Lock a player, preventing them from interacting with their game client.",
usage = "/locker <player> <on|off>", aliases = {"lock", "lockup"})
@Permissive(perm = "datura.locker")
@Completion(args = {"%player%"}, index = 0)
@Completion(args = {"on", "off"}, index = 1)
public final class LockerCommand extends Commander
{
public LockerCommand(final @NotNull Datura plugin)
@ -20,8 +22,6 @@ public final class LockerCommand extends Commander
super(plugin);
}
@Completion(args = {"%player%"}, index = 0)
@Completion(args = {"on", "off"}, index = 1)
@Subcommand(permission = "datura.locker", args = {Player.class, String.class})
public void lockPlayer(final CommandSender sender, final Player player, final String string)
{

View File

@ -20,6 +20,9 @@ import org.jetbrains.annotations.NotNull;
@Info(name = "manageuser", description = "Manage a user's permissions", usage = "/manageuser <username> <info | (add "
+ "| remove <permission>)>", aliases = {"mu", "userdata", "ud", "usermanager", "um"})
@Permissive(perm = "datura.manageuser")
@Completion(index = 0, args = {"%player%"})
@Completion(index = 1, args = {"info", "add", "remove"})
@Completion(index = 2, args = {"<permission>"})
public class ManageUserCommand extends Commander
{
@ -38,9 +41,6 @@ public class ManageUserCommand extends Commander
}
@Subcommand(permission = "datura.manageuser", args = {Player.class, String.class, String.class, Long.class})
@Completion(index = 0, args = {"%player%"})
@Completion(index = 1, args = {"info", "add", "remove"})
@Completion(index = 2, args = {"<permission>"})
public void manageUser(final CommandSender sender, final Player player, final String addOrRemove,
final String permission, final long duration)
{

View File

@ -13,6 +13,7 @@ import org.jetbrains.annotations.NotNull;
@Info(name = "smite", description = "Smite a player.", usage = "/smite <player>", aliases = {"sm"})
@Permissive(perm = "datura.smite")
@Completion(index = 0, args = {"%player%"})
public class SmiteCommand extends Commander
{
/**
@ -30,7 +31,6 @@ public class SmiteCommand extends Commander
}
@Subcommand(permission = "datura.smite", args = {Player.class})
@Completion(index = 0, args = {"%player%"})
public void smite(final CommandSender sender, final Player player)
{
final double size = 5D;