package net.saltymc.eaa.function; import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; import net.minecraft.client.MinecraftClient; import net.minecraft.client.toast.SystemToast; import net.minecraft.text.Text; import net.saltymc.eaa.util.database.DB_Tag; import java.util.ArrayList; import java.util.List; public class LobbyFunction { public static void checkLobby(FabricClientCommandSource source){ new Thread(new CheckLobby(source)).start(); } private static class CheckLobby implements Runnable { FabricClientCommandSource source; public CheckLobby(FabricClientCommandSource source) { this.source = source; } @Override public void run() { try { List uuids = new ArrayList<>(); MinecraftClient.getInstance().getNetworkHandler().getPlayerList().forEach(x -> uuids.add(x.getProfile().getId().toString())); int dangerLvl = 0; // 0 = nothing; 1 = idiot; 2 = hacker for (String uuid: uuids){ TagFunction.loadPlayer(uuid, false); if (TagFunction.getHashMap().containsKey(uuid)){ DB_Tag.Type type = TagFunction.getHashMap().get(uuid).getType(); if (type == DB_Tag.Type.HACKER){ dangerLvl = 2; break; } else if (type == DB_Tag.Type.IDIOT || type == DB_Tag.Type.NOOB){ dangerLvl = 1; } } } switch (dangerLvl){ case 0: SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.WORLD_BACKUP, Text.of("OKAY!"), Text.of("No Hackers found")); break; case 1: SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.of("MEH!"), Text.of("There is an Idiot or Noob!")); break; case 2: SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.WORLD_ACCESS_FAILURE, Text.of("ALARM!"), Text.of("There is a Hacker!")); } } catch (Exception e) { source.sendFeedback(Text.of(e.toString())); } } } }