aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-07-21 17:18:15 +0200
committernea <nea@nea.moe>2023-07-21 17:18:15 +0200
commit09679ad7e0e94b984e6a8a3f26ec97e05a987df0 (patch)
treef32fe290d1d1e794b9cef6475cfa3aec245551c6 /src
parent7744e5310aa3d601279d8f416c20b7bef65865a5 (diff)
downloadSkyblockPlayersAnonymous-09679ad7e0e94b984e6a8a3f26ec97e05a987df0.tar.gz
SkyblockPlayersAnonymous-09679ad7e0e94b984e6a8a3f26ec97e05a987df0.tar.bz2
SkyblockPlayersAnonymous-09679ad7e0e94b984e6a8a3f26ec97e05a987df0.zip
Fix hidden messages not triggering kick
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/github/romangraef/skyblockplayersanonymous/SPA.java17
1 files changed, 12 insertions, 5 deletions
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()