diff options
author | hackthetime <l4bg0jb7@duck.com> | 2023-12-14 12:57:03 +0100 |
---|---|---|
committer | HacktheTime <l4bg0jb7@duck.com> | 2023-12-15 18:17:42 +0100 |
commit | f8ab64f88f69ec50d5aca562f0ddbbf6ff7b0a34 (patch) | |
tree | 328c9b25691e27aab8a4281e9c17e72fa5973868 | |
parent | 709972ffd493632949282ca848fee848146a01ad (diff) | |
download | BBsentials-f8ab64f88f69ec50d5aca562f0ddbbf6ff7b0a34.tar.gz BBsentials-f8ab64f88f69ec50d5aca562f0ddbbf6ff7b0a34.tar.bz2 BBsentials-f8ab64f88f69ec50d5aca562f0ddbbf6ff7b0a34.zip |
a lot of prob not full working things
14 files changed, 419 insertions, 50 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 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 - * <li>{@link #CRYSTAL_HOLLOWS} - * <li>{@link #CRIMSON_ISLE} - * <li>{@link #DEEP_CAVERNS} - * <li>{@link #DUNGEON} - * <li>{@link #DUNGEON_HUB} - * <li>{@link #DWARVEN_MINES} - * <li>{@link #GOLD_MINE} - * <li>{@link #HUB} - * <li>{@link #KUUDRA} - * <li>{@link #PRIVATE_ISLAND} - * <li>{@link #SPIDERS_DEN} - * <li>{@link #THE_END} - * <li>{@link #THE_FARMING_ISLANDS} - * <li>{@link #JERRYS_WORKSHOP} - * <li>{@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 - * <li>{@link #BETTER_TOGETHER} - * <li>{@link #DOUBLE_POWDER} - * <li>{@link #GONE_WITH_THE_WIND} - * <li>{@link #GOBLIN_RAID} - * <li>{@link #MITHRIL_GOURMAND} - * <li>{@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<String> 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<String> 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<String> 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/Commands.java b/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java index e23d76b..f3a6d80 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java @@ -246,6 +246,15 @@ public class Commands implements MCCommand { }) ); });/*requestpottimes*/ + event.register((dispatcher, registryAccess) -> { + dispatcher.register( + ClientCommandManager.literal("getLeecher") + .executes((context) -> { + Chat.sendPrivateMessageToSelfInfo("Leeching Players: " + String.join(", ", EnvironmentCore.mcUtils.getSplashLeechingPlayers())); + return 1; + }) + ); + });/*getLeecher*/ } if (hasAdmin) { event.register((dispatcher, registryAccess) -> { diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java b/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java index e792ff9..92274a3 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java @@ -1,10 +1,16 @@ package de.hype.bbsentials.fabric; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.entity.player.PlayerEntity; + +import java.util.ArrayList; import java.util.List; public class DebugThread implements de.hype.bbsentials.common.client.DebugThread { boolean doTest = false; + public static List<Object> store = new ArrayList<>(); @Override public void loop() { if (doTest) { @@ -25,4 +31,48 @@ public class DebugThread implements de.hype.bbsentials.common.client.DebugThread public List<String> test() { return List.of(""); } + + public List<PlayerEntity> getAllPlayers() { + List<PlayerEntity> players = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerEntity player : MinecraftClient.getInstance().player.getEntityWorld().getPlayers()) { + if (!player.getDisplayName().getString().startsWith("!")) { + players.add(player); + } + } + + return players; + } + + public List<PlayerEntity> getPlayersInRadius(ClientPlayerEntity referencePlayer, List<PlayerEntity> players, double radius) { + List<PlayerEntity> nearbyPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerEntity player : players) { + if (player != referencePlayer && player.squaredDistanceTo(referencePlayer) <= radius * radius) { + nearbyPlayers.add(player); + } + } + + return nearbyPlayers; + } + + public List<PlayerEntity> getNonBingoPlayers(List<PlayerEntity> players) { + List<PlayerEntity> nonBingoPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerEntity player : players) { + if (player.getCustomName().getString().contains("Ⓑ")) { + nonBingoPlayers.add(player); + } + } + return nonBingoPlayers; + } + + public List<String> getSplashLeechingPlayers() { + List<PlayerEntity> players = getAllPlayers(); + players.remove(MinecraftClient.getInstance().player); + return getPlayersInRadius(MinecraftClient.getInstance().player, getNonBingoPlayers(players), 5).stream().map((playerEntity -> playerEntity.getDisplayName().getString())).toList(); + } } diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java b/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java index 26d2872..b87a54c 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java @@ -4,13 +4,18 @@ import com.mojang.authlib.exceptions.AuthenticationException; import de.hype.bbsentials.common.chat.Chat; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import java.io.File; +import java.util.ArrayList; +import java.util.List; public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { public boolean isWindowFocused() { @@ -57,14 +62,117 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { } catch (AuthenticationException e) { try { Thread.sleep(1000); - }catch (Exception ignored){ + } catch (Exception ignored) { } - if (tries==0){ - Chat.sendPrivateMessageToSelfError("Could not authenticate at mojang: "+e.getMessage()); + if (tries == 0) { + Chat.sendPrivateMessageToSelfError("Could not authenticate at mojang: " + e.getMessage()); e.printStackTrace(); } } } return serverId; } -} + + public List<PlayerEntity> getAllPlayers() { + List<PlayerEntity> players = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerEntity player : MinecraftClient.getInstance().player.getEntityWorld().getPlayers()) { + if (!player.getDisplayName().getString().startsWith("!")) { + players.add(player); + } + } + + return players; + } + + public List<PlayerEntity> getPlayersInRadius(ClientPlayerEntity referencePlayer, List<PlayerEntity> players, double radius) { + List<PlayerEntity> nearbyPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerEntity player : players) { + if (player != referencePlayer && player.squaredDistanceTo(referencePlayer) <= radius * radius) { + nearbyPlayers.add(player); + } + } + + return nearbyPlayers; + } + + public List<String> getBingoPlayers() { + List<String> bingoPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerListEntry entry : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + try { + if (entry.getProfile().getName().startsWith("!")) { + String customName = entry.getDisplayName().getString(); + if (customName.contains("Ⓑ")) { + bingoPlayers.add(customName.trim().split(" ")[1]); + } + } + } catch (Exception ignored) { + } + + } + return bingoPlayers; + } + + public List<String> getIronmanPlayers() { + List<String> ironmanPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (PlayerListEntry entry : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + try { + if (entry.getProfile().getName().startsWith("!")) { + String customName = entry.getDisplayName().getString(); + if (customName.contains("♻")) { + ironmanPlayers.add(customName.trim().split(" ")[1]); + } + } + } catch (Exception ignored) { + } + + } + return ironmanPlayers; + } + + public List<PlayerEntity> onlyFromList(List<PlayerEntity> players, List<String> usernames) { + ArrayList<PlayerEntity> filtered = new ArrayList<>(); + for (PlayerEntity player : players) { + String playerUsername = player.getGameProfile().getName(); + for (int i = 0; i < usernames.size(); i++) { + if (playerUsername.equals(usernames.get(i))) { + usernames.remove(i); + filtered.add(player); + } + } + } + return filtered; + } + + public List<PlayerEntity> filterOut(List<PlayerEntity> players, List<String> usernames) { + ArrayList<PlayerEntity> filtered = new ArrayList<>(); + for (PlayerEntity player : players) { + String playerUsername = player.getGameProfile().getName(); + boolean toAdd = true; + for (int i = 0; i < usernames.size(); i++) { + if (playerUsername.equals(usernames.get(i))) { + toAdd = false; + usernames.remove(i); + break; + } + } + if (toAdd) { + filtered.add(player); + } + } + return filtered; + } + + public List<String> getSplashLeechingPlayers() { + List<PlayerEntity> players = getAllPlayers(); + players.remove(MinecraftClient.getInstance().player); + return getPlayersInRadius(MinecraftClient.getInstance().player, filterOut(getAllPlayers(), getBingoPlayers()), 5).stream().map((playerEntity -> playerEntity.getDisplayName().getString())).toList(); + } +}
\ No newline at end of file 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<EntityPlayer> getAllPlayers() { + List<EntityPlayer> 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<EntityPlayer> getPlayersInRadius(EntityPlayer referencePlayer, List<EntityPlayer> players, double radius) { + List<EntityPlayer> 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<String> getBingoPlayers() { + List<String> bingoPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (Iterator<NetworkPlayerInfo> 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<String> getIronmanPlayers() { + List<String> ironmanPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (Iterator<NetworkPlayerInfo> 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<EntityPlayer> onlyFromList(List<EntityPlayer> players, List<String> usernames) { + ArrayList<EntityPlayer> 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<EntityPlayer> filterOut(List<EntityPlayer> players, List<String> usernames) { + ArrayList<EntityPlayer> 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<String> getSplashLeechingPlayers() { + List<EntityPlayer> 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<MoulConfig> editor; - MoulConfigProcessor<MoulConfig> 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<MoulConfig> 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)); + } +} |