Skip to content

Commit

Permalink
Fix command args
Browse files Browse the repository at this point in the history
  • Loading branch information
Laica-Lunasys committed Jul 13, 2024
1 parent 0f5918c commit 68346d9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,7 +17,7 @@ public class DispatchCommand {
@Command("dispatch <target> <command>")
@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("<green>Dispatched: %s >> </green><gold>%s</gold>", target, command));

plugin.getApiClient().dispatch(target, command).whenComplete((result, throwable) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,21 +18,21 @@ public class PunishCommand {
@Command("warn <target> <reason>")
@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 <target> <reason>")
@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 <target> <reason>")
@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";

Expand All @@ -46,7 +47,7 @@ public void onTempBan(CommandSender sender, @Argument(value = "target", suggesti
@Command("ban|permban|pban|ppunish <target> <reason>")
@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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,7 +21,7 @@ public class ReportCommand {
@Command("report|modreq|sos|helpop <target> <message>")
@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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,7 +22,7 @@ public class RunasCommand {
@Command("runas|sudo <target> <command>")
@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("<green>Run as </green><gold>everyone</gold><green>: </green>")
Expand Down

0 comments on commit 68346d9

Please sign in to comment.