diff options
author | Äkwav <ekwav@coflnet.com> | 2022-06-04 14:46:42 +0200 |
---|---|---|
committer | Äkwav <ekwav@coflnet.com> | 2022-06-04 14:46:42 +0200 |
commit | cab805393559a9a7e6433199aaf8591cc9a8ae98 (patch) | |
tree | 27d16b3971d3227f50637ed179f5381de5e45b71 | |
parent | cd127e92dfd9657977b180678dbe76306a3e917f (diff) | |
download | COFL-cab805393559a9a7e6433199aaf8591cc9a8ae98.tar.gz COFL-cab805393559a9a7e6433199aaf8591cc9a8ae98.tar.bz2 COFL-cab805393559a9a7e6433199aaf8591cc9a8ae98.zip |
only send nobestflip once and clearify code
-rw-r--r-- | src/main/java/de/torui/coflsky/WSCommandHandler.java | 4 | ||||
-rw-r--r-- | 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<SoundData> 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) |