aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-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()