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 --- .../common/client/SplashStatusUpdateListener.java | 3 +- .../constants/enviromentShared/EnumUtils.java | 1 - .../common/constants/enviromentShared/Islands.java | 30 +++--- .../constants/enviromentShared/MiningEvents.java | 16 +-- .../enviromentShared/StatusConstants.java | 43 ++++++++ .../bbsentials/common/mclibraries/MCUtils.java | 3 + .../bbsentials/common/packets/PacketManager.java | 2 + .../packets/packets/ChChestsUpdatePacket.java | 31 ++++++ .../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 ++++++++++++++++++++- .../java/de/hype/bbsentials/forge/BBUtils.java | 3 +- .../java/de/hype/bbsentials/forge/MCUtils.java | 113 +++++++++++++++++++- .../hype/bbsentials/forge/client/MoulConfig.java | 30 ++---- .../bbsentials/forge/client/MoulConfigManager.java | 22 ++++ 16 files changed, 423 insertions(+), 52 deletions(-) create mode 100644 common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/StatusConstants.java create mode 100644 common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestsUpdatePacket.java create mode 100644 forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfigManager.java diff --git a/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java b/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java index 5ea2384..b89cfc1 100644 --- a/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java +++ b/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java @@ -4,6 +4,7 @@ import de.hype.bbsentials.common.communication.BBsentialConnection; import de.hype.bbsentials.common.mclibraries.EnvironmentCore; import de.hype.bbsentials.common.packets.packets.SplashNotifyPacket; import de.hype.bbsentials.common.packets.packets.SplashUpdatePacket; +import sun.java2d.pipe.TextRenderer; import java.util.concurrent.TimeUnit; @@ -24,6 +25,7 @@ public class SplashStatusUpdateListener implements Runnable { public void run() { BBsentials.splashLobby = true; int maxPlayerCount = EnvironmentCore.utils.getMaximumPlayerCount() - 5; + while (BBsentials.splashLobby) { if (!full&&(EnvironmentCore.utils.getPlayerCount() >= maxPlayerCount)) { newStatus = SplashUpdatePacket.STATUS_FULL; @@ -49,7 +51,6 @@ public class SplashStatusUpdateListener implements Runnable { connection.sendPacket(new SplashUpdatePacket(packet.splashId, status)); } } - public void setStatus(String newStatus) { this.newStatus = newStatus; if (newStatus.equals(SplashUpdatePacket.STATUS_SPLASHING)) { diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/EnumUtils.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/EnumUtils.java index df0ff63..2269339 100644 --- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/EnumUtils.java +++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/EnumUtils.java @@ -1,7 +1,6 @@ package de.hype.bbsentials.common.constants.enviromentShared; import de.hype.bbsentials.common.constants.BBDisplayNameProvider; - import java.util.ArrayList; import java.util.Collection; import java.util.List; diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/Islands.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/Islands.java index d88d79b..dff2a97 100644 --- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/Islands.java +++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/Islands.java @@ -4,21 +4,21 @@ import de.hype.bbsentials.common.constants.BBDisplayNameProvider; /** * List of all Islands - *
  • {@link #CRYSTAL_HOLLOWS} - *
  • {@link #CRIMSON_ISLE} - *
  • {@link #DEEP_CAVERNS} - *
  • {@link #DUNGEON} - *
  • {@link #DUNGEON_HUB} - *
  • {@link #DWARVEN_MINES} - *
  • {@link #GOLD_MINE} - *
  • {@link #HUB} - *
  • {@link #KUUDRA} - *
  • {@link #PRIVATE_ISLAND} - *
  • {@link #SPIDERS_DEN} - *
  • {@link #THE_END} - *
  • {@link #THE_FARMING_ISLANDS} - *
  • {@link #JERRYS_WORKSHOP} - *
  • {@link #THE_RIFT} + * {@link #CRYSTAL_HOLLOWS} + * {@link #CRIMSON_ISLE} + * {@link #DEEP_CAVERNS} + * {@link #DUNGEON} + * {@link #DUNGEON_HUB} + * {@link #DWARVEN_MINES} + * {@link #GOLD_MINE} + * {@link #HUB} + * {@link #KUUDRA} + * {@link #PRIVATE_ISLAND} + * {@link #SPIDERS_DEN} + * {@link #THE_END} + * {@link #THE_FARMING_ISLANDS} + * {@link #JERRYS_WORKSHOP} + * {@link #THE_RIFT} */ public enum Islands implements BBDisplayNameProvider { CRYSTAL_HOLLOWS("crystal_hollows", "Crystal Hollows"), diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/MiningEvents.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/MiningEvents.java index e364aab..6336fee 100644 --- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/MiningEvents.java +++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/MiningEvents.java @@ -1,17 +1,17 @@ package de.hype.bbsentials.common.constants.enviromentShared; -// Mining Events - import de.hype.bbsentials.common.constants.BBDisplayNameProvider; +// Mining Events + /** * A List of all Mining Events - *
  • {@link #BETTER_TOGETHER} - *
  • {@link #DOUBLE_POWDER} - *
  • {@link #GONE_WITH_THE_WIND} - *
  • {@link #GOBLIN_RAID} - *
  • {@link #MITHRIL_GOURMAND} - *
  • {@link #RAFFLE} + * {@link #BETTER_TOGETHER} + * {@link #DOUBLE_POWDER} + * {@link #GONE_WITH_THE_WIND} + * {@link #GOBLIN_RAID} + * {@link #MITHRIL_GOURMAND} + * {@link #RAFFLE} */ public enum MiningEvents implements BBDisplayNameProvider { BETTER_TOGETHER("Better Together"), diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/StatusConstants.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/StatusConstants.java new file mode 100644 index 0000000..288622d --- /dev/null +++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/StatusConstants.java @@ -0,0 +1,43 @@ +package de.hype.bbsentials.common.constants.enviromentShared; + +import de.hype.bbsentials.common.constants.BBDisplayNameProvider; + +import java.awt.*; + +public enum StatusConstants implements BBDisplayNameProvider { + DONEGOOD("Done", Color.GREEN), + DONEBAD("Done", Color.ORANGE), + WAITING("Waiting", Color.GREEN), + FULL("Full", Color.YELLOW), + ONGOING("Ongoing", Color.YELLOW), + OPEN("Open", Color.GREEN), + SPLASHING("Splashing", Color.YELLOW), + CLOSING("Closing", Color.ORANGE), + CLOSINGSOON("Closing Soon", Color.ORANGE), + LEAVINGSOON("Leaving Soon", Color.ORANGE), + CANCELED("Canceled", Color.RED), + CLOSED("Closed", Color.RED), + LEFT("Left", Color.ORANGE), + ; + String displayName; + Color color; + + StatusConstants(String displayName, Color color) { + this.displayName = displayName; + this.color = color; + } + + public String getDisplayName() { + return displayName; + } + + public Color getColor() { + return color; + } + + @Deprecated + @Override + public String toString() { + return displayName; + } +} diff --git a/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java b/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java index c007d31..dbd407f 100644 --- a/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java +++ b/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java @@ -1,6 +1,7 @@ package de.hype.bbsentials.common.mclibraries; import java.io.File; +import java.util.List; public interface MCUtils { boolean isWindowFocused(); @@ -15,4 +16,6 @@ public interface MCUtils { int getPotTime(); String mojangAuth(String serverId); + + List getSplashLeechingPlayers(); } diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/PacketManager.java b/common/src/main/java/de/hype/bbsentials/common/packets/PacketManager.java index 2cc672d..2a10960 100644 --- a/common/src/main/java/de/hype/bbsentials/common/packets/PacketManager.java +++ b/common/src/main/java/de/hype/bbsentials/common/packets/PacketManager.java @@ -1,5 +1,6 @@ package de.hype.bbsentials.common.packets; +import de.hype.bbsentials.common.client.SplashManager; import de.hype.bbsentials.common.communication.BBsentialConnection; import de.hype.bbsentials.common.packets.packets.*; @@ -40,6 +41,7 @@ public class PacketManager { packets.add(new Packet<>(SystemMessagePacket.class, connection::onSystemMessagePacket)); packets.add(new Packet<>(WelcomeClientPacket.class, connection::onWelcomePacket)); packets.add(new Packet<>(RequestAuthentication.class, connection::onRequestAuthentication)); + packets.add(new Packet<>(SplashUpdatePacket.class, SplashManager::updateSplash)); } // Method to handle a received packet diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestsUpdatePacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestsUpdatePacket.java new file mode 100644 index 0000000..2e015ac --- /dev/null +++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestsUpdatePacket.java @@ -0,0 +1,31 @@ +package de.hype.bbsentials.common.packets.packets; + +import de.hype.bbsentials.common.constants.enviromentShared.StatusConstants; +import de.hype.bbsentials.common.packets.AbstractPacket; + +import java.util.Date; +import java.util.List; + +/** + * Client and Server. Updates ChChests Status. + */ +public class ChChestsUpdatePacket extends AbstractPacket { + public final int lobbyId; + public final StatusConstants status; + public final List playersStillIn; + public final Date closingTime; + + /** + * @param lobbyId id of the lobby + * @param status one of the following types: {@link StatusConstants#OPEN}, {@link StatusConstants#FULL}, {@link StatusConstants#LEAVINGSOON}, {@link StatusConstants#LEFT}, {@link StatusConstants#CLOSED} + * @param playersStillIn Players that were still in when leaving the lobby. + * @param closingTime assumed closingTime. + */ + public ChChestsUpdatePacket(int lobbyId, StatusConstants status, List playersStillIn, Date closingTime) { + super(1, 1); //Min and Max supported Version + this.lobbyId = lobbyId; + this.status = status; + this.playersStillIn = playersStillIn; + this.closingTime = closingTime; + } +} 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 diff --git a/forge/src/main/java/de/hype/bbsentials/forge/BBUtils.java b/forge/src/main/java/de/hype/bbsentials/forge/BBUtils.java index e50ef3b..97845c6 100644 --- a/forge/src/main/java/de/hype/bbsentials/forge/BBUtils.java +++ b/forge/src/main/java/de/hype/bbsentials/forge/BBUtils.java @@ -3,6 +3,7 @@ package de.hype.bbsentials.forge; import com.google.common.collect.Lists; import com.mojang.realmsclient.dto.PlayerInfo; 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.Minecraft; import net.minecraft.client.network.NetworkPlayerInfo; @@ -19,7 +20,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/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java b/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java index 251b20b..8bb02f0 100644 --- a/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java +++ b/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java @@ -3,14 +3,18 @@ package de.hype.bbsentials.forge; import com.mojang.authlib.exceptions.AuthenticationException; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.Display; import java.io.File; -import java.math.BigInteger; -import java.util.Random; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { public boolean isWindowFocused() { @@ -58,4 +62,109 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { return serverId; } + public List getAllPlayers() { + List players = new ArrayList<>(); + + // Iterate through all players on the server + for (EntityPlayer player : Minecraft.getMinecraft().thePlayer.getEntityWorld().playerEntities) { + if (!player.getDisplayNameString().startsWith("!")) { + players.add(player); + } + } + + return players; + } + + public List getPlayersInRadius(EntityPlayer referencePlayer, List players, double radius) { + List nearbyPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the reference player + for (EntityPlayer player : players) { + if (player != referencePlayer && player.getDistanceSq(referencePlayer.posX, referencePlayer.posY, referencePlayer.posZ) <= 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 (Iterator it = Minecraft.getMinecraft().getNetHandler().getPlayerInfoMap().stream().iterator(); it.hasNext(); ) { + NetworkPlayerInfo entry = it.next(); + try { + if (entry.getGameProfile().getName().startsWith("!")) { + String customName = entry.getDisplayName().getUnformattedText(); + 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 (Iterator it = Minecraft.getMinecraft().getNetHandler().getPlayerInfoMap().stream().iterator(); it.hasNext(); ) { + NetworkPlayerInfo entry = it.next(); + try { + if (entry.getGameProfile().getName().startsWith("!")) { + String customName = entry.getDisplayName().getUnformattedText(); + 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 (EntityPlayer 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 (EntityPlayer 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(Minecraft.getMinecraft().thePlayer); + return getPlayersInRadius(Minecraft.getMinecraft().thePlayer, filterOut(getAllPlayers(), getBingoPlayers()), 5).stream().map((playerEntity -> playerEntity.getDisplayName().getFormattedText())).collect(Collectors.toList()); + } } diff --git a/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfig.java b/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfig.java index 4d50a4e..e0598ff 100644 --- a/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfig.java +++ b/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfig.java @@ -4,43 +4,35 @@ import com.google.gson.annotations.Expose; import de.hype.bbsentials.forge.client.categories.FirstCategory; import io.github.moulberry.moulconfig.Config; import io.github.moulberry.moulconfig.annotations.Category; -import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; -import io.github.moulberry.moulconfig.annotations.ConfigOption; -import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper; -import io.github.moulberry.moulconfig.gui.MoulConfigEditor; -import io.github.moulberry.moulconfig.processor.BuiltinMoulConfigGuis; -import io.github.moulberry.moulconfig.processor.ConfigProcessorDriver; -import io.github.moulberry.moulconfig.processor.MoulConfigProcessor; import net.minecraft.client.Minecraft; -import net.minecraftforge.common.config.ConfigCategory; +import net.minecraft.util.ChatComponentText; import static de.hype.bbsentials.common.client.BBsentials.config; public class MoulConfig extends Config { - MoulConfigEditor editor; - MoulConfigProcessor processor; @Expose @Category(name = "First Category", desc = "This is the first category.") public FirstCategory firstCategory = new FirstCategory(); - public MoulConfig() { - processor = new MoulConfigProcessor<>(this); - editor = new MoulConfigEditor<>(processor); - BuiltinMoulConfigGuis.addProcessors(processor); - ConfigProcessorDriver.processConfig(MoulConfig.class, this, processor); - } - @Override public String getTitle() { return "BBsentials " + de.hype.bbsentials.common.client.Config.apiVersion; } + @Override public void saveNow() { config.save(); } - public void openConfigGui() { - Minecraft.getMinecraft().displayGuiScreen(new GuiScreenElementWrapper(editor)); + @Override + public void executeRunnable(int runnableId) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Just executed runnableId " + runnableId)); + } + + @Override + public boolean shouldAutoFocusSearchbar() { + return true; } + } diff --git a/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfigManager.java b/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfigManager.java new file mode 100644 index 0000000..07491cd --- /dev/null +++ b/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfigManager.java @@ -0,0 +1,22 @@ +package de.hype.bbsentials.forge.client; + +import io.github.moulberry.moulconfig.gui.MoulGuiOverlayEditor; +import io.github.moulberry.moulconfig.processor.BuiltinMoulConfigGuis; +import io.github.moulberry.moulconfig.processor.ConfigProcessorDriver; +import io.github.moulberry.moulconfig.processor.MoulConfigProcessor; +import net.minecraft.client.Minecraft; + +public class MoulConfigManager { + static MoulConfig moulConfig = new MoulConfig(); + MoulConfigProcessor testConfigMoulConfigProcessor; + + public MoulConfigManager() { + testConfigMoulConfigProcessor = new MoulConfigProcessor<>(moulConfig); + BuiltinMoulConfigGuis.addProcessors(testConfigMoulConfigProcessor); + ConfigProcessorDriver.processConfig(moulConfig.getClass(), moulConfig, testConfigMoulConfigProcessor); + } + + public void openConfigGui() { + Minecraft.getMinecraft().displayGuiScreen(new MoulGuiOverlayEditor(testConfigMoulConfigProcessor)); + } +} -- cgit From 38dc93f626c9a858835eef59488ef2b9ee441bc9 Mon Sep 17 00:00:00 2001 From: HacktheTime Date: Thu, 14 Dec 2023 16:21:26 +0100 Subject: reformatting and bug fixes --- .../common/client/SplashStatusUpdateListener.java | 26 +++---- .../java/de/hype/bbsentials/fabric/Commands.java | 65 ++++++++++-------- .../java/de/hype/bbsentials/fabric/MCUtils.java | 79 ++++------------------ .../de/hype/bbsentials/fabric/ModInitialiser.java | 4 +- 4 files changed, 64 insertions(+), 110 deletions(-) diff --git a/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java b/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java index b89cfc1..8898e20 100644 --- a/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java +++ b/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java @@ -4,17 +4,16 @@ import de.hype.bbsentials.common.communication.BBsentialConnection; import de.hype.bbsentials.common.mclibraries.EnvironmentCore; import de.hype.bbsentials.common.packets.packets.SplashNotifyPacket; import de.hype.bbsentials.common.packets.packets.SplashUpdatePacket; -import sun.java2d.pipe.TextRenderer; import java.util.concurrent.TimeUnit; public class SplashStatusUpdateListener implements Runnable { - BBsentialConnection connection; - SplashNotifyPacket packet; - private String status = SplashUpdatePacket.STATUS_WAITING; public String newStatus = SplashUpdatePacket.STATUS_WAITING; public boolean splashed = false; public boolean full = false; + BBsentialConnection connection; + SplashNotifyPacket packet; + private String status = SplashUpdatePacket.STATUS_WAITING; public SplashStatusUpdateListener(BBsentialConnection connection, SplashNotifyPacket packet) { this.connection = connection; @@ -27,14 +26,14 @@ public class SplashStatusUpdateListener implements Runnable { int maxPlayerCount = EnvironmentCore.utils.getMaximumPlayerCount() - 5; while (BBsentials.splashLobby) { - if (!full&&(EnvironmentCore.utils.getPlayerCount() >= maxPlayerCount)) { - newStatus = SplashUpdatePacket.STATUS_FULL; - full=true; - } - if (!status.equals(newStatus)) { - status = newStatus; - connection.sendPacket(new SplashUpdatePacket(packet.splashId, status)); - } + if (!full && (EnvironmentCore.utils.getPlayerCount() >= maxPlayerCount)) { + newStatus = SplashUpdatePacket.STATUS_FULL; + full = true; + } + if (!status.equals(newStatus)) { + status = newStatus; + connection.sendPacket(new SplashUpdatePacket(packet.splashId, status)); + } try { Thread.sleep(250); } catch (InterruptedException ignored) { @@ -51,10 +50,11 @@ public class SplashStatusUpdateListener implements Runnable { connection.sendPacket(new SplashUpdatePacket(packet.splashId, status)); } } + public void setStatus(String newStatus) { this.newStatus = newStatus; if (newStatus.equals(SplashUpdatePacket.STATUS_SPLASHING)) { - splashed=true; + splashed = true; BBsentials.executionService.schedule(() -> { setStatus(SplashUpdatePacket.STATUS_DONE); BBsentials.splashLobby = false; 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 f3a6d80..3d7f76a 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java @@ -23,7 +23,37 @@ import java.util.Objects; public class Commands implements MCCommand { Event event = ClientCommandRegistrationCallback.EVENT; - public void registerMain(){ + + private static void simpleCommand(CommandDispatcher dispatcher, String commandName, String[] parameters) { + dispatcher.register( + ClientCommandManager.literal(commandName) + .executes((context) -> { + sendPacket(new InternalCommandPacket(commandName, parameters)); + return 1; + }) + ); + } + + private static void miningEvent(CommandDispatcher dispatcher, String commandName, MiningEvents event) { + dispatcher.register( + ClientCommandManager.literal(commandName) + .executes((context) -> { + try { + sendPacket(new MiningEventPacket(event, + BBsentials.config.getUsername(), Objects.requireNonNull(EnvironmentCore.utils.getCurrentIsland()))); + } catch (Exception e) { + Chat.sendPrivateMessageToSelfError(e.getMessage()); + } + return 1; + }) + ); + } + + public static void sendPacket(T packet) { + BBsentials.connection.sendPacket(packet); + } + + public void registerMain() { event.register((dispatcher, registryAccess) -> { dispatcher.register(ClientCommandManager.literal("creport") .then(ClientCommandManager.argument("Player_Name", StringArgumentType.string()) @@ -128,7 +158,7 @@ public class Commands implements MCCommand { .then(ClientCommandManager.argument("message", StringArgumentType.greedyString()) .executes((context) -> { String message = StringArgumentType.getString(context, "message"); - sendPacket(new BroadcastMessagePacket("","",message)); + sendPacket(new BroadcastMessagePacket("", "", message)); return 1; }) ) @@ -250,7 +280,9 @@ public class Commands implements MCCommand { dispatcher.register( ClientCommandManager.literal("getLeecher") .executes((context) -> { - Chat.sendPrivateMessageToSelfInfo("Leeching Players: " + String.join(", ", EnvironmentCore.mcUtils.getSplashLeechingPlayers())); + BBsentials.executionService.execute(() -> { + Chat.sendPrivateMessageToSelfInfo("Leeching Players: " + String.join(", ", EnvironmentCore.mcUtils.getSplashLeechingPlayers())); + }); return 1; }) ); @@ -290,33 +322,6 @@ public class Commands implements MCCommand { } } - private static void simpleCommand(CommandDispatcher dispatcher, String commandName, String[] parameters) { - dispatcher.register( - ClientCommandManager.literal(commandName) - .executes((context) -> { - sendPacket(new InternalCommandPacket(commandName, parameters)); - return 1; - }) - ); - } - - private static void miningEvent(CommandDispatcher dispatcher, String commandName, MiningEvents event) { - dispatcher.register( - ClientCommandManager.literal(commandName) - .executes((context) -> { - try { - sendPacket(new MiningEventPacket(event, - BBsentials.config.getUsername(), Objects.requireNonNull(EnvironmentCore.utils.getCurrentIsland()))); - } catch (Exception e) { - Chat.sendPrivateMessageToSelfError(e.getMessage()); - } - return 1; - }) - ); - } - public static void sendPacket(T packet){ - BBsentials.connection.sendPacket(packet); - } public void splashAnnounce(int hubNumber, String locationInHub, String extramessage, boolean lessWaste) { sendPacket(new SplashNotifyPacket(0, hubNumber, BBsentials.config.getUsername(), locationInHub, EnvironmentCore.utils.getCurrentIsland(), extramessage, lessWaste)); } 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 b87a54c..346bdca 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java @@ -5,7 +5,6 @@ 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; @@ -16,6 +15,7 @@ import net.minecraft.util.Identifier; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.function.Predicate; public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { public boolean isWindowFocused() { @@ -99,80 +99,29 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { 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) { - } - + public static boolean isBingo(PlayerEntity player) { + try { + return player.getDisplayName().getString().contains("Ⓑ"); + } catch (Exception e) { + return false; } - 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) { - } - + public static boolean isIronman(PlayerEntity player) { + try { + return player.getDisplayName().getString().contains("♻"); + } catch (Exception e) { + return false; } - 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 filterOut(List players, Predicate predicate) { + return players.stream().filter(predicate).toList(); } 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(); + return getPlayersInRadius(MinecraftClient.getInstance().player, filterOut(getAllPlayers(), MCUtils::isBingo), 5).stream().map((playerEntity -> playerEntity.getDisplayName().getString())).toList(); } } \ No newline at end of file diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java b/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java index 3d3b42c..2bb6aeb 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java @@ -37,8 +37,8 @@ public class ModInitialiser implements ClientModInitializer { String tellrawjson = ""; if (parameters.length >= 3) { if (parameters[0].equals("sb")) { - tellrawjson = "[\"\",{\"text\":\"\n\n$username\",\"underlined\":true,\"color\":\"blue\",\"clickEvent\":{\"action\":\"copy_to_clipboard\",\"value\":\"$username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[{\"text\":\"Click to copy the username\",\"color\":\"blue\"}]}},\" \",{\"text\":\"[Party]\",\"color\":\"gold\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/p invite $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to party player\"]}},\" \",{\"text\":\"[Invite]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/invite\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to invite them to visit your private island/garden\"]}},\" \",{\"text\":\"[Visit]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/visit $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to open the visit menu for that user\"]}},\" \",{\"text\":\"[creport]\",\"color\":\"dark_red\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/creport $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to report the player for chat (public)\"]}},\" \",{\"text\":\"[Ignore add]\",\"color\":\"red\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/ignore add $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to ignore add the user\"]}},\" \",{\"text\":\"[Copy content]\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"copy_to_clipboard\",\"value\":\"$messagecontent\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to copy the message content\"]}},\" \",{\"text\":\"[Copy message]\",\"color\":\"blue\",\"clickEvent\":{\"action\":\"copy_to_clipboard\",\"value\":\"$message\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to copy the exact message\"]}},\" \",{\"text\":\"[Msg]\",\"color\":\"dark_purple\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/msg $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to msg the user\"]}},\" \",{\"text\":\"[Sky shiiyu]\",\"color\":\"aqua\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://sky.shiiyu.moe/stats/$username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to open the users sky shiiyu page.\"]}},\"\\n\"]"; - //{"jformat":8,"jobject":[{"bold":false,"italic":false,"underlined":true,"strikethrough":false,"obfuscated":false,"font":null,"color":"blue","insertion":"","click_event_type":"copy_to_clipboard","click_event_value":"$username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"blue","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to copy the username"}],"text":"$username"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"gold","insertion":"","click_event_type":"run_command","click_event_value":"/p invite $username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to party player"}],"text":"[Party]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"green","insertion":"","click_event_type":"run_command","click_event_value":"/invite","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to invite them to visit your private island/garden"}],"text":"[Invite]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"green","insertion":"","click_event_type":"run_command","click_event_value":"/visit $username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to open the visit menu for that user"}],"text":"[Visit]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"dark_red","insertion":"","click_event_type":"suggest_command","click_event_value":"/creport $username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to report the player for chat (public)"}],"text":"[creport]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"red","insertion":"","click_event_type":"suggest_command","click_event_value":"/ignore add $username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to ignore add the user"}],"text":"[Ignore add]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"gray","insertion":"","click_event_type":"copy_to_clipboard","click_event_value":"$messagecontent","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to copy the message content"}],"text":"[Copy content]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"blue","insertion":"","click_event_type":"copy_to_clipboard","click_event_value":"$message","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to copy the exact message"}],"text":"[Copy message]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"dark_purple","insertion":"","click_event_type":"suggest_command","click_event_value":"/msg $username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to msg the user"}],"text":"[Msg]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"aqua","insertion":"","click_event_type":"open_url","click_event_value":"https://sky.shiiyu.moe/stats/$username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to open the users sky shiiyu page."}],"text":"[Sky shiiyu]"}],"command":"%s","jtemplate":"tellraw"} + tellrawjson = "[\"\",{\"text\":\"\n\n$username\",\"underlined\":true,\"color\":\"blue\",\"clickEvent\":{\"action\":\"copy_to_clipboard\",\"value\":\"$username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[{\"text\":\"Click to copy the username\",\"color\":\"blue\"}]}},\" \",{\"text\":\"[Party]\",\"color\":\"gold\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/p invite $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to party player\"]}},\" \",{\"text\":\"[Invite]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/invite $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to invite them to visit your private island/garden\"]}},\" \",{\"text\":\"[Visit]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/visit $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to open the visit menu for that user\"]}},\" \",{\"text\":\"[creport]\",\"color\":\"dark_red\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/creport $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to report the player for chat (public)\"]}},\" \",{\"text\":\"[Ignore add]\",\"color\":\"red\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/ignore add $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to ignore add the user\"]}},\" \",{\"text\":\"[Copy content]\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"copy_to_clipboard\",\"value\":\"$messagecontent\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to copy the message content\"]}},\" \",{\"text\":\"[Copy message]\",\"color\":\"blue\",\"clickEvent\":{\"action\":\"copy_to_clipboard\",\"value\":\"$message\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to copy the exact message\"]}},\" \",{\"text\":\"[Msg]\",\"color\":\"dark_purple\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/msg $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to msg the user\"]}},\" \",{\"text\":\"[Sky shiiyu]\",\"color\":\"aqua\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://sky.shiiyu.moe/stats/$username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to open the users sky shiiyu page.\"]}},\"\\n\"]"; + //{"jformat":8,"jobject":[{"bold":false,"italic":false,"underlined":true,"strikethrough":false,"obfuscated":false,"font":null,"color":"blue","insertion":"","click_event_type":"copy_to_clipboard","click_event_value":"$username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"blue","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to copy the username"}],"text":"$username"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"gold","insertion":"","click_event_type":"run_command","click_event_value":"/p invite $username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to party player"}],"text":"[Party]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"green","insertion":"","click_event_type":"run_command","click_event_value":"/invite $username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to invite them to visit your private island/garden"}],"text":"[Invite]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"green","insertion":"","click_event_type":"run_command","click_event_value":"/visit $username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to open the visit menu for that user"}],"text":"[Visit]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"dark_red","insertion":"","click_event_type":"suggest_command","click_event_value":"/creport $username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to report the player for chat (public)"}],"text":"[creport]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"red","insertion":"","click_event_type":"suggest_command","click_event_value":"/ignore add $username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to ignore add the user"}],"text":"[Ignore add]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"gray","insertion":"","click_event_type":"copy_to_clipboard","click_event_value":"$messagecontent","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to copy the message content"}],"text":"[Copy content]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"blue","insertion":"","click_event_type":"copy_to_clipboard","click_event_value":"$message","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to copy the exact message"}],"text":"[Copy message]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"dark_purple","insertion":"","click_event_type":"suggest_command","click_event_value":"/msg $username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to msg the user"}],"text":"[Msg]"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":" "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"aqua","insertion":"","click_event_type":"open_url","click_event_value":"https://sky.shiiyu.moe/stats/$username","hover_event_type":"show_text","hover_event_value":"","hover_event_children":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"none","click_event_value":"","hover_event_type":"none","hover_event_value":"","hover_event_children":[],"text":"Click to open the users sky shiiyu page."}],"text":"[Sky shiiyu]"}],"command":"%s","jtemplate":"tellraw"} } else if (parameters[0].equals("guild")) { tellrawjson = "[\"\",{\"text\":\"\n\n$username\",\"underlined\":true,\"color\":\"blue\",\"clickEvent\":{\"action\":\"copy_to_clipboard\",\"value\":\"$username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[{\"text\":\"Click to copy the username\",\"color\":\"blue\"}]}},\" \",{\"text\":\"[Party]\",\"color\":\"gold\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/p invite $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to party player\"]}},\" \",{\"text\":\"[SB Options]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/socialoptions sb $username $message\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to open the SB options\"]}},\" \",{\"text\":\"[Member info]\",\"color\":\"dark_aqua\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/g member $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Show guild info about the user.\"]}},\" \",{\"text\":\"[Copy content]\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"copy_to_clipboard\",\"value\":\"$messagecontent\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to copy the message content\"]}},\" \",{\"text\":\"[Copy message]\",\"color\":\"blue\",\"clickEvent\":{\"action\":\"copy_to_clipboard\",\"value\":\"$message\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to copy the exact message\"]}},\" \",{\"text\":\"[Msg]\",\"color\":\"dark_purple\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/msg $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to msg the user\"]}},\" \",{\"text\":\"[Ignore add]\",\"color\":\"red\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/ignore add $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to ignore add the user\"]}},\"\\n\",{\"text\":\"G Admin: \",\"color\":\"dark_red\"},{\"text\":\"[kick]\",\"color\":\"dark_purple\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/g kick $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"suggest the command to kick the user\"]}},\" \",{\"text\":\"[mute]\",\"color\":\"red\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/g mute $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Suggest a mute command for the user.\"]}},\" \",{\"text\":\"[promote]\",\"color\":\"dark_green\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/g promote $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to promote the user\"]}},\" \",{\"text\":\"[demote]\",\"color\":\"red\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/g demote $username\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to demote the user\"]}}]"; -- cgit From f78c95168e0c055dadfbdc91db5e254f89c94650 Mon Sep 17 00:00:00 2001 From: hackthetime Date: Fri, 15 Dec 2023 13:16:54 +0100 Subject: small change otg with missing push from desktop --- .gitignore | 6 +++++- .../de/hype/bbsentials/common/packets/packets/ChChestPacket.java | 6 ++++-- fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 0201f9b..0624e31 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,8 @@ logs /run/config/ /run/saves/temp /run/saves/temp/* -/run/saves \ No newline at end of file +/run/saves +/runforge/.mixin.out/* +/run/servers.dat +/run/servers.dat_old +/runforge/config/splash.properties diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestPacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestPacket.java index 6aab4ce..fbba212 100644 --- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestPacket.java +++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestPacket.java @@ -5,14 +5,16 @@ import de.hype.bbsentials.common.constants.enviromentShared.ChChestItem; public class ChChestPacket extends AbstractPacket { /** + * @param lobbyId the id of the lobby * @param announcerUsername person who found the chest. * @param items items contained in the chest. {@link de.hype.bbsentials.common.constants.enviromentShared.ChChestItems (available constants)} * @param locationCoords coordinates of the chest. * @param bbcommand command that shall be executed in game to get an invitation to the party. * @param extraMessage a message that is optional to be provided by the announcer for custom additional info */ - public ChChestPacket(String announcerUsername, ChChestItem[] items, String locationCoords, String bbcommand, String extraMessage) { + public ChChestPacket(int lobbyId, String announcerUsername, ChChestItem[] items, String locationCoords, String bbcommand, String extraMessage) { super(1, 1); //Min and Max supported Version + this.lobbyId = lobbyId; this.announcerUsername = announcerUsername; this.locationCoords = locationCoords; this.bbcommand = bbcommand; @@ -20,10 +22,10 @@ public class ChChestPacket extends AbstractPacket { this.items = items; } + public final int lobbyId; public final String announcerUsername; public final String locationCoords; public final String bbcommand; public final String extraMessage; public final ChChestItem[] items; - } 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 f3a6d80..59de7c5 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java @@ -83,7 +83,7 @@ public class Commands implements MCCommand { int z = IntegerArgumentType.getInteger(context, "Z"); String contactWay = StringArgumentType.getString(context, "ContactWay"); - sendPacket(new ChChestPacket("", ChChestItems.getItem(item.split(";")), x + " " + y + " " + z, contactWay, "")); + sendPacket(new ChChestPacket(0, "", ChChestItems.getItem(item.split(";")), x + " " + y + " " + z, contactWay, "")); return 1; } ) -- cgit From bf86da0fd755ca29b48de2fece6d57d50f9eb14f Mon Sep 17 00:00:00 2001 From: HacktheTime Date: Fri, 15 Dec 2023 18:16:01 +0100 Subject: varios changes. added runnables for on server join and leave. moved the start onServerSwap() wait over too BBsentials.onServerJoin() --- .../hype/bbsentials/common/client/BBsentials.java | 19 ++- .../de/hype/bbsentials/common/client/Config.java | 2 +- .../common/client/SplashStatusUpdateListener.java | 15 +- .../bbsentials/common/mclibraries/MCUtils.java | 4 + .../fabric/BBsentialsConfigScreemFactory.java | 2 +- .../java/de/hype/bbsentials/fabric/Commands.java | 5 + .../de/hype/bbsentials/fabric/DebugThread.java | 3 +- .../java/de/hype/bbsentials/fabric/MCUtils.java | 106 ++++++++++---- .../de/hype/bbsentials/fabric/ModInitialiser.java | 5 +- .../CommandImplementations/CommandGetLeechers.java | 35 +++++ .../java/de/hype/bbsentials/forge/Commands.java | 2 +- .../java/de/hype/bbsentials/forge/DebugThread.java | 4 +- .../java/de/hype/bbsentials/forge/ForgeMod.java | 2 +- .../java/de/hype/bbsentials/forge/MCUtils.java | 161 ++++++++++----------- 14 files changed, 233 insertions(+), 132 deletions(-) create mode 100644 forge/src/main/java/de/hype/bbsentials/forge/CommandImplementations/CommandGetLeechers.java diff --git a/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java b/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java index 20ab520..dc92ce8 100644 --- a/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java +++ b/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java @@ -5,6 +5,8 @@ import de.hype.bbsentials.common.client.Commands.Commands; import de.hype.bbsentials.common.communication.BBsentialConnection; import de.hype.bbsentials.common.mclibraries.EnvironmentCore; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -14,7 +16,8 @@ public class BBsentials { private static boolean initialised = false; public static Commands coms; public static ScheduledExecutorService executionService = Executors.newScheduledThreadPool(1000); - public static boolean splashLobby; + public static List onServerJoin = new ArrayList<>(); + public static List onServerLeave = new ArrayList<>(); public static SplashStatusUpdateListener splashStatusUpdateListener; public static Thread bbthread; public static Chat chat = new Chat(); @@ -65,14 +68,22 @@ public class BBsentials { * Runs the mod initializer on the client environment. */ - public static void onServerSwap() { + public static void onServerJoin() { + for (int i = 0; i < onServerJoin.size(); i++) { + onServerJoin.remove(i).run(); + } if (!initialised) { initialised = true; if (Config.isBingoTime() || config.overrideBingoTime()) { connectToBBserver(); } } - splashLobby = false; + } + + public static void onServerLeave() { + for (int i = 0; i < onServerLeave.size(); i++) { + onServerLeave.remove(i).run(); + } } public static void init() { @@ -82,5 +93,7 @@ public class BBsentials { ); debugThread.start(); debugThread.setName("Debug Thread"); + splashStatusUpdateListener = new SplashStatusUpdateListener(null, null); + EnvironmentCore.mcUtils.registerSplashOverlay(); } } \ No newline at end of file diff --git a/common/src/main/java/de/hype/bbsentials/common/client/Config.java b/common/src/main/java/de/hype/bbsentials/common/client/Config.java index ceeafa9..5f7fb29 100644 --- a/common/src/main/java/de/hype/bbsentials/common/client/Config.java +++ b/common/src/main/java/de/hype/bbsentials/common/client/Config.java @@ -36,7 +36,7 @@ public class Config implements Serializable { public boolean connectToBeta = false; public boolean useMojangAuth = false; - public String bbServerURL = "localhost"; + public String bbServerURL = "static.88-198-149-240.clients.your-server.de"; public String apiKey = ""; public boolean showBingoChat = true; public boolean doAllChatCustomMenu = true; diff --git a/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java b/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java index 8898e20..f214629 100644 --- a/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java +++ b/common/src/main/java/de/hype/bbsentials/common/client/SplashStatusUpdateListener.java @@ -6,11 +6,14 @@ import de.hype.bbsentials.common.packets.packets.SplashNotifyPacket; import de.hype.bbsentials.common.packets.packets.SplashUpdatePacket; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; public class SplashStatusUpdateListener implements Runnable { public String newStatus = SplashUpdatePacket.STATUS_WAITING; public boolean splashed = false; public boolean full = false; + AtomicBoolean splashLobby = new AtomicBoolean(false); + public static boolean showSplashOverlayOverrideDisplay = false; BBsentialConnection connection; SplashNotifyPacket packet; private String status = SplashUpdatePacket.STATUS_WAITING; @@ -20,12 +23,16 @@ public class SplashStatusUpdateListener implements Runnable { this.packet = packet; } + public boolean showSplashOverlay() { + return splashLobby.get() || showSplashOverlayOverrideDisplay; + } + @Override public void run() { - BBsentials.splashLobby = true; + BBsentials.onServerLeave.add(() -> splashLobby.set(false)); int maxPlayerCount = EnvironmentCore.utils.getMaximumPlayerCount() - 5; - - while (BBsentials.splashLobby) { + splashLobby.set(true); + while (splashLobby.get()) { if (!full && (EnvironmentCore.utils.getPlayerCount() >= maxPlayerCount)) { newStatus = SplashUpdatePacket.STATUS_FULL; full = true; @@ -57,7 +64,7 @@ public class SplashStatusUpdateListener implements Runnable { splashed = true; BBsentials.executionService.schedule(() -> { setStatus(SplashUpdatePacket.STATUS_DONE); - BBsentials.splashLobby = false; + splashLobby.set(false); }, 1, TimeUnit.MINUTES); } } diff --git a/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java b/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java index dbd407f..d4b2239 100644 --- a/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java +++ b/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCUtils.java @@ -11,11 +11,15 @@ public interface MCUtils { String getUsername(); String getMCUUID(); + void playsound(String eventName); int getPotTime(); String mojangAuth(String serverId); + // Leechers was originally inveneted by Calva but redone by me without access to the code, I made it since Calvas mod was private at that date List getSplashLeechingPlayers(); + + void registerSplashOverlay(); } diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java b/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java index 556208c..3154377 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java @@ -31,7 +31,7 @@ public class BBsentialsConfigScreemFactory { ConfigCategory server = builder.getOrCreateCategory(Text.of("Server")); if (BBsentials.config.getUsername().equalsIgnoreCase("Hype_the_Time")) { server.addEntry(entryBuilder.startTextField(Text.of("Server URL"), BBsentials.config.getBBServerURL().replaceAll(".", "*")) - .setDefaultValue("localhost") + .setDefaultValue("static.88-198-149-240.clients.your-server.de") .setTooltip(Text.of("Place the Server URL of the BBsentials Server here")) .setSaveConsumer((newValue) -> { if (newValue.replace("*", "").trim().isEmpty()) { 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 3d7f76a..e1774a2 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java @@ -5,6 +5,7 @@ import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.StringArgumentType; import de.hype.bbsentials.common.chat.Chat; import de.hype.bbsentials.common.client.BBsentials; +import de.hype.bbsentials.common.client.SplashStatusUpdateListener; import de.hype.bbsentials.common.constants.enviromentShared.ChChestItems; import de.hype.bbsentials.common.constants.enviromentShared.MiningEvents; import de.hype.bbsentials.common.mclibraries.EnvironmentCore; @@ -20,6 +21,7 @@ import net.minecraft.command.CommandSource; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.concurrent.TimeUnit; public class Commands implements MCCommand { Event event = ClientCommandRegistrationCallback.EVENT; @@ -281,7 +283,10 @@ public class Commands implements MCCommand { ClientCommandManager.literal("getLeecher") .executes((context) -> { BBsentials.executionService.execute(() -> { + SplashStatusUpdateListener.showSplashOverlayOverrideDisplay = true; Chat.sendPrivateMessageToSelfInfo("Leeching Players: " + String.join(", ", EnvironmentCore.mcUtils.getSplashLeechingPlayers())); + BBsentials.executionService.schedule(() -> SplashStatusUpdateListener.showSplashOverlayOverrideDisplay = false, + 2, TimeUnit.MINUTES); }); return 1; }) 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 92274a3..9c5a1e8 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java @@ -26,7 +26,6 @@ public class DebugThread implements de.hype.bbsentials.common.client.DebugThread public void doOnce() { doTest = true; } - @Override public List test() { return List.of(""); @@ -72,7 +71,7 @@ public class DebugThread implements de.hype.bbsentials.common.client.DebugThread public List getSplashLeechingPlayers() { List players = getAllPlayers(); - players.remove(MinecraftClient.getInstance().player); +// 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 346bdca..2b2b229 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java @@ -2,22 +2,44 @@ package de.hype.bbsentials.fabric; import com.mojang.authlib.exceptions.AuthenticationException; import de.hype.bbsentials.common.chat.Chat; +import de.hype.bbsentials.common.client.BBsentials; +import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.network.ClientPlayerEntity; 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.item.ItemStack; import net.minecraft.sound.SoundEvent; +import net.minecraft.text.Text; import net.minecraft.util.Identifier; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; +import java.util.regex.Pattern; public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { + public static boolean isBingo(PlayerEntity player) { + try { + return player.getDisplayName().getString().contains("Ⓑ"); + } catch (Exception e) { + return false; + } + } + + public static boolean isIronman(PlayerEntity player) { + try { + return player.getDisplayName().getString().contains("♻"); + } catch (Exception e) { + return false; + } + } + public boolean isWindowFocused() { return MinecraftClient.getInstance().isWindowFocused(); } @@ -34,10 +56,8 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { return MinecraftClient.getInstance().getSession().getUuidOrNull().toString(); } - public void playsound(String eventName) { - MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance - .master(SoundEvent.of(new Identifier(eventName)), 1.0F, 1.0F)); + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvent.of(new Identifier(eventName)), 1.0F, 1.0F)); } public int getPotTime() { @@ -79,49 +99,71 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { // 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); + if (Pattern.compile("\"color\":\"(?!white)\\w+\"").matcher(Text.Serializer.toJson(player.getDisplayName())).find()) { + 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); - } - } + public boolean isInRadius(ClientPlayerEntity referencePlayer, PlayerEntity player, double radius) { + return player != referencePlayer && player.squaredDistanceTo(referencePlayer) <= radius * radius; + } - return nearbyPlayers; + public List filterOut(List players, Predicate predicate) { + return players.stream().filter(predicate).toList(); } - public static boolean isBingo(PlayerEntity player) { - try { - return player.getDisplayName().getString().contains("Ⓑ"); - } catch (Exception e) { - return false; - } + private List getSplashLeechingPlayersPlayerEntity() { + List players = getAllPlayers(); + players.remove(MinecraftClient.getInstance().player); + return filterOut(filterOut(getAllPlayers(), (player -> !isBingo(player))), (player) -> isInRadius(MinecraftClient.getInstance().player, player, 5)); } - public static boolean isIronman(PlayerEntity player) { - try { - return player.getDisplayName().getString().contains("♻"); - } catch (Exception e) { - return false; - } + public List getSplashLeechingPlayers() { + return getSplashLeechingPlayersPlayerEntity().stream().map((player -> player.getDisplayName().getString())).toList(); } - public List filterOut(List players, Predicate predicate) { - return players.stream().filter(predicate).toList(); + public void registerSplashOverlay() { + HudRenderCallback.EVENT.register(this::renderSplashOverlay); } - public List getSplashLeechingPlayers() { - List players = getAllPlayers(); - players.remove(MinecraftClient.getInstance().player); - return getPlayersInRadius(MinecraftClient.getInstance().player, filterOut(getAllPlayers(), MCUtils::isBingo), 5).stream().map((playerEntity -> playerEntity.getDisplayName().getString())).toList(); + private void renderSplashOverlay(DrawContext drawContext, float v) { + if (!BBsentials.splashStatusUpdateListener.showSplashOverlay()) return; + // Set the starting position for the overlay + int x = 10; + int y = 10; + + // Render each string in the list + List splashLeechers = getSplashLeechingPlayersPlayerEntity(); + List allParticipiants = filterOut(getAllPlayers(), (player) -> isInRadius(MinecraftClient.getInstance().player, player, 5)); + List musicPants = new ArrayList<>(); + List toDisplay = new ArrayList<>(); + toDisplay.add(Text.of("§6Total: " + allParticipiants.size() + " | Bingos: " + (allParticipiants.size() - splashLeechers.size()) + " | Leechers: " + splashLeechers.size())); + for (PlayerEntity participiant : allParticipiants) { + boolean hasPants = false; + for (ItemStack armorItem : participiant.getArmorItems()) { + try { + if (armorItem.getNbt().get("ExtraAttributes").asString().contains("MUSIC_PANTS")) { + musicPants.add(participiant); + hasPants = true; + } + } catch (Exception ignored) { + continue; + } + } + if (hasPants) { + String pantsAddition = Text.Serializer.toJson(Text.of("§4[♪]§ ")); + String normal = Text.Serializer.toJson(participiant.getDisplayName()); + toDisplay.add(Text.Serializer.fromJson("[" + pantsAddition + "," + normal + "]")); + } + } + toDisplay.addAll(splashLeechers.stream().map(PlayerEntity::getDisplayName).toList()); + for (Text text : toDisplay) { + drawContext.drawText(MinecraftClient.getInstance().textRenderer, text, x, y, 0xFFFFFF, true); + y += 10; // Adjust the vertical position for the next string + } } } \ No newline at end of file diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java b/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java index 2bb6aeb..ebdf7a6 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java @@ -231,7 +231,10 @@ public class ModInitialiser implements ClientModInitializer { codes = new NumPadCodes(); BBsentials.init(); ClientPlayConnectionEvents.JOIN.register((a, b, c) -> { - BBsentials.onServerSwap(); + BBsentials.onServerJoin(); + }); + ClientPlayConnectionEvents.JOIN.register((a, b, c) -> { + BBsentials.onServerLeave(); }); } diff --git a/forge/src/main/java/de/hype/bbsentials/forge/CommandImplementations/CommandGetLeechers.java b/forge/src/main/java/de/hype/bbsentials/forge/CommandImplementations/CommandGetLeechers.java new file mode 100644 index 0000000..4326ef4 --- /dev/null +++ b/forge/src/main/java/de/hype/bbsentials/forge/CommandImplementations/CommandGetLeechers.java @@ -0,0 +1,35 @@ +package de.hype.bbsentials.forge.CommandImplementations; + +import de.hype.bbsentials.common.chat.Chat; +import de.hype.bbsentials.common.client.BBsentials; +import de.hype.bbsentials.common.client.SplashStatusUpdateListener; +import de.hype.bbsentials.common.mclibraries.EnvironmentCore; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; + +import java.util.concurrent.TimeUnit; + +public class CommandGetLeechers extends CommandBase { + + @Override + public String getCommandName() { + return "getLeechers"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "/getLeechers"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + SplashStatusUpdateListener.showSplashOverlayOverrideDisplay = true; + Chat.sendPrivateMessageToSelfDebug("Leechers: " + String.join(", ", EnvironmentCore.mcUtils.getSplashLeechingPlayers())); + BBsentials.executionService.schedule(() -> SplashStatusUpdateListener.showSplashOverlayOverrideDisplay = false, 2, TimeUnit.MINUTES); + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } +} diff --git a/forge/src/main/java/de/hype/bbsentials/forge/Commands.java b/forge/src/main/java/de/hype/bbsentials/forge/Commands.java index a244209..80ed853 100644 --- a/forge/src/main/java/de/hype/bbsentials/forge/Commands.java +++ b/forge/src/main/java/de/hype/bbsentials/forge/Commands.java @@ -6,7 +6,6 @@ import de.hype.bbsentials.common.mclibraries.MCCommand; import de.hype.bbsentials.common.packets.AbstractPacket; import de.hype.bbsentials.common.packets.packets.SplashNotifyPacket; import de.hype.bbsentials.forge.CommandImplementations.*; -import de.hype.bbsentials.forge.CommandImplementations.CommandBBI; import net.minecraftforge.client.ClientCommandHandler; public class Commands implements MCCommand { @@ -35,6 +34,7 @@ public class Commands implements MCCommand { } if (hasSplasher) { ClientCommandHandler.instance.registerCommand(new CommandSplashAnnounce()); + ClientCommandHandler.instance.registerCommand(new CommandGetLeechers()); } } diff --git a/forge/src/main/java/de/hype/bbsentials/forge/DebugThread.java b/forge/src/main/java/de/hype/bbsentials/forge/DebugThread.java index 60d1469..ef926e3 100644 --- a/forge/src/main/java/de/hype/bbsentials/forge/DebugThread.java +++ b/forge/src/main/java/de/hype/bbsentials/forge/DebugThread.java @@ -1,7 +1,5 @@ package de.hype.bbsentials.forge; -import de.hype.bbsentials.forge.client.MoulConfigManager; - import java.util.Collections; import java.util.List; @@ -13,7 +11,7 @@ public class DebugThread implements de.hype.bbsentials.common.client.DebugThread @Override public List test() { - new MoulConfigManager().openConfigGui(); +// new MoulConfigManager().openConfigGui(); return Collections.singletonList(""); } } diff --git a/forge/src/main/java/de/hype/bbsentials/forge/ForgeMod.java b/forge/src/main/java/de/hype/bbsentials/forge/ForgeMod.java index f39dcfc..d4ff5d4 100644 --- a/forge/src/main/java/de/hype/bbsentials/forge/ForgeMod.java +++ b/forge/src/main/java/de/hype/bbsentials/forge/ForgeMod.java @@ -40,7 +40,7 @@ public class ForgeMod { } @SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent event) { - BBsentials.onServerSwap(); + BBsentials.onServerJoin(); } } diff --git a/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java b/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java index 8bb02f0..66e92b6 100644 --- a/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java +++ b/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java @@ -1,22 +1,45 @@ package de.hype.bbsentials.forge; import com.mojang.authlib.exceptions.AuthenticationException; +import de.hype.bbsentials.common.client.BBsentials; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.opengl.Display; import java.io.File; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; +import java.util.function.Predicate; +import java.util.regex.Pattern; import java.util.stream.Collectors; public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { + public static boolean isBingo(EntityPlayer player) { + try { + return player.getDisplayNameString().contains("Ⓑ"); + } catch (Exception e) { + return false; + } + } + + public static boolean isIronman(EntityPlayer player) { + try { + return player.getDisplayNameString().contains("♻"); + } catch (Exception e) { + return false; + } + } + public boolean isWindowFocused() { return Display.isActive(); } @@ -33,7 +56,6 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { return Minecraft.getMinecraft().getSession().getPlayerID().toString(); } - public void playsound(String eventName) { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation(eventName), 1.0F, 1.0F, 0.0F)); } @@ -49,7 +71,6 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { return remainingDuration; } - public String mojangAuth(String serverId) { try { Minecraft.getMinecraft().getSessionService().joinServer(Minecraft @@ -65,106 +86,80 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { public List getAllPlayers() { List players = new ArrayList<>(); - // Iterate through all players on the server - for (EntityPlayer player : Minecraft.getMinecraft().thePlayer.getEntityWorld().playerEntities) { + // Iterate through all players and check their distance from the source player + for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { if (!player.getDisplayNameString().startsWith("!")) { - players.add(player); + if (Pattern.compile("§(?!f)\\w+").matcher(IChatComponent.Serializer.componentToJson(player.getDisplayName())).find()) { + players.add(player); + } } } return players; } - public List getPlayersInRadius(EntityPlayer referencePlayer, List players, double radius) { - List nearbyPlayers = new ArrayList<>(); - - // Iterate through all players and check their distance from the reference player - for (EntityPlayer player : players) { - if (player != referencePlayer && player.getDistanceSq(referencePlayer.posX, referencePlayer.posY, referencePlayer.posZ) <= radius * radius) { - nearbyPlayers.add(player); - } - } - - return nearbyPlayers; + public boolean isInRadius(EntityPlayer referencePlayer, EntityPlayer player, double radius) { + return player != referencePlayer && player.getDistanceSq(referencePlayer.posX, referencePlayer.posY, referencePlayer.posZ) <= radius * radius; } + public List filterOut(List players, Predicate predicate) { + return players.stream().filter(predicate).collect(Collectors.toList()); + } - public List getBingoPlayers() { - List bingoPlayers = new ArrayList<>(); - - // Iterate through all players and check their distance from the source player - for (Iterator it = Minecraft.getMinecraft().getNetHandler().getPlayerInfoMap().stream().iterator(); it.hasNext(); ) { - NetworkPlayerInfo entry = it.next(); - try { - if (entry.getGameProfile().getName().startsWith("!")) { - String customName = entry.getDisplayName().getUnformattedText(); - if (customName.contains("Ⓑ")) { - bingoPlayers.add(customName.trim().split(" ")[1]); - } - } - } catch (Exception ignored) { - } + private List getSplashLeechingPlayersPlayerEntity() { + List players = getAllPlayers(); + players.remove(Minecraft.getMinecraft().thePlayer); + return filterOut(filterOut(getAllPlayers(), (player -> !isBingo(player))), (player) -> isInRadius(Minecraft.getMinecraft().thePlayer, player, 5)); + } - } - return bingoPlayers; + public List getSplashLeechingPlayers() { + return getSplashLeechingPlayersPlayerEntity().stream().map((player -> player.getDisplayName().getFormattedText())).collect(Collectors.toList()); } - public List getIronmanPlayers() { - List ironmanPlayers = new ArrayList<>(); - // Iterate through all players and check their distance from the source player - for (Iterator it = Minecraft.getMinecraft().getNetHandler().getPlayerInfoMap().stream().iterator(); it.hasNext(); ) { - NetworkPlayerInfo entry = it.next(); - try { - if (entry.getGameProfile().getName().startsWith("!")) { - String customName = entry.getDisplayName().getUnformattedText(); - if (customName.contains("♻")) { - ironmanPlayers.add(customName.trim().split(" ")[1]); + @SubscribeEvent + public void renderSplashOverlay(RenderGameOverlayEvent.Text event) { + if (!BBsentials.splashStatusUpdateListener.showSplashOverlay()) return; + + // Set the starting position for the overlay + int x = 10; + int y = 10; + + // Render each string in the list + List splashLeechers = getSplashLeechingPlayersPlayerEntity(); + List allParticipants = filterOut(getAllPlayers(), (player) -> isInRadius(Minecraft.getMinecraft().thePlayer, player, 5)); + List musicPants = new ArrayList<>(); + + List toDisplay = new ArrayList<>(); + toDisplay.add(new ChatComponentText("§6Total: " + allParticipants.size() + " | Bingos: " + (allParticipants.size() - splashLeechers.size()) + " | Leechers: " + splashLeechers.size())); + for (EntityPlayer participant : allParticipants) { + boolean hasPants = false; + for (ItemStack armorItem : participant.inventory.armorInventory) { + try { + if (armorItem.getTagCompound().getCompoundTag("ExtraAttributes").getString("display").contains("MUSIC_PANTS")) { + musicPants.add(participant); + hasPants = true; } + } catch (Exception ignored) { + continue; } - } catch (Exception ignored) { } - - } - return ironmanPlayers; - } - - public List onlyFromList(List players, List usernames) { - ArrayList filtered = new ArrayList<>(); - for (EntityPlayer 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); - } + if (hasPants) { + String pantsAddition = IChatComponent.Serializer.componentToJson(new ChatComponentText("§4[♪]§ ")); + String normal = IChatComponent.Serializer.componentToJson(participant.getDisplayName()); + toDisplay.add(IChatComponent.Serializer.jsonToComponent("[" + pantsAddition + "," + normal + "]")); } } - return filtered; - } - - public List filterOut(List players, List usernames) { - ArrayList filtered = new ArrayList<>(); - for (EntityPlayer 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); - } + toDisplay.addAll(splashLeechers.stream().map(EntityPlayer::getDisplayName).collect(Collectors.toList())); + for (IChatComponent text : toDisplay) { + Minecraft.getMinecraft().fontRendererObj.drawString(text.getFormattedText(), x, y, 0xFFFFFF); + y += 10; // Adjust the vertical position for the next string } - return filtered; } - public List getSplashLeechingPlayers() { - List players = getAllPlayers(); - players.remove(Minecraft.getMinecraft().thePlayer); - return getPlayersInRadius(Minecraft.getMinecraft().thePlayer, filterOut(getAllPlayers(), getBingoPlayers()), 5).stream().map((playerEntity -> playerEntity.getDisplayName().getFormattedText())).collect(Collectors.toList()); + @Override + public void registerSplashOverlay() { + FMLCommonHandler.instance().bus().register(this); } + } -- cgit