From 582f1c41bf434a54aa40bd9210a8f75bf1620d00 Mon Sep 17 00:00:00 2001 From: Shiewk Date: Sat, 8 Jun 2024 17:52:20 +0200 Subject: [PATCH] No negative durations --- src/main/java/de/shiewk/smoderation/command/BanCommand.java | 4 ++++ src/main/java/de/shiewk/smoderation/command/MuteCommand.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/de/shiewk/smoderation/command/BanCommand.java b/src/main/java/de/shiewk/smoderation/command/BanCommand.java index f3800cc..f282d6d 100644 --- a/src/main/java/de/shiewk/smoderation/command/BanCommand.java +++ b/src/main/java/de/shiewk/smoderation/command/BanCommand.java @@ -62,6 +62,10 @@ public class BanCommand implements CommandExecutor, TabCompleter { sender.sendMessage(Component.text("Please provide a valid duration.").color(NamedTextColor.RED)); return false; } + if (duration < 0){ + sender.sendMessage(Component.text("Please provide a duration that's longer than 0ms.").color(NamedTextColor.RED)); + return false; + } StringBuilder reason = new StringBuilder(); for (int i = p; i < args.length; i++) { if (!reason.isEmpty()){ diff --git a/src/main/java/de/shiewk/smoderation/command/MuteCommand.java b/src/main/java/de/shiewk/smoderation/command/MuteCommand.java index 41f449d..dcb440c 100644 --- a/src/main/java/de/shiewk/smoderation/command/MuteCommand.java +++ b/src/main/java/de/shiewk/smoderation/command/MuteCommand.java @@ -62,6 +62,10 @@ public class MuteCommand implements CommandExecutor, TabCompleter { sender.sendMessage(Component.text("Please provide a valid duration.").color(NamedTextColor.RED)); return false; } + if (duration < 0){ + sender.sendMessage(Component.text("Please provide a duration that's longer than 0ms.").color(NamedTextColor.RED)); + return false; + } StringBuilder reason = new StringBuilder(); for (int i = p; i < args.length; i++) { if (!reason.isEmpty()){