mirror of
https://github.com/kaboomserver/extras.git
synced 2025-01-10 08:27:38 +00:00
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
This commit is contained in:
parent
8fe96bcc2b
commit
7450b8bcc9
2 changed files with 5 additions and 6 deletions
|
@ -23,7 +23,7 @@ import java.util.regex.Pattern;
|
||||||
public final class PlayerChat implements Listener {
|
public final class PlayerChat implements Listener {
|
||||||
private static final PlayerChatRenderer CHAT_RENDERER = new PlayerChatRenderer();
|
private static final PlayerChatRenderer CHAT_RENDERER = new PlayerChatRenderer();
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
||||||
void onAsyncChatEventProcess(final AsyncChatEvent event) {
|
void onAsyncChatEventProcess(final AsyncChatEvent event) {
|
||||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ public final class PlayerChat implements Listener {
|
||||||
|
|
||||||
if (millisDifference < 50) {
|
if (millisDifference < 50) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.UUID;
|
||||||
import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent;
|
import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ import pw.kaboom.extras.modules.server.ServerCommand;
|
||||||
public final class PlayerCommand implements Listener {
|
public final class PlayerCommand implements Listener {
|
||||||
private static HashMap<UUID, Long> commandMillisList = new HashMap<UUID, Long>();
|
private static HashMap<UUID, Long> commandMillisList = new HashMap<UUID, Long>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
||||||
void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
||||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||||
|
|
||||||
|
@ -24,15 +25,12 @@ public final class PlayerCommand implements Listener {
|
||||||
|
|
||||||
if (millisDifference < 75) {
|
if (millisDifference < 75) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getCommandMillisList().put(playerUuid, System.currentTimeMillis());
|
getCommandMillisList().put(playerUuid, System.currentTimeMillis());
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final CommandSender sender = event.getPlayer();
|
final CommandSender sender = event.getPlayer();
|
||||||
final String command = event.getMessage();
|
final String command = event.getMessage();
|
||||||
final boolean isConsoleCommand = false;
|
final boolean isConsoleCommand = false;
|
||||||
|
|
Loading…
Reference in a new issue