From 6fd6138f40f5ae1d0f924a7de382d889e277ee59 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Thu, 21 Jul 2022 18:18:18 +0900 Subject: fix: fix locraw cancelling all locraw messages (#61) * fix: fix locraw cancelling all locraw messages * fix: use a separate variable for cancelling locraw messages --- .../java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main/java/cc/polyfrost') diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java index 3e719de..dcef472 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java @@ -29,6 +29,7 @@ public class HypixelUtils { private int limboLoop = 0; private boolean sentCommand = false; + private boolean cancel = false; private boolean sendPermitted = false; private boolean inGame; @@ -72,6 +73,7 @@ public class HypixelUtils { sendPermitted = true; Multithreading.schedule(() -> { if (sendPermitted) { + cancel = true; UChat.say("/locraw"); } }, interval, TimeUnit.MILLISECONDS); @@ -96,6 +98,7 @@ public class HypixelUtils { private void onWorldLoad(WorldLoadEvent event) { locraw = null; sendPermitted = false; + cancel = false; sentCommand = false; limboLoop = 0; } @@ -103,6 +106,7 @@ public class HypixelUtils { @Subscribe private void onMessageReceived(ChatReceiveEvent event) { try { + final boolean didSendCommand = sentCommand; final String msg = event.getFullyUnformattedMessage(); // Checking for rate limitation. if (!(msg.startsWith("{") && msg.endsWith("}"))) { @@ -131,7 +135,10 @@ public class HypixelUtils { inGame = true; // If your gamemode does not return "lobby", boolean inGame is true. } EventManager.INSTANCE.post(new LocrawEvent(locraw)); - event.isCancelled = true; + if (cancel && didSendCommand) { + cancel = false; + event.isCancelled = true; + } } } catch (Exception ex) { ex.printStackTrace(); -- cgit