From 68346d96875fa5f1b1f36c587a0b60cc33428f93 Mon Sep 17 00:00:00 2001 From: Laica Lunasys Date: Sat, 13 Jul 2024 15:50:37 +0900 Subject: [PATCH] Fix command args --- .../net/synchthia/systera/commands/DispatchCommand.java | 3 ++- .../net/synchthia/systera/commands/PunishCommand.java | 9 +++++---- .../net/synchthia/systera/commands/ReportCommand.java | 3 ++- .../net/synchthia/systera/commands/RunasCommand.java | 3 ++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/synchthia/systera/commands/DispatchCommand.java b/src/main/java/net/synchthia/systera/commands/DispatchCommand.java index 608200a..0839233 100644 --- a/src/main/java/net/synchthia/systera/commands/DispatchCommand.java +++ b/src/main/java/net/synchthia/systera/commands/DispatchCommand.java @@ -4,6 +4,7 @@ import net.kyori.adventure.text.Component; import net.synchthia.systera.SysteraPlugin; import org.bukkit.command.CommandSender; +import org.incendo.cloud.annotation.specifier.Greedy; import org.incendo.cloud.annotations.Argument; import org.incendo.cloud.annotations.Command; import org.incendo.cloud.annotations.CommandDescription; @@ -16,7 +17,7 @@ public class DispatchCommand { @Command("dispatch ") @Permission("systera.command.dispatch") @CommandDescription("Dispatch commands for the specified or all servers") - public void onDispatch(CommandSender sender, @Argument("target") String target, @Argument("command") String command) { + public void onDispatch(CommandSender sender, @Argument("target") String target, @Argument("command") @Greedy String command) { sender.sendRichMessage(String.format("Dispatched: %s >> %s", target, command)); plugin.getApiClient().dispatch(target, command).whenComplete((result, throwable) -> { diff --git a/src/main/java/net/synchthia/systera/commands/PunishCommand.java b/src/main/java/net/synchthia/systera/commands/PunishCommand.java index 70c97dd..ec3b319 100644 --- a/src/main/java/net/synchthia/systera/commands/PunishCommand.java +++ b/src/main/java/net/synchthia/systera/commands/PunishCommand.java @@ -5,6 +5,7 @@ import net.synchthia.systera.SysteraPlugin; import net.synchthia.systera.util.DateUtil; import org.bukkit.command.CommandSender; +import org.incendo.cloud.annotation.specifier.Greedy; import org.incendo.cloud.annotations.Argument; import org.incendo.cloud.annotations.Command; import org.incendo.cloud.annotations.CommandDescription; @@ -17,21 +18,21 @@ public class PunishCommand { @Command("warn ") @Permission("systera.command.punishment") @CommandDescription("Warning Command") - public void onWarn(CommandSender sender, @Argument(value = "target", suggestions = "players") String target, @Argument(value = "reason", suggestions = "punish_reason") String reason) { + public void onWarn(CommandSender sender, @Argument(value = "target", suggestions = "players") String target, @Argument(value = "reason", suggestions = "punish_reason") @Greedy String reason) { plugin.getPunishAPI().punish(false, SysteraProtos.PunishLevel.WARN, sender, target, reason, 0L); } @Command("kick ") @Permission("systera.command.punishment") @CommandDescription("Kick Command") - public void onKick(CommandSender sender, @Argument(value = "target", suggestions = "players") String target, @Argument(value = "reason", suggestions = "punish_reason") String reason) { + public void onKick(CommandSender sender, @Argument(value = "target", suggestions = "players") String target, @Argument(value = "reason", suggestions = "punish_reason") @Greedy String reason) { plugin.getPunishAPI().punish(false, SysteraProtos.PunishLevel.KICK, sender, target, reason, 0L); } @Command("tempban|tban|punish ") @Permission("systera.command.punishment") @CommandDescription("Temporary BAN Command") - public void onTempBan(CommandSender sender, @Argument(value = "target", suggestions = "players") String target, @Argument(value = "reason", suggestions = "punish_reason") String reason) { + public void onTempBan(CommandSender sender, @Argument(value = "target", suggestions = "players") String target, @Argument(value = "reason", suggestions = "punish_reason") @Greedy String reason) { // String expireDate = args.hasFlag('t') ? args.getFlag('t') : "7d"; String expireDate = "7d"; @@ -46,7 +47,7 @@ public void onTempBan(CommandSender sender, @Argument(value = "target", suggesti @Command("ban|permban|pban|ppunish ") @Permission("systera.command.punishment") @CommandDescription("Permanently BAN Command") - public void onPermBan(CommandSender sender, @Argument(value = "target", suggestions = "players") String target, @Argument(value = "reason", suggestions = "punish_reason") String reason) { + public void onPermBan(CommandSender sender, @Argument(value = "target", suggestions = "players") String target, @Argument(value = "reason", suggestions = "punish_reason") @Greedy String reason) { plugin.getPunishAPI().punish(true, SysteraProtos.PunishLevel.PERMBAN, sender, target, reason, 0L); } } diff --git a/src/main/java/net/synchthia/systera/commands/ReportCommand.java b/src/main/java/net/synchthia/systera/commands/ReportCommand.java index 725748c..9d66b5b 100644 --- a/src/main/java/net/synchthia/systera/commands/ReportCommand.java +++ b/src/main/java/net/synchthia/systera/commands/ReportCommand.java @@ -5,6 +5,7 @@ import net.synchthia.systera.i18n.I18n; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.incendo.cloud.annotation.specifier.Greedy; import org.incendo.cloud.annotations.Argument; import org.incendo.cloud.annotations.Command; import org.incendo.cloud.annotations.CommandDescription; @@ -20,7 +21,7 @@ public class ReportCommand { @Command("report|modreq|sos|helpop ") @Permission("systera.command.report") @CommandDescription("Report to Staff") - public void onReport(CommandSender sender, @Argument(value = "target", suggestions = "players") String target, @Argument(value = "message", suggestions = "punish_reason") String message) { + public void onReport(CommandSender sender, @Argument(value = "target", suggestions = "players") String target, @Argument(value = "message", suggestions = "punish_reason") @Greedy String message) { Player targetPlayer = plugin.getServer().getPlayer(target); UUID toUUID = targetPlayer != null ? targetPlayer.getUniqueId() : null; diff --git a/src/main/java/net/synchthia/systera/commands/RunasCommand.java b/src/main/java/net/synchthia/systera/commands/RunasCommand.java index e9bd38b..cc5d324 100644 --- a/src/main/java/net/synchthia/systera/commands/RunasCommand.java +++ b/src/main/java/net/synchthia/systera/commands/RunasCommand.java @@ -9,6 +9,7 @@ import net.synchthia.systera.i18n.I18n; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.incendo.cloud.annotation.specifier.Greedy; import org.incendo.cloud.annotations.Argument; import org.incendo.cloud.annotations.Command; import org.incendo.cloud.annotations.CommandDescription; @@ -21,7 +22,7 @@ public class RunasCommand { @Command("runas|sudo ") @Permission("systera.command.runas") @CommandDescription("Make another user perform a command") - public void onRunas(CommandSender sender, @Argument(value = "target", suggestions = "all_and_players") String target, String command) { + public void onRunas(CommandSender sender, @Argument(value = "target", suggestions = "all_and_players") String target, @Argument("command") @Greedy String command) { if (target.equals("*")) { sender.sendMessage( MiniMessage.miniMessage().deserialize("Run as everyone: ")