From cab805393559a9a7e6433199aaf8591cc9a8ae98 Mon Sep 17 00:00:00 2001 From: Äkwav Date: Sat, 4 Jun 2022 14:46:42 +0200 Subject: only send nobestflip once and clearify code --- src/main/java/de/torui/coflsky/WSCommandHandler.java | 4 ++-- src/main/java/de/torui/coflsky/handlers/EventRegistry.java | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/torui/coflsky/WSCommandHandler.java b/src/main/java/de/torui/coflsky/WSCommandHandler.java index ca583a2..ef15381 100644 --- a/src/main/java/de/torui/coflsky/WSCommandHandler.java +++ b/src/main/java/de/torui/coflsky/WSCommandHandler.java @@ -68,8 +68,8 @@ public class WSCommandHandler { ChatMessage(showCmd); flipHandler.fds.Insert(new de.torui.coflsky.FlipHandler.Flip(cmd.getData().Id, cmd.getData().Worth)); - //just to be safe emit a event - CoflSky.Events.onEvent(null); + // trigger the keyevent to execute the event handler + CoflSky.Events.onKeyEvent(null); } private static void PlaySound(Command cmd, Entity sender) { diff --git a/src/main/java/de/torui/coflsky/handlers/EventRegistry.java b/src/main/java/de/torui/coflsky/handlers/EventRegistry.java index 81411f4..aaee721 100644 --- a/src/main/java/de/torui/coflsky/handlers/EventRegistry.java +++ b/src/main/java/de/torui/coflsky/handlers/EventRegistry.java @@ -60,7 +60,7 @@ public class EventRegistry { @SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) - public void onEvent(KeyInputEvent event) { + public void onKeyEvent(KeyInputEvent event) { if (CoflSky.keyBindings[0].isPressed()) { if (WSCommandHandler.lastOnClickEvent != null) { @@ -74,7 +74,7 @@ public class EventRegistry { } if(CoflSky.keyBindings[1].isKeyDown()) { - if((System.currentTimeMillis() - LastClick) >= 400) { + if((System.currentTimeMillis() - LastClick) >= 300) { Flip f = WSCommandHandler.flipHandler.fds.GetHighestFlip(); @@ -87,12 +87,12 @@ public class EventRegistry { WSCommandHandler.Execute("/cofl track besthotkey " + f.id, Minecraft.getMinecraft().thePlayer); CoflSky.Wrapper.SendMessage(new JsonStringCommand(CommandType.Clicked, command)); } else { - WSCommandHandler.Execute("/cofl dialog nobestflip", Minecraft.getMinecraft().thePlayer); - } - + // only display message once (if this is the key down event) + if(CoflSky.keyBindings[1].isPressed()) + WSCommandHandler.Execute("/cofl dialog nobestflip", Minecraft.getMinecraft().thePlayer); + } } } - } @SideOnly(Side.CLIENT) -- cgit