From dba4a297e295d68980da31264b0069fe9b18a13e Mon Sep 17 00:00:00 2001 From: HacktheTime Date: Thu, 12 Oct 2023 20:17:28 +0200 Subject: preperations to have a common code and different implementations for forge and fabric to ease up maintaining both versions --- src/main/java/de/hype/bbsentials/api/Discord.java | 70 --- .../java/de/hype/bbsentials/api/ISimpleOption.java | 5 - src/main/java/de/hype/bbsentials/api/Options.java | 13 - src/main/java/de/hype/bbsentials/chat/Chat.java | 466 ----------------- src/main/java/de/hype/bbsentials/chat/Message.java | 117 ----- src/main/java/de/hype/bbsentials/chat/Sender.java | 106 ---- .../java/de/hype/bbsentials/client/BBUtils.java | 66 --- .../java/de/hype/bbsentials/client/BBsentials.java | 261 ---------- .../client/BBsentialsConfigScreemFactory.java | 304 ----------- .../bbsentials/client/Commands/CommandsOLD.java | 365 ------------- .../java/de/hype/bbsentials/client/Config.java | 205 -------- .../java/de/hype/bbsentials/client/CustomGson.java | 28 - .../de/hype/bbsentials/client/DebugThread.java | 52 -- .../de/hype/bbsentials/client/ModMenueScreen.java | 18 - .../de/hype/bbsentials/client/SplashManager.java | 58 --- .../client/SplashStatusUpdateListener.java | 65 --- .../de/hype/bbsentials/client/ToDisplayConfig.java | 96 ---- .../communication/BBsentialConnection.java | 569 --------------------- .../constants/BBDisplayNameProvider.java | 23 - .../constants/BBDisplayNameProviderWithCustom.java | 6 - .../enviromentShared/AuthenticationConstants.java | 7 - .../constants/enviromentShared/ChChestItem.java | 46 -- .../constants/enviromentShared/ChChestItems.java | 87 ---- .../constants/enviromentShared/EnumUtils.java | 208 -------- .../enviromentShared/InternalReasonConstants.java | 14 - .../constants/enviromentShared/Islands.java | 47 -- .../constants/enviromentShared/MiningEvents.java | 39 -- .../mixins/ClientCommandSourceMixin.java | 56 -- .../hype/bbsentials/mixins/ItemRendererMixin.java | 40 -- .../de/hype/bbsentials/mixins/ScreenMixin.java | 26 - .../hype/bbsentials/mixins/SimpleOptionMixin.java | 33 -- .../de/hype/bbsentials/packets/AbstractPacket.java | 67 --- .../bbsentials/packets/EnviromentPacketConfig.java | 7 - .../java/de/hype/bbsentials/packets/Packet.java | 26 - .../de/hype/bbsentials/packets/PacketManager.java | 53 -- .../de/hype/bbsentials/packets/PacketUtils.java | 103 ---- .../packets/packets/BingoChatMessagePacket.java | 25 - .../packets/packets/BroadcastMessagePacket.java | 18 - .../bbsentials/packets/packets/ChChestPacket.java | 23 - .../packets/packets/DisconnectPacket.java | 23 - .../packets/DisplayTellrawMessagePacket.java | 12 - .../packets/packets/InternalCommandPacket.java | 32 -- .../packets/InvalidCommandFeedbackPacket.java | 24 - .../packets/packets/MiningEventPacket.java | 25 - .../bbsentials/packets/packets/PartyPacket.java | 16 - .../packets/packets/PunishUserPacket.java | 24 - .../packets/packets/RequestConnectPacket.java | 20 - .../packets/packets/SplashNotifyPacket.java | 28 - .../packets/packets/SplashUpdatePacket.java | 22 - .../packets/packets/SystemMessagePacket.java | 16 - .../packets/packets/WelcomeClientPacket.java | 18 - 51 files changed, 4078 deletions(-) delete mode 100644 src/main/java/de/hype/bbsentials/api/Discord.java delete mode 100644 src/main/java/de/hype/bbsentials/api/ISimpleOption.java delete mode 100644 src/main/java/de/hype/bbsentials/api/Options.java delete mode 100644 src/main/java/de/hype/bbsentials/chat/Chat.java delete mode 100644 src/main/java/de/hype/bbsentials/chat/Message.java delete mode 100644 src/main/java/de/hype/bbsentials/chat/Sender.java delete mode 100644 src/main/java/de/hype/bbsentials/client/BBUtils.java delete mode 100644 src/main/java/de/hype/bbsentials/client/BBsentials.java delete mode 100644 src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java delete mode 100644 src/main/java/de/hype/bbsentials/client/Commands/CommandsOLD.java delete mode 100644 src/main/java/de/hype/bbsentials/client/Config.java delete mode 100644 src/main/java/de/hype/bbsentials/client/CustomGson.java delete mode 100644 src/main/java/de/hype/bbsentials/client/DebugThread.java delete mode 100644 src/main/java/de/hype/bbsentials/client/ModMenueScreen.java delete mode 100644 src/main/java/de/hype/bbsentials/client/SplashManager.java delete mode 100644 src/main/java/de/hype/bbsentials/client/SplashStatusUpdateListener.java delete mode 100644 src/main/java/de/hype/bbsentials/client/ToDisplayConfig.java delete mode 100644 src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java delete mode 100644 src/main/java/de/hype/bbsentials/constants/BBDisplayNameProvider.java delete mode 100644 src/main/java/de/hype/bbsentials/constants/BBDisplayNameProviderWithCustom.java delete mode 100644 src/main/java/de/hype/bbsentials/constants/enviromentShared/AuthenticationConstants.java delete mode 100644 src/main/java/de/hype/bbsentials/constants/enviromentShared/ChChestItem.java delete mode 100644 src/main/java/de/hype/bbsentials/constants/enviromentShared/ChChestItems.java delete mode 100644 src/main/java/de/hype/bbsentials/constants/enviromentShared/EnumUtils.java delete mode 100644 src/main/java/de/hype/bbsentials/constants/enviromentShared/InternalReasonConstants.java delete mode 100644 src/main/java/de/hype/bbsentials/constants/enviromentShared/Islands.java delete mode 100644 src/main/java/de/hype/bbsentials/constants/enviromentShared/MiningEvents.java delete mode 100644 src/main/java/de/hype/bbsentials/mixins/ClientCommandSourceMixin.java delete mode 100644 src/main/java/de/hype/bbsentials/mixins/ItemRendererMixin.java delete mode 100644 src/main/java/de/hype/bbsentials/mixins/ScreenMixin.java delete mode 100644 src/main/java/de/hype/bbsentials/mixins/SimpleOptionMixin.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/AbstractPacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/EnviromentPacketConfig.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/Packet.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/PacketManager.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/PacketUtils.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/BingoChatMessagePacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/BroadcastMessagePacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/ChChestPacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/DisconnectPacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/DisplayTellrawMessagePacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/InternalCommandPacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/InvalidCommandFeedbackPacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/MiningEventPacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/PartyPacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/PunishUserPacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/RequestConnectPacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/SplashNotifyPacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/SplashUpdatePacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/SystemMessagePacket.java delete mode 100644 src/main/java/de/hype/bbsentials/packets/packets/WelcomeClientPacket.java (limited to 'src/main/java/de/hype') diff --git a/src/main/java/de/hype/bbsentials/api/Discord.java b/src/main/java/de/hype/bbsentials/api/Discord.java deleted file mode 100644 index 3f47439..0000000 --- a/src/main/java/de/hype/bbsentials/api/Discord.java +++ /dev/null @@ -1,70 +0,0 @@ -package de.hype.bbsentials.api; - -import de.hype.bbsentials.chat.Chat; -import de.hype.bbsentials.client.BBsentials; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; - -public class Discord { - public static void sendWebhookMessage(String message) { - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - sendWebhookMessageNoThread(message); - } - }); - thread.start(); - } - - - public static void sendWebhookMessageNoThread(String message) { - CloseableHttpClient httpClient = HttpClients.createDefault(); - String WEBHOOK_URL = "https://discord.com/api/v8/webhooks/1127524566407860276/" + BBsentials.getConfig().getApiKey(); - - - try { - HttpPost httpPost = new HttpPost(WEBHOOK_URL); - - StringEntity jsonEntity = new StringEntity("{\"content\": \"" + message + "\"}", StandardCharsets.UTF_8); - jsonEntity.setContentType("application/json"); - httpPost.setEntity(jsonEntity); - - CloseableHttpResponse response = httpClient.execute(httpPost); - HttpEntity responseEntity = response.getEntity(); - - if (responseEntity != null) { - InputStream inputStream = responseEntity.getContent(); - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); - - String line; - StringBuilder responseBuilder = new StringBuilder(); - while ((line = reader.readLine()) != null) { - responseBuilder.append(line); - } - - String responseString = responseBuilder.toString(); - Chat.sendPrivateMessageToSelfInfo(responseString); - } - - response.close(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - httpClient.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } -} diff --git a/src/main/java/de/hype/bbsentials/api/ISimpleOption.java b/src/main/java/de/hype/bbsentials/api/ISimpleOption.java deleted file mode 100644 index c6e1158..0000000 --- a/src/main/java/de/hype/bbsentials/api/ISimpleOption.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.hype.bbsentials.api; - -public interface ISimpleOption { - void set(Object value); -} diff --git a/src/main/java/de/hype/bbsentials/api/Options.java b/src/main/java/de/hype/bbsentials/api/Options.java deleted file mode 100644 index 7dc4b0d..0000000 --- a/src/main/java/de/hype/bbsentials/api/Options.java +++ /dev/null @@ -1,13 +0,0 @@ -package de.hype.bbsentials.api; - -import net.minecraft.client.MinecraftClient; - -public class Options{ - public static void setFov(int value) { - ((ISimpleOption) (Object) MinecraftClient.getInstance().options.getFov()).set(value); - } - public static void setGamma(double value) { - ((ISimpleOption) (Object) MinecraftClient.getInstance().options.getGamma()).set(value); - } -} - diff --git a/src/main/java/de/hype/bbsentials/chat/Chat.java b/src/main/java/de/hype/bbsentials/chat/Chat.java deleted file mode 100644 index ac5f892..0000000 --- a/src/main/java/de/hype/bbsentials/chat/Chat.java +++ /dev/null @@ -1,466 +0,0 @@ -package de.hype.bbsentials.chat; - -import de.hype.bbsentials.client.BBsentials; -import de.hype.bbsentials.client.Config; -import de.hype.bbsentials.packets.packets.SplashUpdatePacket; -import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; -import net.fabricmc.fabric.api.client.message.v1.ClientSendMessageEvents; -import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; - -import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Clip; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Modifier; -import java.time.Instant; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static de.hype.bbsentials.client.BBsentials.*; - -public class Chat { - public Chat() { - init(); - } - - public static String[] getVariableInfo(String packageName, String className) { - List variableInfoList = new ArrayList<>(); - - // Combine the class name with the package name - String fullClassName = packageName + "." + className; - - // Load the class - Class clazz = null; - try { - clazz = Class.forName(fullClassName); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - - // Extract fields of the class - Field[] fields = clazz.getDeclaredFields(); - - // Collect information for each field - for (Field field : fields) { - // Exclude transient fields - if (java.lang.reflect.Modifier.isTransient(field.getModifiers())) { - continue; - } - String variableName = field.getName(); - String variablePackageName = clazz.getPackage().getName(); - String variableClassName = clazz.getSimpleName(); - - variableInfoList.add(variableName); - } - - return variableInfoList.toArray(new String[variableInfoList.size()]); - } - - public static void setVariableValue(Object obj, String variableName, String value) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException { - if (value == null) { - // Handle null value case - sendPrivateMessageToSelfError("Invalid value: null"); - return; - } - - Class objClass = obj.getClass(); - Field field = objClass.getDeclaredField(variableName); - field.setAccessible(true); - - // Get the type of the field - Class fieldType = field.getType(); - - // Convert the value to the appropriate type - Object convertedValue = parseValue(value, fieldType); - - if (Modifier.isStatic(field.getModifiers())) { - // If the field is static - field.set(null, convertedValue); - } - else { - field.set(obj, convertedValue); - } - - // Check and output the value of the variable - sendPrivateMessageToSelfSuccess("The variable " + field.getName() + " is now: " + field.get(obj)); - } - - private static Object parseValue(String value, Class targetType) { - if (targetType == int.class || targetType == Integer.class) { - return Integer.parseInt(value); - } - else if (targetType == double.class || targetType == Double.class) { - return Double.parseDouble(value); - } - else if (targetType == float.class || targetType == Float.class) { - return Float.parseFloat(value); - } - else if (targetType == long.class || targetType == Long.class) { - return Long.parseLong(value); - } - else if (targetType == boolean.class || targetType == Boolean.class) { - return Boolean.parseBoolean(value); - } - else { - // For other types, return the original string value - return value; - } - } - - public static void getVariableValue(Object object, String variableName) throws NoSuchFieldException, IllegalAccessException { - Class objClass = object.getClass(); - Field field = objClass.getDeclaredField(variableName); - field.setAccessible(true); - sendPrivateMessageToSelfSuccess("The variable " + field.getName() + " is: " + field.get(object)); - } - - private void init() { - // Register a callback for a custom message type - ClientReceiveMessageEvents.CHAT.register((message, signedMessage, sender, params, receptionTimestamp) -> { - onEvent(message); - }); - ClientReceiveMessageEvents.MODIFY_GAME.register((message, overlay) -> (onEvent(message))); - ClientSendMessageEvents.CHAT.register(message -> { - if (message.startsWith("/")) { - System.out.println("Sent command: " + message); - } - }); - } - - private Text onEvent(Text text) { - if (!isSpam(text.toString())) { - if (getConfig().isDetailedDevModeEnabled()) { - System.out.println("got a message: " + Text.Serializer.toJson(text)); - } - Message message = new Message(text); - executionService.execute(() -> processThreaded(message)); - return processNotThreaded(message); - } - return text; // Return the original message if it is spam - } - - //Handle in the messages which need to be modified here - public Text processNotThreaded(Message message) { -// if (message.isFromParty()) { -// message.replaceInJson("\"action\":\"run_command\",\"value\":\"/viewprofile", "\"action\":\"run_command\",\"value\":\"/bviewprofile " + messageUnformatted.split(">", 1)[1].trim()); -// } - if (message.isFromReportedUser()) { - sendPrivateMessageToSelfBase(Formatting.RED + "B: " + message.getUnformattedString()); - return null; - } - if (config.doPartyChatCustomMenu && message.isFromParty()) { - message.replaceInJson("/viewprofile \\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}", "/socialoptions party " + message.getPlayerName() + " " + message.getUnformattedString()); - } - else if (config.doGuildChatCustomMenu && message.isFromGuild()) { - message.replaceInJson("/viewprofile \\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}", "/socialoptions guild " + message.getPlayerName() + " " + message.getUnformattedString()); - } - else if (config.doAllChatCustomMenu) { - System.out.println("User: '" + message.getPlayerName() + "' | Message: " + message.getUnformattedString()); - message.replaceInJson("/socialoptions " + message.getPlayerName(), "/socialoptions sb " + message.getPlayerName() + " " + message.getUnformattedString()); - } - - return message.text; - } - - public void processThreaded(Message message) { - if (message.getString() != null) { - String messageUnformatted = message.getUnformattedString(); - String username = message.getPlayerName(); - if (message.isFromReportedUser()) { - - } - else if (!MinecraftClient.getInstance().isWindowFocused()) { - if (config.doDesktopNotifications) { - if ((messageUnformatted.endsWith("is visiting Your Garden !") || messageUnformatted.endsWith("is visiting Your Island !")) && !MinecraftClient.getInstance().isWindowFocused() && config.doDesktopNotifications) { - sendNotification("BBsentials Visit-Watcher", messageUnformatted); - } - else if (message.isMsg()) { - sendNotification("BBsentials Message Notifier", username + " sent you the following message: " + message.getMessageContent()); - } - if (message.getMessageContent().toLowerCase().contains(getConfig().getUsername().toLowerCase()) || (message.getMessageContent().toLowerCase().contains(getConfig().getNickname().toLowerCase() + " ") && getConfig().getNotifForParty().toLowerCase().equals("nick")) || getConfig().getNotifForParty().toLowerCase().equals("all")) { - sendNotification("BBsentials Party Chat Notification", username + " : " + message.getMessageContent()); - } - else { - if (message.getMessageContent().toLowerCase().contains(getConfig().getUsername().toLowerCase()) || message.getMessageContent().toLowerCase().contains(config.getNickname().toLowerCase() + " ")) { - sendNotification("BBsentials Notifier", "You got mentioned in chat! " + message.getMessageContent()); - } - } - } - } - else if (message.isServerMessage()) { - if (messageUnformatted.contains("disbanded the party")) { - lastPartyDisbandedUsername = username; - partyDisbandedMap.put(username, Instant.now()); - } - else if (message.contains("invited you to join their party")) { - if (lastPartyDisbandedUsername != null && partyDisbandedMap != null) { - Instant lastDisbandedInstant = partyDisbandedMap.get(lastPartyDisbandedUsername); - if (config.acceptReparty) { - if (lastDisbandedInstant != null && lastDisbandedInstant.isAfter(Instant.now().minusSeconds(20)) && (username.equals(lastPartyDisbandedUsername))) { - sendCommand("/p accept " + username); - } - } - } - if (!MinecraftClient.getInstance().isWindowFocused()) { - sendNotification("BBsentials Party Notifier", "You got invited too a party by: " + username); - } - } - else if (message.startsWith("Party Members (")) { - Config.partyMembers = new ArrayList<>(); - } - else if (message.startsWith("Party Moderators:")) { - String temp = messageUnformatted.replace("Party Moderators:", "").replace(" ●", "").replaceAll("\\s*\\[[^\\]]+\\]", "").trim(); - if (temp.contains(",")) { - for (int i = 0; i < temp.split(",").length; i++) { - Config.partyMembers.add(temp.split(",")[i - 1]); - } - } - else { - Config.partyMembers.add(temp); - } - } - else if (message.startsWith("Party Members:")) { - String temp = messageUnformatted.replace("Party Members:", "").replace(" ●", "").replaceAll("\\s*\\[[^\\]]+\\]", "").trim(); - if (temp.contains(",")) { - for (int i = 0; i < temp.split(",").length; i++) { - System.out.println("Added to plist: " + (temp.split(",")[i - 1])); - Config.partyMembers.add(temp.split(",")[i - 1]); - } - } - else { - Config.partyMembers.add(temp); - } - } - else if ((message.contains("Party Leader:") && !message.contains(getConfig().getUsername())) || message.equals("You are not currently in a party.") || (message.contains("warped the party into a Skyblock Dungeon") && !message.startsWith(getConfig().getUsername()) || (!message.startsWith("The party was transferred to " + getConfig().getUsername()) && message.startsWith("The party was transferred to"))) || messageUnformatted.endsWith(getConfig().getUsername() + " is now a Party Moderator") || (message.startsWith("The party was disbanded")) || (message.contains("You have joined ") && message.contains("'s party!")) || (message.contains("Party Leader, ") && message.contains(" , summoned you to their server.")) || (message.contains("warped to your dungeon"))) { - BBsentials.getConfig().setIsLeader(false); - if (getConfig().isDetailedDevModeEnabled()) { - sendPrivateMessageToSelfDebug("Leader: " + getConfig().isLeader()); - } - } - else if (config.getPlayersInParty().length == 0 && messageUnformatted.endsWith("to the party! They have 60 seconds to accept")) { - config.setIsLeader(true); - } - else if (messageUnformatted.startsWith("You'll be partying with:")) { - List members = new ArrayList<>(); - for (String users : messageUnformatted.replace("You'll be partying with:", "").replaceAll("\\[[^\\]]*\\]","").trim().split(",")) { - if (users.contains("and ")){break;} - members.add(users); - } - Config.partyMembers=members; - } - else if (((messageUnformatted.startsWith("Party Leader: ") && messageUnformatted.endsWith(getConfig().getUsername() + " ●"))) || (message.contains(getConfig().getUsername() + " warped the party to a SkyBlock dungeon!")) || message.startsWith("The party was transferred to " + getConfig().getUsername()) || message.getUnformattedString().endsWith(" has promoted " + getConfig().getUsername() + " to Party Leader") || (message.contains("warped to your dungeon"))) { - BBsentials.getConfig().setIsLeader(true); - if (getConfig().isDetailedDevModeEnabled()) { - sendPrivateMessageToSelfDebug("Leader: " + getConfig().isLeader()); - } - } - else if (message.getUnformattedString().equals("Please type /report confirm to log your report for staff review.")) { - sendCommand("/report confirm"); - } - else if (messageUnformatted.startsWith("BUFF! You splashed yourself with")) { - if (splashStatusUpdateListener != null) { - splashStatusUpdateListener.setStatus(SplashUpdatePacket.STATUS_SPLASHING); - } - } - } - - else if (message.isFromGuild()) { - - } - else if (message.isFromParty()) { - - } - else if (message.isMsg()) { - if (messageUnformatted.endsWith("bb:party me")) { - if (BBsentials.getConfig().allowBBinviteMe()) { - sendCommand("/p " + username); - } - } - } - else { - if (message.contains("[OPEN MENU]") || message.contains("[YES]")) { - setChatPromtId(message.getText().toString()); - } - } - } - } - - //{"strikethrough":false,"extra":[{"strikethrough":false,"clickEvent":{"action":"run_command","value":"/viewprofile 4fa1228c-8dd6-47c4-8fe3-b04b580311b8"},"hoverEvent":{"action":"show_text","contents":{"strikethrough":false,"text":"§eClick here to view §bHype_the_Time§e's profile"}},"text":"§9Party §8> §b[MVP§2+§b] Hype_the_Time§f: "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"text":"h:test"}],"text":""}// {"strikethrough":false,"extra":[{"strikethrough":false,"clickEvent":{"action":"run_command","value":"/viewprofile f772b2c7-bd2a-46e1-b1a2-41fa561157d6"},"hoverEvent":{"action":"show_text","contents":{"strikethrough":false,"text":"§eClick here to view §bShourtu§e's profile"}},"text":"§9Party §8> §b[MVP§c+§b] Shourtu§f: "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"text":"Hype_the_Time TEST"}],"text":""} - //{"strikethrough":false,"extra":[{"strikethrough":false,"clickEvent":{"action":"run_command","value":"/viewprofile 4fa1228c-8dd6-47c4-8fe3-b04b580311b8"},"hoverEvent":{"action":"show_text","contents":{"strikethrough":false,"text":"§eClick here to view §bHype_the_Time§e's profile"}},"text":"§9Party §8> §b[MVP§2+§b] Hype_the_Time§f: "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"text":"h:test"}],"text":""} - private final Map partyDisbandedMap = new HashMap<>(); - private String lastPartyDisbandedUsername = null; - - - public boolean isSpam(String message) { - if (message.contains("Mana")) return true; - if (message.contains("Status")) return true; - if (message.contains("Achievement Points")) return true; - return false; - } - - public String test() { - //put test code here - sendNotification("test", "This is an example which was run of the h:test test"); - return new String(); - } - - public static void sendPrivateMessageToSelfError(String message) { - sendPrivateMessageToSelfBase(Formatting.RED + message); - } - - public static void sendPrivateMessageToSelfFatal(String message) { - sendPrivateMessageToSelfBase(Formatting.DARK_RED + message); - } - - public static void sendPrivateMessageToSelfSuccess(String message) { - sendPrivateMessageToSelfBase(Formatting.GREEN + message); - } - - public static void sendPrivateMessageToSelfInfo(String message) { - sendPrivateMessageToSelfBase(Formatting.YELLOW + message); - } - - public static void sendPrivateMessageToSelfImportantInfo(String message) { - sendPrivateMessageToSelfBase(Formatting.GOLD + message); - } - - public static void sendPrivateMessageToSelfDebug(String message) { - sendPrivateMessageToSelfBase(Formatting.AQUA + message); - } - - private static void sendPrivateMessageToSelfBase(String message) { - MinecraftClient client = MinecraftClient.getInstance(); - if (client.player != null) { - client.player.sendMessage(Text.of(Formatting.RED + message)); - } - } - - public static void sendPrivateMessageToSelfText(Text message) { - MinecraftClient client = MinecraftClient.getInstance(); - if (client.player != null) { - client.player.sendMessage(message); - } - } - - public static void sendCommand(String s) { - getConfig().sender.addSendTask(s); - } - - public void sendNotification(String title, String text) { - executionService.execute(() -> { - try { - InputStream inputStream = getClass().getResourceAsStream("/sounds/mixkit-sci-fi-confirmation-914.wav"); - AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(inputStream); - Clip clip = AudioSystem.getClip(); - clip.open(audioInputStream); - clip.start(); - Thread.sleep(clip.getMicrosecondLength() / 1000); - clip.close(); - audioInputStream.close(); - } catch (Exception e) { - e.printStackTrace(); - } - }); - List argsList = new ArrayList<>(); - argsList.add("--title"); - argsList.add(title); - argsList.add("--passivepopup"); - argsList.add(text); - argsList.add("5"); - - try { - ProcessBuilder processBuilder = new ProcessBuilder(); - processBuilder.command("kdialog"); - processBuilder.command().addAll(argsList); - - Process process = processBuilder.start(); - process.waitFor(); - } catch (IOException | InterruptedException e) { - e.printStackTrace(); - } - } - - public static Text createClientSideTellraw(String tellrawInput) { - Text formattedMessage = null; - try { - formattedMessage = Text.Serializer.fromJson(tellrawInput); - } catch (Exception e) { - e.printStackTrace(); - System.out.println("Invalid Json: \n" + tellrawInput); - } - return formattedMessage; - } - - public static void setChatPromtId(String logMessage) { - String cbUUIDPattern = "/cb ([a-fA-F0-9-]+)"; - Pattern cbPattern = Pattern.compile(cbUUIDPattern); - Matcher cbMatcher = cbPattern.matcher(logMessage); - - String yesClickAction = "/chatprompt ([a-fA-F0-9-]+) YES"; - Pattern yesPattern = Pattern.compile(yesClickAction); - Matcher yesMatcher = yesPattern.matcher(logMessage); - String lastPrompt = null; - if (cbMatcher.find()) { - lastPrompt = cbMatcher.group(1); - String finalLastPrompt1 = lastPrompt; - new Thread(new Runnable() { - @Override - public void run() { - String promptCommand = "/cb " + finalLastPrompt1; - BBsentials.getConfig().setLastChatPromptAnswer(promptCommand); - if (config.isDevModeEnabled()) { - Chat.sendPrivateMessageToSelfDebug("set the last prompt action too + \"" + promptCommand + "\""); - } - try { - Thread.sleep(10 * 1000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - BBsentials.getConfig().setLastChatPromptAnswer(null); - return; - } - }).start(); - } - if (yesMatcher.find()) { - lastPrompt = yesMatcher.group(1); - String finalLastPrompt = lastPrompt; - new Thread(new Runnable() { - @Override - public void run() { - String promptCommand = "/chatprompt " + finalLastPrompt + " YES"; - getConfig().setLastChatPromptAnswer(promptCommand); - if (config.isDevModeEnabled()) { - Chat.sendPrivateMessageToSelfDebug("set the last prompt action too + \"" + promptCommand + "\""); - } - try { - Thread.sleep(10 * 1000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - getConfig().setLastChatPromptAnswer(null); - return; - } - }).start(); - - } - } - - public static Text replaceAllForText(Text input, String replace, String replaceWith) { - String text = Text.Serializer.toJson(input); - if (text.contains(replace)) { - text = text.replaceAll("\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}", ""); - } - text = text.replace(replace, replaceWith); - Text output = Text.Serializer.fromJson(text); - return output; - } -} diff --git a/src/main/java/de/hype/bbsentials/chat/Message.java b/src/main/java/de/hype/bbsentials/chat/Message.java deleted file mode 100644 index 42d1b2e..0000000 --- a/src/main/java/de/hype/bbsentials/chat/Message.java +++ /dev/null @@ -1,117 +0,0 @@ -package de.hype.bbsentials.chat; - -import de.hype.bbsentials.client.BBsentials; -import net.minecraft.text.Text; - -public class Message { - public Text text; - private String unformattedString = null; - private String playerName = null; - - public Message(Text text) { - this.text = text; - } - - public Text getText() { - return text; - } - - public String getString() { - return text.getString(); - } - - public String getUnformattedString() { - if (unformattedString != null) return unformattedString; - unformattedString = text.getString().replaceAll("§.", "").trim(); - return unformattedString; - } - - public String getMessageContent() { - if (isServerMessage()) return unformattedString; - return getUnformattedString().split(":", 2)[1]; - } - - Boolean guild = null; - - public boolean isFromGuild() { - if (guild != null) return guild; - guild = getUnformattedString().startsWith("Guild >"); - return guild; - } - - Boolean party = null; - - public boolean isFromParty() { - if (party != null) return party; - party = getUnformattedString().startsWith("Party >"); - return party; - } - - Boolean msg = null; - - public boolean isMsg() { - if (msg != null) return msg; - msg = getUnformattedString().startsWith("From") || getUnformattedString().startsWith("To"); - return msg; - } - - Boolean server = null; - - public boolean isServerMessage() { - if (server != null) return server; - int space = getUnformattedString().indexOf(" "); - int doublepoint = getUnformattedString().indexOf(":"); - return ((space + 2 < doublepoint)||doublepoint==-1||space==-1); - } - - public String getPlayerName() { - if (playerName != null) return playerName; - playerName = getUnformattedString(); - if (!playerName.contains(":")) { - playerName = ""; - return ""; - } - playerName = playerName.split(":", 2)[0]; - if (isMsg()) { - playerName = playerName.replaceFirst("From", "").replace("To", "").trim(); - } - if (playerName.contains(">")){ - playerName=playerName.split(">",2)[1]; - } -// playerName = playerName.replaceFirst("\\[[^\\]]*\\](?:\\s?[^\\x00-\\x7F]?\\s?\\[[^\\]]*\\])*", "").trim()// replaces every [] and unicode character before a asci character. - playerName = playerName.replaceAll("[^\\x00-\\x7F]","").replaceAll("\\[[^\\]]*\\]","").trim(); - if (playerName.matches("[^a-zA-Z0-9_-]+")) playerName = ""; - return playerName; - } - - public void replaceInJson(String replace, String replaceWith) { - String textString = toJson(); - textString = textString.replaceFirst(replace, replaceWith); - text = Text.Serializer.fromJson(textString); - } - - public static Message fromJson(String json) { - return new Message(Text.Serializer.fromJson(json)); - } - - public String toJson() { - return Text.Serializer.toJson(text); - } - - public boolean isFromReportedUser() { - return BBsentials.config.alreadyReported.contains(getPlayerName()) && !getPlayerName().isEmpty(); - } - - public boolean contains(String string) { - return getUnformattedString().contains(string); - } - - public boolean startsWith(String string) { - return getUnformattedString().startsWith(string); - } - - @Override - public String toString() { - return getUnformattedString(); - } -} diff --git a/src/main/java/de/hype/bbsentials/chat/Sender.java b/src/main/java/de/hype/bbsentials/chat/Sender.java deleted file mode 100644 index eef2469..0000000 --- a/src/main/java/de/hype/bbsentials/chat/Sender.java +++ /dev/null @@ -1,106 +0,0 @@ -package de.hype.bbsentials.chat; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; - -import java.util.ArrayList; -import java.util.List; - -import static de.hype.bbsentials.chat.Chat.sendPrivateMessageToSelfInfo; -import static de.hype.bbsentials.chat.Chat.sendPrivateMessageToSelfText; - -public class Sender { - private final List sendQueue; - private final List sendQueueTiming; - private final List hidden; - - - public Sender() { - this.sendQueue = new ArrayList<>(); - this.sendQueueTiming = new ArrayList<>(); - this.hidden = new ArrayList<>(); - startSendingThread(); - } - - public void addSendTask(String task, double timing) { - synchronized (sendQueue) { - sendPrivateMessageToSelfText(Text.literal(Formatting.GREEN + "Scheduled send-task (as " + sendQueueTiming.size() + " in line): " + task + " | Delay: " + timing)); - sendQueueTiming.add(timing); - sendQueue.add(task); - hidden.add(false); - sendQueue.notify(); // Notify the waiting thread that a new String has been added - } - } - - public void addHiddenSendTask(String task, double timing) { - synchronized (sendQueue) { - sendQueueTiming.add(timing); - sendQueue.add(task); - hidden.add(true); - - sendQueue.notify(); // Notify the waiting thread that a new String has been added - } - } - - public void addImmediateSendTask(String task) { - synchronized (sendQueue) { - sendQueueTiming.add(0, 0.0); - sendQueue.add(0, task); - hidden.add(false); - - sendQueue.notify(); // Notify the waiting thread that a new String has been added - } - } - - public void addSendTask(String task) { - addSendTask(task, 1); - } - - public void startSendingThread() { - Thread sendingThread = new Thread(new SendingRunnable()); - sendingThread.start(); - } - - private class SendingRunnable implements Runnable { - @Override - public void run() { - while (true) { - String task = getNextTask(); - if (task != null) { - send(task, sendQueueTiming.remove(0), hidden.remove(0)); - } - else { - synchronized (sendQueue) { - try { - sendQueue.wait(); // Wait for new Send - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - } - } - } - - private String getNextTask() { - synchronized (sendQueue) { - if (!sendQueue.isEmpty()) { - return sendQueue.remove(0); - } - return null; - } - } - - private void send(String toSend, double timing, boolean hidden) { - try { - Thread.sleep((long) (timing * 1000)); // Simulate the send operation - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - MinecraftClient.getInstance().getNetworkHandler().sendChatMessage(toSend); - if (!hidden) { - sendPrivateMessageToSelfInfo("Sent Command to Server: " + toSend); - } - } - } -} diff --git a/src/main/java/de/hype/bbsentials/client/BBUtils.java b/src/main/java/de/hype/bbsentials/client/BBUtils.java deleted file mode 100644 index 1b35fa6..0000000 --- a/src/main/java/de/hype/bbsentials/client/BBUtils.java +++ /dev/null @@ -1,66 +0,0 @@ -package de.hype.bbsentials.client; - -import com.google.common.collect.Lists; -import de.hype.bbsentials.chat.Chat; -import de.hype.bbsentials.constants.enviromentShared.Islands; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.PlayerListEntry; - -import java.util.Iterator; -import java.util.List; - -public class BBUtils { - public static Islands getCurrentIsland() { - try { - String string = MinecraftClient.getInstance().player.networkHandler.getPlayerListEntry("!C-b").getDisplayName().getString(); - if (!string.startsWith("Area: ")) { - Chat.sendPrivateMessageToSelfError("Could not get Area data. Are you in Skyblock?"); - } - else { - return Islands.getByDisplayName(string.replace("Area: ", "").trim()); - } - } catch (Exception e) { - } - return null; - } - - public static int getPlayerCount() { - return Integer.parseInt(MinecraftClient.getInstance().player.networkHandler.getPlayerListEntry("!B-a").getDisplayName().getString().trim().replaceAll("[^0-9]", "")); - } - - public static String getServer() { - return MinecraftClient.getInstance().player.networkHandler.getPlayerListEntry("!C-c").getDisplayName().getString().replace("Server:", "").trim(); - } - - public static boolean isOnMegaServer() { - return getServer().toLowerCase().startsWith("mega"); - } - - public static boolean isOnMiniServer() { - return getServer().toLowerCase().startsWith("mini"); - } - - public static int getMaximumPlayerCount() { - boolean mega = isOnMegaServer(); - Islands island = getCurrentIsland(); - if (island == null) return 100; - if (island.equals(Islands.HUB)) { - if (mega) return 80; - else return 24; - } - return 24; - } - - public List getPlayers() { - List list = Lists.newArrayList(); - Iterator var2 = MinecraftClient.getInstance().getNetworkHandler().getPlayerList().iterator(); - while (var2.hasNext()) { - PlayerListEntry playerListEntry = (PlayerListEntry) var2.next(); - String playerName = playerListEntry.getProfile().getName(); - if (!playerName.startsWith("!")) { - list.add(playerName); - } - } - return list; - } -} diff --git a/src/main/java/de/hype/bbsentials/client/BBsentials.java b/src/main/java/de/hype/bbsentials/client/BBsentials.java deleted file mode 100644 index fe51139..0000000 --- a/src/main/java/de/hype/bbsentials/client/BBsentials.java +++ /dev/null @@ -1,261 +0,0 @@ -package de.hype.bbsentials.client; - -import com.mojang.brigadier.arguments.StringArgumentType; -import de.hype.bbsentials.api.Options; -import de.hype.bbsentials.chat.Chat; -import de.hype.bbsentials.client.Commands.CommandsOLD; -import de.hype.bbsentials.communication.BBsentialConnection; -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; -import net.minecraft.command.CommandSource; -import org.lwjgl.glfw.GLFW; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import static de.hype.bbsentials.chat.Chat.*; - -public class BBsentials implements ClientModInitializer { - public static Config config; - public static BBsentialConnection connection; - public static CommandsOLD coms; - public static ScheduledExecutorService executionService = Executors.newScheduledThreadPool(1000); - public static boolean splashLobby; - private static Thread bbthread; - private boolean initialised = false; - public static SplashStatusUpdateListener splashStatusUpdateListener; - - public static Config getConfig() { - return config; - } - - public static void connectToBBserver() { - connectToBBserver(config.connectToBeta); - } - - /** - * Checks if still connected to the Server. - * - * @return true if it connected; false if old connection is kept. - */ - public static boolean conditionalReconnectToBBserver() { - if (!connection.isConnected()) { - Chat.sendPrivateMessageToSelfInfo("Reconnecting"); - connectToBBserver(config.connectToBeta); - return true; - } - return false; - } - - public static void connectToBBserver(boolean beta) { - if (connection != null) { - connection.sendHiddenMessage("exit"); - } - if (bbthread != null) { - if (bbthread.isAlive()) { - bbthread.interrupt(); - } - } - bbthread = new Thread(() -> { - connection = new BBsentialConnection(); - coms = new CommandsOLD(); - connection.setMessageReceivedCallback(message -> executionService.execute(() -> connection.onMessageReceived(message))); - if (beta) { - connection.connect(config.getBBServerURL(), 5011); - } - else { - connection.connect(config.getBBServerURL(), 5000); - } - executionService.scheduleAtFixedRate(new DebugThread(), 0, 20, TimeUnit.SECONDS); - }); - bbthread.start(); - } - - /** - * Runs the mod initializer on the client environment. - */ - - @Override - public void onInitializeClient() { - ClientPlayConnectionEvents.JOIN.register((a, b, c) -> { - splashLobby = false; - if (!initialised) { - config = Config.load(); - if (config.doGammaOverride) Options.setGamma(10); - Chat chat = new Chat(); - if (Config.isBingoTime() || config.overrideBingoTime()) { - connectToBBserver(); - } - initialised = true; - } - }); - } - - { - ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> { - dispatcher.register(ClientCommandManager.literal("bbi") - .then(ClientCommandManager.literal("reconnect") - .executes((context) -> { - connectToBBserver(); - return 1; - })) - .then(ClientCommandManager.literal("reconnect-stable-server") - .executes((context) -> { - connectToBBserver(false); - return 1; - })) - .then(ClientCommandManager.literal("reconnect-test-server") - .executes((context) -> { - connectToBBserver(true); - return 1; - })) - .then(ClientCommandManager.literal("config") - .then(ClientCommandManager.argument("category", StringArgumentType.string()) - .suggests((context, builder) -> { - // Provide tab-completion options for config subfolder - return CommandSource.suggestMatching(new String[]{"save", "reset", "load"}, builder); - }).executes((context) -> { - String category = StringArgumentType.getString(context, "category"); - switch (category) { - case "save": - getConfig().save(); - sendPrivateMessageToSelfSuccess("Saved config successfully"); - break; - case "load": - BBsentials.config = Config.load(); - break; - case "reset": - // Reset logic here - break; - } - return 1; - })) - .then(ClientCommandManager.literal("set-value") - .then(ClientCommandManager.argument("className", StringArgumentType.string()) - .suggests((context, builder) -> { - // Provide tab-completion options for classes - ArrayList classNames = new ArrayList<>(); - classNames.add("Config"); - // Replace with your own logic to retrieve class names - return CommandSource.suggestMatching(classNames, builder); - }) - .then(ClientCommandManager.argument("variableName", StringArgumentType.string()) - .suggests((context, builder) -> { - // Provide tab-completion options for variable names - List variableNames; - variableNames = List.of(getVariableInfo("de.hype.bbsentials.client", "Config")); - return CommandSource.suggestMatching(variableNames, builder); - }) - .then(ClientCommandManager.argument("variableValue", StringArgumentType.string()) - .executes((context) -> { - // Handle "variableName" and "variableValue" logic here - String variableName = StringArgumentType.getString(context, "variableName"); - String variableValue = StringArgumentType.getString(context, "variableValue"); - try { - if (!variableName.toLowerCase().contains("dev") || config.hasBBRoles("dev")) { - setVariableValue(getConfig(), variableName, variableValue); - } - getConfig().save(); - } catch (ClassNotFoundException | - NoSuchFieldException | - IllegalAccessException | - InstantiationException | - InvocationTargetException | - NoSuchMethodException e) { - Chat.sendPrivateMessageToSelfError("Invalid variable or value"); - } - return 1; - }))))) - .then(ClientCommandManager.literal("get-value") - .then(ClientCommandManager.argument("className", StringArgumentType.string()) - .suggests((context, builder) -> { - // Provide tab-completion options for classes - ArrayList classNames = new ArrayList<>(); - classNames.add("Config"); - // Replace with your own logic to retrieve class names - return CommandSource.suggestMatching(classNames, builder); - }) - .then(ClientCommandManager.argument("variableName", StringArgumentType.string()) - .suggests((context, builder) -> { - // Provide tab-completion options for variable names - List variableNames; - variableNames = List.of(getVariableInfo("de.hype.bbsentials.client", "Config")); - return CommandSource.suggestMatching(variableNames, builder); - }) - .executes((context) -> { - // Handle "variableName" and "variableValue" logic here - String variableName = StringArgumentType.getString(context, "variableName"); - try { - Chat.getVariableValue(getConfig(), variableName); - } catch (Exception e) { - e.printStackTrace(); - } - return 1; - }))).executes((context) -> { - // Handle the case when "config" argument is not provided - // ... - return 1; - }))) - ); - }); //bbi - - KeyBinding devKeyBind = new KeyBinding("Open Mod Menu Config", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_ADD, "BBsentials: Developing Tools"); - KeyBindingHelper.registerKeyBinding(devKeyBind); - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (devKeyBind.wasPressed()) { - MinecraftClient.getInstance().setScreen(BBsentialsConfigScreemFactory.create(MinecraftClient.getInstance().currentScreen)); - } - }); - - KeyBinding promptKeyBind = new KeyBinding("Chat Prompt Yes / Open Menu", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_R, "BBsentials"); - KeyBindingHelper.registerKeyBinding(promptKeyBind); - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (promptKeyBind.wasPressed()) { - if (config.getLastChatPromptAnswer() != null) { - if (config.isDetailedDevModeEnabled()) { - Chat.sendPrivateMessageToSelfDebug(config.getLastChatPromptAnswer()); - } - MinecraftClient.getInstance().getNetworkHandler().sendChatMessage(config.getLastChatPromptAnswer()); - } - config.setLastChatPromptAnswer(null); - } - }); - KeyBinding craftKeyBind = new KeyBinding("Craft", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_V, "BBsentials"); - KeyBindingHelper.registerKeyBinding(craftKeyBind); - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (craftKeyBind.wasPressed()) MinecraftClient.getInstance().getNetworkHandler().sendChatMessage("/craft"); - }); - KeyBinding petKeyBind = new KeyBinding("Open Pet Menu", InputUtil.Type.KEYSYM, -1, "BBsentials"); - KeyBindingHelper.registerKeyBinding(petKeyBind); - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (petKeyBind.wasPressed()) MinecraftClient.getInstance().getNetworkHandler().sendChatMessage("/pets"); - }); - for (int i = 1; i <= 9; i++) { - KeyBinding ecPageKeyBind = new KeyBinding("Ender Chest Page " + i, InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_1 + (i - 1), "BBsentials"); - KeyBindingHelper.registerKeyBinding(ecPageKeyBind); - int pageNum = i; // Capture the page number for lambda - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (ecPageKeyBind.wasPressed()) { - BBsentials.getConfig().sender.addImmediateSendTask("/ec " + pageNum); - } - }); - } - } // KeyBinds - - public void manualLoad() { - initialised = true; - config = Config.load(); - connectToBBserver(); - } -} \ No newline at end of file diff --git a/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java b/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java deleted file mode 100644 index d078b46..0000000 --- a/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java +++ /dev/null @@ -1,304 +0,0 @@ -package de.hype.bbsentials.client; - -import de.hype.bbsentials.constants.enviromentShared.Islands; -import me.shedaniel.clothconfig2.api.ConfigBuilder; -import me.shedaniel.clothconfig2.api.ConfigCategory; -import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; -import me.shedaniel.clothconfig2.api.Requirement; -import me.shedaniel.clothconfig2.gui.entries.BooleanListEntry; -import me.shedaniel.clothconfig2.gui.entries.DropdownBoxEntry; -import me.shedaniel.clothconfig2.gui.entries.StringListEntry; -import me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.NoticeScreen; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.Text; - -import java.util.List; - -import static de.hype.bbsentials.client.BBsentials.config; - -public class BBsentialsConfigScreemFactory { - public static Screen create(Screen parent) { - if (BBsentials.config == null) { - return new NoticeScreen(() -> MinecraftClient.getInstance().setScreen(parent), Text.of("BBsentials"), Text.of("You need to login to a Server for the Config to be loaded.")); - } - else { - ConfigBuilder builder = ConfigBuilder.create() - .setParentScreen(parent) - .setTitle(Text.of("BBsentials Config")); - builder.setSavingRunnable(BBsentials.getConfig()::save); - ConfigEntryBuilder entryBuilder = builder.entryBuilder(); - ConfigCategory server = builder.getOrCreateCategory(Text.of("Server")); - if (config.getUsername().equalsIgnoreCase("Hype_the_Time")) { - server.addEntry(entryBuilder.startTextField(Text.of("Server URL"), config.getBBServerURL().replaceAll(".", "*")) - .setDefaultValue("localhost") - .setTooltip(Text.of("Place the Server URL of the BBsentials Server here")) - .setSaveConsumer((newValue) -> { - if (newValue.replace("*", "").trim().isEmpty()) { - return; - } - else { - config.bbServerURL = newValue; - } - }) - .build()); - } - else { - server.addEntry(entryBuilder.startTextField(Text.of("Server URL"), config.getBBServerURL()) - .setDefaultValue("localhost") - .setTooltip(Text.of("Place the Server URL of the BBsentials Server here")) - .setSaveConsumer(newValue -> config.bbServerURL = newValue) - .build()); - } - server.addEntry(entryBuilder.startStrField(Text.of("BBsentials API key"), config.apiKey.replaceAll(".", "*")) - .setDefaultValue("unset") - .setTooltip(Text.of("Put you API Key here (the one generated in the Discord! with /link). §cThe Text is visually censored. Not saved unless you changed it.")) - .setSaveConsumer((newValue) -> { - if (newValue.replace("*", "").trim().isEmpty()) { - return; - } - else { -