aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/torui/coflsky/handlers/EventRegistry.java
diff options
context:
space:
mode:
authormatthias-luger <58751503+matthias-luger@users.noreply.github.com>2023-10-31 16:12:14 +0100
committerGitHub <noreply@github.com>2023-10-31 16:12:14 +0100
commited5052c23c2e48cd696e3708bbbfc911dcc1718e (patch)
treed2a8ad8dca0e11680804d92e85ef41a841336312 /src/main/java/de/torui/coflsky/handlers/EventRegistry.java
parent2088cda8b5a9d17047ddc1efd8a5c328795aa58d (diff)
downloadCOFL-ed5052c23c2e48cd696e3708bbbfc911dcc1718e.tar.gz
COFL-ed5052c23c2e48cd696e3708bbbfc911dcc1718e.tar.bz2
COFL-ed5052c23c2e48cd696e3708bbbfc911dcc1718e.zip
prevent hotkey from being spammed when held (#109)
* prevent hotkey from being spammed when held * fix hotkey holding still working
Diffstat (limited to 'src/main/java/de/torui/coflsky/handlers/EventRegistry.java')
-rw-r--r--src/main/java/de/torui/coflsky/handlers/EventRegistry.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/de/torui/coflsky/handlers/EventRegistry.java b/src/main/java/de/torui/coflsky/handlers/EventRegistry.java
index 81300ad..3ebd168 100644
--- a/src/main/java/de/torui/coflsky/handlers/EventRegistry.java
+++ b/src/main/java/de/torui/coflsky/handlers/EventRegistry.java
@@ -38,6 +38,7 @@ import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientDisconnection
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.common.gameevent.TickEvent;
+import org.lwjgl.input.Keyboard;
import static de.torui.coflsky.CoflSky.config;
import static de.torui.coflsky.handlers.DescriptionHandler.*;
@@ -57,13 +58,22 @@ public class EventRegistry {
}
}
- public long LastClick = System.currentTimeMillis();
+ public static long LastClick = System.currentTimeMillis();
+ public static Boolean LastHotkeyState;
private DescriptionHandler descriptionHandler;
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void onKeyEvent(KeyInputEvent event) {
+ if (LastHotkeyState != null && Keyboard.getEventKeyState() == LastHotkeyState) {
+ return;
+ }
+ LastHotkeyState = Keyboard.getEventKeyState();
+ onAfterKeyPressed();
+ }
+
+ public static void onAfterKeyPressed() {
if (CoflSky.keyBindings[0].isPressed()) {
if (WSCommandHandler.lastOnClickEvent != null) {
FlipData f = WSCommandHandler.flipHandler.fds.GetLastFlip();