From 7450b8bcc9c2da492890ddc46d23b64cb0a3588b Mon Sep 17 00:00:00 2001 From: amy <144570677+amyavi@users.noreply.github.com> Date: Tue, 10 Sep 2024 20:15:45 -0300 Subject: [PATCH 1/3] Don't re-apply command rate-limit when command is ratelimited (#364) * fix: don't re-apply ratelimit when user is already ratelimited * fix: lower command ratelimit event priority Makes command spam not show up in CommandSpy --- .../java/pw/kaboom/extras/modules/player/PlayerChat.java | 3 ++- .../pw/kaboom/extras/modules/player/PlayerCommand.java | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java index 62747cb..a40644e 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java @@ -23,7 +23,7 @@ import java.util.regex.Pattern; public final class PlayerChat implements Listener { private static final PlayerChatRenderer CHAT_RENDERER = new PlayerChatRenderer(); - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOW) void onAsyncChatEventProcess(final AsyncChatEvent event) { final UUID playerUuid = event.getPlayer().getUniqueId(); @@ -33,6 +33,7 @@ public final class PlayerChat implements Listener { if (millisDifference < 50) { event.setCancelled(true); + return; } } diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java index b1fd441..cc3e5d0 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java @@ -6,6 +6,7 @@ import java.util.UUID; import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent; import org.bukkit.command.CommandSender; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; @@ -14,7 +15,7 @@ import pw.kaboom.extras.modules.server.ServerCommand; public final class PlayerCommand implements Listener { private static HashMap<UUID, Long> commandMillisList = new HashMap<UUID, Long>(); - @EventHandler + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOW) void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) { final UUID playerUuid = event.getPlayer().getUniqueId(); @@ -24,15 +25,12 @@ public final class PlayerCommand implements Listener { if (millisDifference < 75) { event.setCancelled(true); + return; } } getCommandMillisList().put(playerUuid, System.currentTimeMillis()); - if (event.isCancelled()) { - return; - } - final CommandSender sender = event.getPlayer(); final String command = event.getMessage(); final boolean isConsoleCommand = false; From 3278ddaddc86d6171fecf82817d246fe2cd53c28 Mon Sep 17 00:00:00 2001 From: GEOEGII555 <57674559+GEOEGII555@users.noreply.github.com> Date: Wed, 11 Sep 2024 02:19:56 +0300 Subject: [PATCH 2/3] Block the /execute ... run datapack command (#361) * Block the /execute ... run datapack command The /datapack list command is useless, and the other 2 subcommands (/datapack enable and /datapack disable) can be used to cause huge lag on the server. * Update ServerCommand.java (partial revert) --- .../java/pw/kaboom/extras/modules/server/ServerCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java index 7698b9c..9659fec 100644 --- a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java @@ -23,7 +23,7 @@ public final class ServerCommand implements Listener { private static final Pattern SELECTOR_PATTERN = Pattern.compile("(?>\\s)*@[aepsr](?>\\s)*"); private static final Logger LOGGER = JavaPlugin.getPlugin(Main.class).getLogger(); - private static final String[] COMMANDS = { "execute", "clone", "fill", "forceload", "kick", + private static final String[] COMMANDS = { "execute", "clone", "datapack", "fill", "forceload", "kick", "locate", "locatebiome", "me", "msg", "reload", "save-all", "say", "spreadplayers", "stop", "summon", "teammsg", "teleport", "tell", "tellraw", "tm", "tp", "w", "place", "fillbiome", "ride" , "tick", "jfr"}; From d882118c96088770b23f2232c3b4e6702920eabe Mon Sep 17 00:00:00 2001 From: Kaboom <58372747+kaboombot@users.noreply.github.com> Date: Wed, 11 Sep 2024 02:21:19 +0300 Subject: [PATCH 3/3] ServerCommand.java: Fix checkstyle violation --- .../pw/kaboom/extras/modules/server/ServerCommand.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java index 9659fec..cdee54b 100644 --- a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java @@ -23,10 +23,10 @@ public final class ServerCommand implements Listener { private static final Pattern SELECTOR_PATTERN = Pattern.compile("(?>\\s)*@[aepsr](?>\\s)*"); private static final Logger LOGGER = JavaPlugin.getPlugin(Main.class).getLogger(); - private static final String[] COMMANDS = { "execute", "clone", "datapack", "fill", "forceload", "kick", - "locate", "locatebiome", "me", "msg", "reload", "save-all", "say", "spreadplayers", - "stop", "summon", "teammsg", "teleport", "tell", "tellraw", "tm", "tp", "w", "place", - "fillbiome", "ride" , "tick", "jfr"}; + private static final String[] COMMANDS = { "execute", "clone", "datapack", "fill", + "forceload", "kick", "locate", "locatebiome", "me", "msg", "reload", "save-all", + "say", "spreadplayers", "stop", "summon", "teammsg", "teleport", "tell", "tellraw", + "tm", "tp", "w", "place", "fillbiome", "ride" , "tick", "jfr"}; public static boolean checkExecuteCommand(final String cmd) { for (String command : COMMANDS) {