mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 20:07:32 +00:00
Fixed KeyPreset throttling logic
so ONLY HOLD presses are affected
This commit is contained in:
1 parent
4b7effe2d7
commit
af0553ba0d
1 file changed
+11
-5
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user