From 09679ad7e0e94b984e6a8a3f26ec97e05a987df0 Mon Sep 17 00:00:00 2001 From: nea Date: Fri, 21 Jul 2023 17:18:15 +0200 Subject: Fix hidden messages not triggering kick --- README.md | 2 +- .../github/romangraef/skyblockplayersanonymous/SPA.java | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ea770e6..dcb8fc9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # SkyBlock Player Anonymous -A mod for the recovering SkyBlock addict. +A relief for the recovering SkyBlock addict. diff --git a/src/main/java/com/github/romangraef/skyblockplayersanonymous/SPA.java b/src/main/java/com/github/romangraef/skyblockplayersanonymous/SPA.java index a90af25..99246b7 100644 --- a/src/main/java/com/github/romangraef/skyblockplayersanonymous/SPA.java +++ b/src/main/java/com/github/romangraef/skyblockplayersanonymous/SPA.java @@ -9,6 +9,7 @@ import net.minecraft.util.Vec3; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -24,6 +25,8 @@ public class SPA { return heldItem != null && heldItem.getDisplayName().equals("§bSkyBlock"); } + boolean kickQueued = false; + public static void warnPlayer() { Minecraft.getMinecraft().ingameGUI.getChatGUI() .printChatMessage(new ChatComponentText("§c§l§kaaa§c§l WARNING!!!! YOU TRIED TO JOIN SKYBLOCK!!!! §c§l§kaaa")); @@ -34,18 +37,22 @@ public class SPA { EVENT_BUS.register(this); } - @SubscribeEvent + @SubscribeEvent(receiveCanceled = true, priority = EventPriority.HIGHEST) public void onChat(ClientChatReceivedEvent event) { if (event.message.getUnformattedText().replaceAll("§.", "").equals("Welcome to Hypixel SkyBlock!")) { - System.out.println("trying to kick you"); - Minecraft.getMinecraft().addScheduledTask(() -> Minecraft.getMinecraft().getNetHandler().getNetworkManager().closeChannel(new ChatComponentText( - "§cYou joined SkyBlock. All hope is lost." - ))); + kickQueued = true; } } @SubscribeEvent public void onTick(TickEvent.ClientTickEvent tick) { + if (kickQueued) { + Minecraft.getMinecraft().getNetHandler().getNetworkManager().closeChannel(new ChatComponentText( + "§cYou joined SkyBlock. All hope is lost." + )); + kickQueued = false; + return; + } if (tick.phase == TickEvent.Phase.END && Minecraft.getMinecraft().thePlayer != null) { if (new Vec3(-175, 125, 118).squareDistanceTo(Minecraft.getMinecraft().thePlayer.getPositionVector()) < 100) { Minecraft.getMinecraft().ingameGUI.getChatGUI() -- cgit