aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java19
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/client/Config.java98
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java1
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java2
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java1
-rw-r--r--forge/src/main/java/de/hype/bbsentials/forge/ExampleMod.java1
-rw-r--r--forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java2
-rw-r--r--log4j2.xml6
8 files changed, 61 insertions, 69 deletions
diff --git a/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java b/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java
index 2c9a603..20fb7ef 100644
--- a/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java
+++ b/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java
@@ -18,7 +18,6 @@ public class BBsentials {
public static SplashStatusUpdateListener splashStatusUpdateListener;
public static Thread bbthread;
public static Chat chat = new Chat();
- private static boolean initialised = false;
public static Config getConfig() {
return config;
@@ -67,20 +66,14 @@ public class BBsentials {
public static void onServerSwap() {
splashLobby = false;
- if (!initialised) {
- config = Config.load();
- executionService.scheduleAtFixedRate(EnvironmentCore.debug, 0, 20, TimeUnit.SECONDS);
- if (config.doGammaOverride) EnvironmentCore.mcoptions.setGamma(10);
- if (Config.isBingoTime() || config.overrideBingoTime()) {
- connectToBBserver();
- }
- initialised = true;
- }
}
- public void manualLoad() {
- initialised = true;
+ public static void init() {
config = Config.load();
- connectToBBserver();
+ executionService.scheduleAtFixedRate(EnvironmentCore.debug, 0, 20, TimeUnit.SECONDS);
+ if (config.doGammaOverride) EnvironmentCore.mcoptions.setGamma(10);
+ if (Config.isBingoTime() || config.overrideBingoTime()) {
+ connectToBBserver();
+ }
}
} \ No newline at end of file
diff --git a/common/src/main/java/de/hype/bbsentials/common/client/Config.java b/common/src/main/java/de/hype/bbsentials/common/client/Config.java
index e05320a..ceeafa9 100644
--- a/common/src/main/java/de/hype/bbsentials/common/client/Config.java
+++ b/common/src/main/java/de/hype/bbsentials/common/client/Config.java
@@ -13,25 +13,23 @@ import java.util.List;
public class Config implements Serializable {
//DO NOT Change any of the following unless you know what you are doing!
public static int apiVersion = 1;
+ public static List<String> partyMembers = new ArrayList<>();
+ public transient final Sender sender = new Sender();
+ // Gson object for serialization
+ private final transient Gson GSON = new GsonBuilder().setPrettyPrinting().create();
+ // File object for storing the config
+ private final transient File CONFIG_FILE = new File(EnvironmentCore.mcUtils.getConfigPath(), "BBsential_settings.json");
+ //You can change again
public boolean allowServerPartyInvite = true;
public boolean devMode = false;
public boolean detailedDevMode = false;
public boolean devSecurity = true;
- //You can change again
-
- // set automatically
- private transient boolean isPartyLeader;
public transient String overwriteActionBar = "";
-
public transient String alreadyReported = "";
public String[] bbsentialsRoles = {""};
- public static List<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 you may change these
public boolean useNumCodes = true;
public boolean overrideBingoTime = false;
@@ -41,9 +39,9 @@ public class Config implements Serializable {
public String bbServerURL = "localhost";
public String apiKey = "";
public boolean showBingoChat = true;
- public boolean doAllChatCustomMenu=true;
- public boolean doPartyChatCustomMenu=true;
- public boolean doGuildChatCustomMenu=true;
+ public boolean doAllChatCustomMenu = true;
+ public boolean doPartyChatCustomMenu = true;
+ public boolean doGuildChatCustomMenu = true;
public boolean allowBBinviteMe = true;
public boolean doDesktopNotifications = false;
@@ -57,27 +55,9 @@ public class Config implements Serializable {
public boolean swapActionBarChat = false;
public boolean swapOnlyNormal = true;
public boolean swapOnlyBBsentials = false;
-
- // Set default attribute values
- private void setDefaults() {
- username = EnvironmentCore.mcUtils.getUsername();
- acceptReparty = true;
- if (username.equals("Hype_the_Time")) {
- nickname = "Hype";
- notifForMessagesType = "nick";
- doDesktopNotifications=true;
- } //Gimmic for Developer due too things which dont make it into releases (bugs)
- else {
- nickname = "";
- notifForMessagesType = "none";
- }
- }
-
- // Gson object for serialization
- private final transient Gson GSON = new GsonBuilder().setPrettyPrinting().create();
- // File object for storing the config
- private final transient File CONFIG_FILE = new File(EnvironmentCore.mcUtils.getConfigPath(), "BBsential_settings.json");
-
+ // set automatically
+ private transient boolean isPartyLeader;
+ private transient String username;
// Constructor
public Config() {
setDefaults();
@@ -89,14 +69,12 @@ public class Config implements Serializable {
File CONFIG_FILE = new File(EnvironmentCore.mcUtils.getConfigPath(), "BBsential_settings.json");
Gson GSON = new GsonBuilder().setPrettyPrinting().create();
if (CONFIG_FILE.exists()) {
- try (FileReader reader = new FileReader(CONFIG_FILE)) {
+ try {
+ FileReader reader = new FileReader(CONFIG_FILE);
settings = GSON.fromJson(reader, Config.class);
- } catch (IOException e) {
+ } catch (IOException | RuntimeException e) {
+ System.err.println("Error loading config. Resetting it.");
e.printStackTrace();
- settings = new Config(); // Use default values if loading fails
- settings.save();
- } catch (IllegalStateException e) {
- System.out.println("Error loading config. Resetting it.");
settings = new Config();
settings.save();
}
@@ -114,6 +92,30 @@ public class Config implements Serializable {
return settings;
}
+ public static boolean isBingoTime() {
+ LocalDate currentDate = LocalDate.now();
+ LocalDate lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
+ LocalDate firstDayOfMonth = currentDate.withDayOfMonth(1);
+ Boolean isBefore = currentDate.isAfter(lastDayOfMonth.minusDays(4));
+ Boolean isInRange = currentDate.isBefore(firstDayOfMonth.plusDays(15));
+ return isBefore || isInRange;
+ }
+
+ // Set default attribute values
+ private void setDefaults() {
+ username = EnvironmentCore.mcUtils.getUsername();
+ acceptReparty = true;
+ if (username.equals("Hype_the_Time")) {
+ nickname = "Hype";
+ notifForMessagesType = "nick";
+ doDesktopNotifications = true;
+ } //Gimmic for Developer due too things which dont make it into releases (bugs)
+ else {
+ nickname = "";
+ notifForMessagesType = "none";
+ }
+ }
+
// Save the config to file
public void save() {
try (FileWriter writer = new FileWriter(CONFIG_FILE)) {
@@ -169,16 +171,6 @@ public class Config implements Serializable {
return bbServerURL;
}
-
- public static boolean isBingoTime() {
- LocalDate currentDate = LocalDate.now();
- LocalDate lastDayOfMonth = currentDate.withDayOfMonth(currentDate.lengthOfMonth());
- LocalDate firstDayOfMonth = currentDate.withDayOfMonth(1);
- Boolean isBefore = currentDate.isAfter(lastDayOfMonth.minusDays(4));
- Boolean isInRange = currentDate.isBefore(firstDayOfMonth.plusDays(15));
- return isBefore || isInRange;
- }
-
public boolean overrideBingoTime() {
return overrideBingoTime;
}
@@ -187,14 +179,14 @@ public class Config implements Serializable {
return lastChatPromptAnswer;
}
- public boolean allowBBinviteMe() {
- return allowBBinviteMe;
- }
-
public void setLastChatPromptAnswer(String lastChatPromptAnswer) {
this.lastChatPromptAnswer = lastChatPromptAnswer;
}
+ public boolean allowBBinviteMe() {
+ return allowBBinviteMe;
+ }
+
public boolean hasBBRoles(String roleName) {
if (roleName == null) return true;
if (roleName.isEmpty()) return true;
diff --git a/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java b/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
index 7d593f9..59f5bee 100644
--- a/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
+++ b/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
@@ -134,7 +134,6 @@ public class BBsentialConnection {
// Create an SSL socket factory
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
socket = sslSocketFactory.createSocket(serverIP, serverPort);
-
socket.setKeepAlive(true); // Enable Keep-Alive
reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
writer = new PrintWriter(socket.getOutputStream(), true);
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 a0f04d2..4fea7fd 100644
--- a/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java
+++ b/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java
@@ -22,7 +22,7 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils {
}
public String getUsername() {
- return MinecraftClient.getInstance().player.getName().getString();
+ return MinecraftClient.getInstance().getSession().getUsername();
}
public String getMCUUID() {
diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java b/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java
index c94202b..3d3b42c 100644
--- a/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java
+++ b/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java
@@ -229,6 +229,7 @@ public class ModInitialiser implements ClientModInitializer {
public void onInitializeClient() {
EnvironmentCore core = new EnvironmentCore(new BBUtils(), new FabricChat(), new MCUtils(), new Commands(), new Options(), new DebugThread());
codes = new NumPadCodes();
+ BBsentials.init();
ClientPlayConnectionEvents.JOIN.register((a, b, c) -> {
BBsentials.onServerSwap();
});
diff --git a/forge/src/main/java/de/hype/bbsentials/forge/ExampleMod.java b/forge/src/main/java/de/hype/bbsentials/forge/ExampleMod.java
index 4e60e69..1202036 100644
--- a/forge/src/main/java/de/hype/bbsentials/forge/ExampleMod.java
+++ b/forge/src/main/java/de/hype/bbsentials/forge/ExampleMod.java
@@ -21,6 +21,7 @@ public class ExampleMod {
public void init(FMLInitializationEvent event) {
printLocation();
EnvironmentCore core = new EnvironmentCore(new BBUtils(), new ForgeChat(), new MCUtils(), new Commands(), new Options(), new DebugThread());
+ BBsentials.init();
MinecraftForge.EVENT_BUS.register(this);
}
public void printLocation() {
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 424eded..50c7c90 100644
--- a/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java
+++ b/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java
@@ -22,7 +22,7 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils {
}
public String getUsername() {
- return Minecraft.getMinecraft().thePlayer.getName();
+ return Minecraft.getMinecraft().getSession().getUsername();
}
public String getMCUUID() {
diff --git a/log4j2.xml b/log4j2.xml
new file mode 100644
index 0000000..294b37b
--- /dev/null
+++ b/log4j2.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="WARN">
+ <!-- Filter out Hypixel scoreboard and sound errors -->
+ <RegexFilter regex="Error executing task.*|Unable to play unknown soundEvent.*" onMatch="DENY"
+ onMismatch="NEUTRAL"/>
+</Configuration> \ No newline at end of file