diff options
-rw-r--r-- | src/main/java/de/torui/coflsky/WSCommandHandler.java | 6 | ||||
-rw-r--r-- | src/main/java/de/torui/coflsky/handlers/EventRegistry.java | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/main/java/de/torui/coflsky/WSCommandHandler.java b/src/main/java/de/torui/coflsky/WSCommandHandler.java index 8d22b62..5bae5b2 100644 --- a/src/main/java/de/torui/coflsky/WSCommandHandler.java +++ b/src/main/java/de/torui/coflsky/WSCommandHandler.java @@ -25,7 +25,6 @@ import net.minecraft.util.ChatStyle; import net.minecraft.util.IChatComponent; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; @@ -97,8 +96,8 @@ public class WSCommandHandler { Command<ChatMessageData[]> showCmd = new Command<ChatMessageData[]>(CommandType.ChatMessage, messages); ChatMessage(showCmd); flipHandler.fds.Insert(cmd.getData()); - // trigger the keyevent to execute the event handler - CoflSky.Events.onKeyEvent(null); + // trigger the onAfterHotkeyPressed function to open the flip if the correct hotkey is currently still pressed + EventRegistry.onAfterKeyPressed(); } private static void handleProxyRequest(ProxyRequest[] request) { @@ -107,7 +106,6 @@ public class WSCommandHandler { } } - public static void cacheMods() { File modFolder = new File(Minecraft.getMinecraft().mcDataDir, "mods"); for (File mods : modFolder.listFiles()) { 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(); |