use of cc.hyperium.event.network.server.hypixel.JoinHypixelEvent in project Hyperium by HyperiumClient.
the class HypixelDetector method serverJoinEvent.
@InvokeEvent
public void serverJoinEvent(ServerJoinEvent event) {
hypixel = HYPIXEL_PATTERN.matcher(event.getServer()).find();
Multithreading.runAsync(() -> {
// Wait a while until the player isn't null, signifying the joining process is complete
int tries = 0;
while (Minecraft.getMinecraft().thePlayer == null) {
tries++;
if (tries > 20 * 10) {
return;
}
try {
Thread.sleep(50L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (hypixel) {
// If player is online recognized Hypixel IP
EventBus.INSTANCE.post(new JoinHypixelEvent(ServerVerificationMethod.IP));
} else {
// Double check the player isn't online Hypixel
if (Minecraft.getMinecraft().getCurrentServerData() != null) {
ServerData serverData = Minecraft.getMinecraft().getCurrentServerData();
if (serverData != null && serverData.serverMOTD != null && serverData.serverMOTD.toLowerCase().contains("hypixel network")) {
// Check MOTD for Hypixel
hypixel = true;
EventBus.INSTANCE.post(new JoinHypixelEvent(ServerVerificationMethod.MOTD));
}
}
}
});
}
Aggregations