aboutsummaryrefslogtreecommitdiff
path: root/fabric
diff options
context:
space:
mode:
authorhackthetime <l4bg0jb7@duck.com>2023-12-14 12:57:03 +0100
committerhackthetime <l4bg0jb7@duck.com>2023-12-14 12:57:03 +0100
commitd7bd502812504373a3d4e181fa4635145d1c10be (patch)
treed6a47a833e0739c0ae32b9a4a53284b2579f2d63 /fabric
parent1f90b12d47118f2a1132f12c39a2977e8c02fa77 (diff)
downloadBBsentials-d7bd502812504373a3d4e181fa4635145d1c10be.tar.gz
BBsentials-d7bd502812504373a3d4e181fa4635145d1c10be.tar.bz2
BBsentials-d7bd502812504373a3d4e181fa4635145d1c10be.zip
a lot of prob not full working things
Diffstat (limited to 'fabric')
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/BBUtils.java3
-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
4 files changed, 173 insertions, 5 deletions
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<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