From af0553ba0d0b34fee703e4ea2c5330acee0fbd6e Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Sat, 20 Dec 2025 13:55:42 +0200 Subject: [PATCH] Fixed KeyPreset throttling logic so ONLY HOLD presses are affected --- .../java/noppes/npcs/client/key/KeyPreset.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/noppes/npcs/client/key/KeyPreset.java b/src/main/java/noppes/npcs/client/key/KeyPreset.java index 5b2b72517..7bae2c58c 100644 --- a/src/main/java/noppes/npcs/client/key/KeyPreset.java +++ b/src/main/java/noppes/npcs/client/key/KeyPreset.java @@ -74,10 +74,13 @@ public class KeyPreset { return this; } - public boolean shouldThrottle() { + /** + * Determine whether the given press type should be throttled. Only HOLD events are throttled. + */ + public boolean shouldThrottle(PressType pressType) { if (throttleInterval <= 0) return false; long currentTime = System.currentTimeMillis(); - long intervalToUse = isFirstAction && firstThrottleInterval > 0 ? + long intervalToUse = pressType == PressType.HOLD && isFirstAction && firstThrottleInterval > 0 ? firstThrottleInterval : throttleInterval; if (currentTime - lastActionTime < intervalToUse) return true; lastActionTime = currentTime; @@ -122,10 +125,13 @@ public class KeyPreset { } public KeyPreset onAction(PressType... pressTypes) { - if (task != null && !shouldThrottle()) { - for (PressType pressType : pressTypes) + if (task == null) + return this; + + for (PressType pressType : pressTypes) + if (!shouldThrottle(pressType)) this.task.accept(new KeyEvent(pressType, this)); - } + return this; }