aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/hype/bbsentials/chat/Chat.java6
-rw-r--r--src/main/java/de/hype/bbsentials/client/BBsentials.java7
-rw-r--r--src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java72
-rw-r--r--src/main/java/de/hype/bbsentials/client/Config.java153
-rw-r--r--src/main/java/de/hype/bbsentials/client/ModMenuConfig.java4
-rw-r--r--src/main/java/de/hype/bbsentials/client/ModMenueScreen.java13
-rw-r--r--src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java2
7 files changed, 118 insertions, 139 deletions
diff --git a/src/main/java/de/hype/bbsentials/chat/Chat.java b/src/main/java/de/hype/bbsentials/chat/Chat.java
index 00380ff..84e1c9e 100644
--- a/src/main/java/de/hype/bbsentials/chat/Chat.java
+++ b/src/main/java/de/hype/bbsentials/chat/Chat.java
@@ -172,7 +172,7 @@ public class Chat {
sendPrivateMessageToSelf(Formatting.RED + "B: " + message);
return null;
}
- if (getConfig().isDevModeEnabled()) {
+ if (getConfig().isDetailedDevModeEnabled()) {
System.out.println("Got message to analyse internally: " + message);
}
//party accepter
@@ -246,13 +246,13 @@ public class Chat {
else if (message.contains("bb:test")) {
sendPrivateMessageToSelf(test());
}
- else if ((message.endsWith("is visiting Your Garden !") || message.endsWith("is visiting Your Island !")) && !MinecraftClient.getInstance().isWindowFocused()) {
+ else if ((message.endsWith("is visiting Your Garden !") || message.endsWith("is visiting Your Island !")) && !MinecraftClient.getInstance().isWindowFocused()&& config.doDesktopNotifications) {
sendNotification("BBsentials Visit-Watcher", message);
}
else if (message.equals("Please type /report confirm to log your report for staff review.")) {
sendCommand("/report confirm");
}
- else if (message.contains(":") && !MinecraftClient.getInstance().isWindowFocused()) {
+ else if (message.contains(":") && !MinecraftClient.getInstance().isWindowFocused()&&config.doDesktopNotifications) {
if (message.startsWith("Party >")) {
String partyMessage = message.replaceFirst("Party >", "").trim();
messageOriginal = replaceAllForText(messageOriginal, "\"action\":\"run_command\",\"value\":\"/viewprofile", "\"action\":\"run_command\",\"value\":\"/hci menu pcm " + partyMessage);
diff --git a/src/main/java/de/hype/bbsentials/client/BBsentials.java b/src/main/java/de/hype/bbsentials/client/BBsentials.java
index 0a2dc71..10bca46 100644
--- a/src/main/java/de/hype/bbsentials/client/BBsentials.java
+++ b/src/main/java/de/hype/bbsentials/client/BBsentials.java
@@ -53,6 +53,11 @@ public class BBsentials implements ClientModInitializer {
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);
@@ -191,7 +196,7 @@ public class BBsentials implements ClientModInitializer {
}
public static void connectToBBserver() {
- connectToBBserver(false);
+ connectToBBserver(config.connectToBeta);
}
public static void connectToBBserver(boolean beta) {
diff --git a/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java b/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java
index 82a5155..c4900ec 100644
--- a/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java
+++ b/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java
@@ -1,9 +1,79 @@
package de.hype.bbsentials.client;
+import me.shedaniel.clothconfig2.api.ConfigBuilder;
+import me.shedaniel.clothconfig2.api.ConfigCategory;
+import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
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) {
- return parent;
+ 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"));
+ server.addEntry(entryBuilder.startStrField(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)
+ .setDefaultValue("unset")
+ .setTooltip(Text.of("Put you API Key here (the one generated in the Discord! with /link)"))
+ .setSaveConsumer(newValue -> config.apiKey = newValue)
+ .build());
+ server.addEntry(entryBuilder.startBooleanToggle(Text.of("Connect to Test Server"), config.connectToBeta)
+ .setDefaultValue(false)
+ .setTooltip(Text.of("Makes you connect to the Test Server instead of the Main Server. Keep in mind that all announces may be tests and the main announces are not transferred over to here!")) // Optional: Shown when the user hover over this option
+ .setSaveConsumer(newValue -> config.connectToBeta = newValue)
+ .build());
+ server.addEntry(entryBuilder.startBooleanToggle(Text.of("Override Bingo Time"), config.overrideBingoTime)
+ .setDefaultValue(false)
+ .setTooltip(Text.of("Override the Bingo Time and connect always to the Server. (Bingo time is 14 days cause Extreme Bingo)"))
+ .setSaveConsumer(newValue -> config.overrideBingoTime = newValue)
+ .build());
+ //Visual
+ ConfigCategory visual = builder.getOrCreateCategory(Text.of("Visual"));
+ visual.addEntry(entryBuilder.startBooleanToggle(Text.of("Show Bingo Chat"), config.showBingoChat)
+ .setDefaultValue(true)
+ .setTooltip(Text.of("Select if you want the Bingo Chat to be show"))
+ .setSaveConsumer(newValue -> config.showBingoChat = newValue)
+ .build());
+ //Notifications
+ ConfigCategory notifications = builder.getOrCreateCategory(Text.of("Notifications"));
+ notifications.addEntry(entryBuilder.startBooleanToggle(Text.of("Do Desktop Notifications"), config.doDesktopNotifications)
+ .setDefaultValue(true)
+ .setTooltip(Text.of("Select if you want BBsentials to automatically accept reparties"))
+ .setSaveConsumer(newValue -> config.doDesktopNotifications = newValue)
+ .build());
+ notifications.addEntry(entryBuilder.startStrField(Text.of("Nickname"), config.nickname)
+ .setDefaultValue("")
+ .setTooltip(Text.of("Nickname. you will get send desktop notifications if a message contains one"))
+ .setSaveConsumer(newValue -> config.nickname = newValue)
+ .build());
+ notifications.addEntry(entryBuilder.startStringDropdownMenu(Text.of("Notification on"), config.NotifForPartyMessagesType) // Start the StringDropdownMenu entry
+ .setSelections(List.of("all", "nick", "none"))
+ .setTooltip(Text.of("When do you want to receive Desktop Notifications? on all party, party messages containing nickname or no party messages"))
+ .setDefaultValue("all")
+ .setSuggestionMode(true)
+ .setSaveConsumer(newValue -> config.NotifForPartyMessagesType = newValue)
+ .build());
+ //other
+ ConfigCategory other = builder.getOrCreateCategory(Text.of("Other"));
+ other.addEntry(entryBuilder.startBooleanToggle(Text.of("Accept Reparties"), config.acceptReparty)
+ .setDefaultValue(true)
+ .setTooltip(Text.of("Select if you want BBsentials to automatically accept reparties"))
+ .setSaveConsumer(newValue -> config.showBingoChat = newValue)
+ .build());
+
+
+
+ return builder.build();
}
}
diff --git a/src/main/java/de/hype/bbsentials/client/Config.java b/src/main/java/de/hype/bbsentials/client/Config.java
index 131b067..f2186ed 100644
--- a/src/main/java/de/hype/bbsentials/client/Config.java
+++ b/src/main/java/de/hype/bbsentials/client/Config.java
@@ -8,124 +8,52 @@ import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import java.io.*;
-import java.lang.reflect.Field;
-import java.net.Socket;
import java.time.LocalDate;
import java.util.ArrayList;
public class Config implements Serializable {
- // Helper class for sending chat messages
- public int version = 1;
- public transient final Sender sender = new Sender();
-
- public transient boolean highlightitem = false;
- public transient String lastChatPromptAnswer = null;
-
- // Automatically set, no need for config
- private transient String username;
- private boolean overrideBingoTime = false;
+ //DO NOT Change any of the following unless you know what you are doing!
+ public int apiVersion = 1;
+ private boolean devMode = false;
+ private boolean detailedDevMode = false;
+ //You can change again
- // Set in-game
+ // set automatically
private transient boolean isLeader;
private transient String alreadyReported = "";
- private String bbServerURL = "static.204.177.34.188.clients.your-server.de";
public String[] bbsentialsRoles = {""};
public static ArrayList<String> partyMembers = new ArrayList<>();
+ public transient ToDisplayConfig toDisplayConfig = ToDisplayConfig.loadFromFile();
+ public transient final Sender sender = new Sender();
+ public transient boolean highlightitem = false;
+ public transient String lastChatPromptAnswer = null;
+ private transient String username;
- // Set via load / default
- private String bbsentialsCommandPrefix = ".";
- private String apiKey = "";
- private boolean leaveDungeonAutomatically;
+ // Set via load / default you may change these
+ public boolean overrideBingoTime = false;
+ public boolean connectToBeta = false;
+
+ public String bbServerURL = "localhost";
+ String apiKey = "";
public boolean showBingoChat = true;
- private boolean allowBBinviteMe = true;
- private boolean leaveKuudraAutomatically;
- private boolean devMode = false;
- private boolean detailedDevMode = false;
- private boolean acceptReparty;
- private String nickname;
- private String getNotifForParty;
- private final int apiVersion = 1;
- public transient ToDisplayConfig toDisplayConfig = ToDisplayConfig.loadFromFile();
+ public boolean allowBBinviteMe = true;
+ public boolean doDesktopNotifications = false;
+ public boolean acceptReparty;
+ public String nickname;
+ public String NotifForPartyMessagesType;
// Set default attribute values
private void setDefaults() {
username = MinecraftClient.getInstance().player.getName().getString();
- leaveKuudraAutomatically = true;
- leaveDungeonAutomatically = true;
acceptReparty = true;
if (username.equals("Hype_the_Time")) {
nickname = "Hype";
- getNotifForParty = "nick";
- }
+ NotifForPartyMessagesType = "nick";
+ doDesktopNotifications=true;
+ } //Gimmic for Developer due too things which dont make it into releases (bugs)
else {
nickname = "";
- getNotifForParty = "none";
- }
- }
-
- // Method to send the config to a server using sockets
- public void sendConfig(Config config, String host, int port) {
- Socket socket = null;
- ObjectOutputStream objectOutputStream = null;
- try {
- socket = new Socket(host, port);
- objectOutputStream = new ObjectOutputStream(socket.getOutputStream());
- objectOutputStream.writeObject(config);
- objectOutputStream.flush();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- if (objectOutputStream != null) {
- objectOutputStream.close();
- }
- if (socket != null) {
- socket.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- // Method to replace the current config with a new one
- public void replaceConfig(Config newConfig) {
- try {
- // Get the class of the current config
- Class<? extends Config> currentClass = this.getClass();
-
- // Get the fields of the current config class
- Field[] currentFields = currentClass.getDeclaredFields();
-
- // Iterate through the fields
- for (Field field : currentFields) {
- // Exclude the socket field from being updated
- if (field.getName().equals("serverSocket") || field.getName().equals("clientSocket")) {
- continue;
- }
-
- // Make the field accessible to modify its value
- field.setAccessible(true);
-
- // Get the corresponding field from the new config class
- Field newField = newConfig.getClass().getDeclaredField(field.getName());
-
- // Make the new field accessible to read its value
- newField.setAccessible(true);
-
- // Get the current value of the field
- Object currentValue = field.get(this);
-
- // Get the new value of the field
- Object newValue = newField.get(newConfig);
-
- // Update the field only if it is defined or explicitly overridden
- if (newValue != null || currentValue == null) {
- field.set(this, newValue);
- }
- }
- } catch (IllegalAccessException | NoSuchFieldException e) {
- e.printStackTrace();
+ NotifForPartyMessagesType = "none";
}
}
@@ -151,7 +79,7 @@ public class Config implements Serializable {
e.printStackTrace();
settings = new Config(); // Use default values if loading fails
settings.save();
- }catch (IllegalStateException e){
+ } catch (IllegalStateException e) {
System.out.println("Error loading config. Resetting it.");
settings = new Config();
settings.save();
@@ -196,15 +124,7 @@ public class Config implements Serializable {
}
public String getNotifForParty() {
- return getNotifForParty;
- }
-
- public boolean isLeaveDungeonAutomatically() {
- return leaveDungeonAutomatically;
- }
-
- public boolean isLeaveKuudraAutomatically() {
- return leaveKuudraAutomatically;
+ return NotifForPartyMessagesType;
}
public boolean isDevModeEnabled() {
@@ -235,15 +155,6 @@ public class Config implements Serializable {
return bbServerURL;
}
- public String getCommandPrefix(String type) {
- if (type.equals("BBsentials")) {
- System.out.println("Registered command with: " + bbsentialsCommandPrefix);
- return bbsentialsCommandPrefix;
- }
- else {
- return "/";
- }
- }
public static boolean isBingoTime() {
LocalDate currentDate = LocalDate.now();
@@ -258,10 +169,6 @@ public class Config implements Serializable {
return overrideBingoTime;
}
- public boolean isHighlightitem() {
- return highlightitem;
- }
-
public String getLastChatPromptAnswer() {
return lastChatPromptAnswer;
}
@@ -274,10 +181,6 @@ public class Config implements Serializable {
this.lastChatPromptAnswer = lastChatPromptAnswer;
}
- public int getVersion() {
- return version;
- }
-
public boolean hasBBRoles(String roleName) {
for (String role : bbsentialsRoles) {
if (role.equalsIgnoreCase(roleName)) {
diff --git a/src/main/java/de/hype/bbsentials/client/ModMenuConfig.java b/src/main/java/de/hype/bbsentials/client/ModMenuConfig.java
new file mode 100644
index 0000000..015f56c
--- /dev/null
+++ b/src/main/java/de/hype/bbsentials/client/ModMenuConfig.java
@@ -0,0 +1,4 @@
+package de.hype.bbsentials.client;
+
+public class ModMenuConfig {
+}
diff --git a/src/main/java/de/hype/bbsentials/client/ModMenueScreen.java b/src/main/java/de/hype/bbsentials/client/ModMenueScreen.java
index 64de624..8376517 100644
--- a/src/main/java/de/hype/bbsentials/client/ModMenueScreen.java
+++ b/src/main/java/de/hype/bbsentials/client/ModMenueScreen.java
@@ -8,13 +8,10 @@ import net.minecraft.client.gui.screen.NoticeScreen;
import net.minecraft.text.Text;
public class ModMenueScreen implements ModMenuApi {
- public class CITResewnModMenu implements ModMenuApi {
- @Override
- public ConfigScreenFactory<?> getModConfigScreenFactory() {
- if (FabricLoader.getInstance().isModLoaded("cloth-config2"))
- return BBsentialsConfigScreemFactory::create;
-
- return parent -> new NoticeScreen(() -> MinecraftClient.getInstance().setScreen(parent), Text.of("CIT Resewn"), Text.of("CIT Resewn requires Cloth Config to be able to show the config."));
- }
+ @Override
+ public ConfigScreenFactory<?> getModConfigScreenFactory() {
+ if (FabricLoader.getInstance().isModLoaded("cloth-config2"))
+ return BBsentialsConfigScreemFactory::create;
+ return parent -> new NoticeScreen(() -> MinecraftClient.getInstance().setScreen(parent), Text.of("BBsentials"), Text.of("BBsentials requires Cloth Config to be able to show the config."));
}
}
diff --git a/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java b/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java
index cb873ad..8140e2e 100644
--- a/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java
+++ b/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java
@@ -322,7 +322,7 @@ public class BBsentialConnection {
public <E extends AbstractPacket> void sendPacket(E packet) {
String packetName = packet.getClass().getSimpleName();
- String rawjson = PacketUtils.parsePacketToJson(packet);
+ String rawjson = PacketUtils.parsePacketToJson(packet);
if (BBsentials.getConfig().isDetailedDevModeEnabled() && !(packet.getClass().equals(RequestConnectPacket.class))) {
Chat.sendPrivateMessageToSelf("BBDev-sP: "+packetName+": "+rawjson);
}