diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-07-01 06:04:29 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-07-01 06:04:29 +0700 |
commit | d2b1d57120bb51e76191302a58d935afe52b89df (patch) | |
tree | 54d0392d9dff80e70a80e38a3067c3d4ff6886a1 /src | |
parent | 68a2dfb5a22137fb433531542e8660bae023595f (diff) | |
download | OneConfig-d2b1d57120bb51e76191302a58d935afe52b89df.tar.gz OneConfig-d2b1d57120bb51e76191302a58d935afe52b89df.tar.bz2 OneConfig-d2b1d57120bb51e76191302a58d935afe52b89df.zip |
sorry salmon
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java | 3 | ||||
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java | 20 |
2 files changed, 18 insertions, 5 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java index 2a69cc5..4e531de 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java @@ -67,9 +67,10 @@ public class OneConfig { BlurHandler.INSTANCE.load(); CommandManager.INSTANCE.registerCommand(OneConfigCommand.class); EventManager.INSTANCE.register(new HudCore()); - EventManager.INSTANCE.register(HypixelUtils.INSTANCE); + HypixelUtils.INSTANCE.initialize(); EventManager.INSTANCE.register(KeyBindHandler.INSTANCE); ConfigCore.sortMods(); + initialized = true; } 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 df5211b..5489946 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java @@ -13,6 +13,7 @@ import cc.polyfrost.oneconfig.libs.universal.UMinecraft; import cc.polyfrost.oneconfig.libs.universal.wrappers.UPlayer; import cc.polyfrost.oneconfig.libs.universal.wrappers.message.UTextComponent; import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; +import net.minecraftforge.fml.common.Loader; import java.util.Locale; import java.util.concurrent.TimeUnit; @@ -37,6 +38,18 @@ public class HypixelUtils { private LocrawInfo locraw; private LocrawInfo previousLocraw; + private boolean initialized = false; + private boolean isSeraph = false; + + public void initialize() { + if (initialized) { + return; + } + EventManager.INSTANCE.register(this); + isSeraph = Loader.isModLoaded("seraph"); + initialized = true; + } + /** * Checks whether the player is on Hypixel. * @@ -44,7 +57,7 @@ public class HypixelUtils { * @see <a href="https://canary.discord.com/channels/864592657572560958/945075920664928276/978649312013725747">this discord link from jade / asbyth</a> */ public boolean isHypixel() { - if (UMinecraft.getWorld() == null || UMinecraft.getMinecraft().isIntegratedServerRunning()) return false; + if (UMinecraft.getWorld() == null || UMinecraft.getMinecraft().isSingleplayer()) return false; net.minecraft.client.entity.EntityPlayerSP player = UPlayer.getPlayer(); if (player == null) return false; @@ -76,7 +89,7 @@ public class HypixelUtils { if (tick % 20 == 0) { tick = 0; - if (isHypixel() && !sentCommand) { + if (isHypixel() && !sentCommand && !isSeraph) { queueUpdate(500); sentCommand = true; } @@ -94,12 +107,11 @@ public class HypixelUtils { @Subscribe private void onMessageReceived(ChatReceiveEvent event) { - if (!sentCommand) return; try { final String msg = UTextComponent.Companion.stripFormatting(event.message.getUnformattedText()); // Checking for rate limitation. if (!(msg.startsWith("{") && msg.endsWith("}"))) { - if (msg.contains("You are sending too many commands! Please try again in a few seconds.")) // if you're being rate limited, the /locraw command will be resent in 5 seconds. + if (sentCommand && msg.contains("You are sending too many commands! Please try again in a few seconds.")) // if you're being rate limited, the /locraw command will be resent in 5 seconds. queueUpdate(5000); return; } |