aboutsummaryrefslogtreecommitdiff
path: root/fabric/src
diff options
context:
space:
mode:
Diffstat (limited to 'fabric/src')
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java9
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java50
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java116
3 files changed, 171 insertions, 4 deletions
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<Object> 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<String> test() {
return List.of("");
}
+
+ public List<PlayerEntity> getAllPlayers() {
+ List<PlayerEntity> 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<PlayerEntity> getPlayersInRadius(ClientPlayerEntity referencePlayer, List<PlayerEntity> players, double radius) {
+ List<PlayerEntity> 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<PlayerEntity> getNonBingoPlayers(List<PlayerEntity> players) {
+ List<PlayerEntity> 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<String> getSplashLeechingPlayers() {
+ List<PlayerEntity> 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<PlayerEntity> getAllPlayers() {
+ List<PlayerEntity> 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<PlayerEntity> getPlayersInRadius(ClientPlayerEntity referencePlayer, List<PlayerEntity> players, double radius) {
+ List<PlayerEntity> 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<String> getBingoPlayers() {
+ List<String> 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<String> getIronmanPlayers() {
+ List<String> 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<PlayerEntity> onlyFromList(List<PlayerEntity> players, List<String> usernames) {
+ ArrayList<PlayerEntity> 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<PlayerEntity> filterOut(List<PlayerEntity> players, List<String> usernames) {
+ ArrayList<PlayerEntity> 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<String> getSplashLeechingPlayers() {
+ List<PlayerEntity> 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