Skip to content

Commit

Permalink
prevent hotkey from being spammed when held
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-luger committed Oct 30, 2023
1 parent 2088cda commit 9e01f85
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/de/torui/coflsky/handlers/EventRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
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.*;
Expand All @@ -58,12 +59,18 @@ public void onDisconnectedFromServerEvent(ClientDisconnectionFromServerEvent eve
}

public long LastClick = System.currentTimeMillis();
public boolean LastKeyboardState;
private DescriptionHandler descriptionHandler;

@SideOnly(Side.CLIENT)
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void onKeyEvent(KeyInputEvent event) {

if(Keyboard.getEventKeyState() == LastKeyboardState){
return;
}
LastKeyboardState = Keyboard.getEventKeyState();

if (CoflSky.keyBindings[0].isPressed()) {
if (WSCommandHandler.lastOnClickEvent != null) {
FlipData f = WSCommandHandler.flipHandler.fds.GetLastFlip();
Expand Down

0 comments on commit 9e01f85

Please sign in to comment.