From d7bd502812504373a3d4e181fa4635145d1c10be Mon Sep 17 00:00:00 2001 From: hackthetime Date: Thu, 14 Dec 2023 12:57:03 +0100 Subject: a lot of prob not full working things --- .../java/de/hype/bbsentials/fabric/BBUtils.java | 3 +- .../java/de/hype/bbsentials/fabric/Commands.java | 9 ++ .../de/hype/bbsentials/fabric/DebugThread.java | 50 +++++++++ .../java/de/hype/bbsentials/fabric/MCUtils.java | 116 ++++++++++++++++++++- 4 files changed, 173 insertions(+), 5 deletions(-) (limited to 'fabric') diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/BBUtils.java b/fabric/src/main/java/de/hype/bbsentials/fabric/BBUtils.java index 5dca4ac..a47419d 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/BBUtils.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/BBUtils.java @@ -2,6 +2,7 @@ package de.hype.bbsentials.fabric; import com.google.common.collect.Lists; import de.hype.bbsentials.common.chat.Chat; +import de.hype.bbsentials.common.constants.enviromentShared.EnumUtils; import de.hype.bbsentials.common.constants.enviromentShared.Islands; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.PlayerListEntry; @@ -17,7 +18,7 @@ public class BBUtils implements de.hype.bbsentials.common.mclibraries.BBUtils { Chat.sendPrivateMessageToSelfError("Could not get Area data. Are you in Skyblock?"); } else { - return Islands.getByDisplayName(string.replace("Area: ", "").trim()); + return EnumUtils.getEnumByName(Islands.class, string.replace("Area: ", "").trim()); } } catch (Exception e) { } diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java b/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java index e23d76b..f3a6d80 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java @@ -246,6 +246,15 @@ public class Commands implements MCCommand { }) ); });/*requestpottimes*/ + event.register((dispatcher, registryAccess) -> { + dispatcher.register( + ClientCommandManager.literal("getLeecher") + .executes((context) -> { + Chat.sendPrivateMessageToSelfInfo("Leeching Players: " + String.join(", ", EnvironmentCore.mcUtils.getSplashLeechingPlayers())); + return 1; + }) + ); + });/*getLeecher*/ } if (hasAdmin) { event.register((dispatcher, registryAccess) -> { diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java b/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java index e792ff9..92274a3 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java @@ -1,10 +1,16 @@ package de.hype.bbsentials.fabric; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.entity.player.PlayerEntity; + +import java.util.ArrayList; import java.util.List; public class DebugThread implements de.hype.bbsentials.common.client.DebugThread { boolean doTest = false; + public static List store = new ArrayList<>(); @Override public void loop() { if (doTest) { @@ -25,4 +31,48 @@ public class DebugThread implements de.hype.bbsentials.common.client.DebugThread public List test() { return List.of(""); } + + public List getAllPlayers() { + List players = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerEntity player : MinecraftClient.getInstance().player.getEntityWorld().getPlayers()) { + if (!player.getDisplayName().getString().startsWith("!")) { + players.add(player); + } + } + + return players; + } + + public List getPlayersInRadius(ClientPlayerEntity referencePlayer, List players, double radius) { + List nearbyPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerEntity player : players) { + if (player != referencePlayer && player.squaredDistanceTo(referencePlayer) <= radius * radius) { + nearbyPlayers.add(player); + } + } + + return nearbyPlayers; + } + + public List getNonBingoPlayers(List players) { + List nonBingoPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerEntity player : players) { + if (player.getCustomName().getString().contains("Ⓑ")) { + nonBingoPlayers.add(player); + } + } + return nonBingoPlayers; + } + + public List getSplashLeechingPlayers() { + List players = getAllPlayers(); + players.remove(MinecraftClient.getInstance().player); + return getPlayersInRadius(MinecraftClient.getInstance().player, getNonBingoPlayers(players), 5).stream().map((playerEntity -> playerEntity.getDisplayName().getString())).toList(); + } } diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java b/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java index 26d2872..b87a54c 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java @@ -4,13 +4,18 @@ import com.mojang.authlib.exceptions.AuthenticationException; import de.hype.bbsentials.common.chat.Chat; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import java.io.File; +import java.util.ArrayList; +import java.util.List; public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { public boolean isWindowFocused() { @@ -57,14 +62,117 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { } catch (AuthenticationException e) { try { Thread.sleep(1000); - }catch (Exception ignored){ + } catch (Exception ignored) { } - if (tries==0){ - Chat.sendPrivateMessageToSelfError("Could not authenticate at mojang: "+e.getMessage()); + if (tries == 0) { + Chat.sendPrivateMessageToSelfError("Could not authenticate at mojang: " + e.getMessage()); e.printStackTrace(); } } } return serverId; } -} + + public List getAllPlayers() { + List players = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerEntity player : MinecraftClient.getInstance().player.getEntityWorld().getPlayers()) { + if (!player.getDisplayName().getString().startsWith("!")) { + players.add(player); + } + } + + return players; + } + + public List getPlayersInRadius(ClientPlayerEntity referencePlayer, List players, double radius) { + List nearbyPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerEntity player : players) { + if (player != referencePlayer && player.squaredDistanceTo(referencePlayer) <= radius * radius) { + nearbyPlayers.add(player); + } + } + + return nearbyPlayers; + } + + public List getBingoPlayers() { + List bingoPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerListEntry entry : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + try { + if (entry.getProfile().getName().startsWith("!")) { + String customName = entry.getDisplayName().getString(); + if (customName.contains("Ⓑ")) { + bingoPlayers.add(customName.trim().split(" ")[1]); + } + } + } catch (Exception ignored) { + } + + } + return bingoPlayers; + } + + public List getIronmanPlayers() { + List ironmanPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerListEntry entry : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + try { + if (entry.getProfile().getName().startsWith("!")) { + String customName = entry.getDisplayName().getString(); + if (customName.contains("♻")) { + ironmanPlayers.add(customName.trim().split(" ")[1]); + } + } + } catch (Exception ignored) { + } + + } + return ironmanPlayers; + } + + public List onlyFromList(List players, List usernames) { + ArrayList filtered = new ArrayList<>(); + for (PlayerEntity player : players) { + String playerUsername = player.getGameProfile().getName(); + for (int i = 0; i < usernames.size(); i++) { + if (playerUsername.equals(usernames.get(i))) { + usernames.remove(i); + filtered.add(player); + } + } + } + return filtered; + } + + public List filterOut(List players, List usernames) { + ArrayList filtered = new ArrayList<>(); + for (PlayerEntity player : players) { + String playerUsername = player.getGameProfile().getName(); + boolean toAdd = true; + for (int i = 0; i < usernames.size(); i++) { + if (playerUsername.equals(usernames.get(i))) { + toAdd = false; + usernames.remove(i); + break; + } + } + if (toAdd) { + filtered.add(player); + } + } + return filtered; + } + + public List getSplashLeechingPlayers() { + List players = getAllPlayers(); + players.remove(MinecraftClient.getInstance().player); + return getPlayersInRadius(MinecraftClient.getInstance().player, filterOut(getAllPlayers(), getBingoPlayers()), 5).stream().map((playerEntity -> playerEntity.getDisplayName().getString())).toList(); + } +} \ No newline at end of file -- cgit