Skip to content

Commit 5c76f21

Browse files
Fixed potential problems with fonts
1 parent cc88dd0 commit 5c76f21

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ org.gradle.jvmargs=-Xmx2G
44
# Fabric Properties
55
minecraft_version=1.21.5
66
yarn_version=1.21.5+build.1
7-
loader_version=0.16.10
7+
loader_version=0.16.14
88

99
# Mod Properties
1010
mod_version = 0.3
1111
maven_group = anticope.rejects
1212
archives_base_name = meteor-rejects-addon
1313

14-
baritone_version=1.21.4
14+
baritone_version=1.21.5

src/main/java/anticope/rejects/utils/RejectsConfig.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,32 @@ public NbtCompound toTag() {
8080

8181
@Override
8282
public RejectsConfig fromTag(NbtCompound tag) {
83-
// Clean the "httpAllowed" string in case it's wrapped in Optional
84-
String httpAllowedString = String.valueOf(tag.getString("httpAllowed"));
85-
if (httpAllowedString.startsWith("Optional[")) {
86-
httpAllowedString = httpAllowedString.substring(9, httpAllowedString.length() - 1); // Strip "Optional[" and "]"
83+
// Get the "httpAllowed" string safely
84+
String httpAllowedString = "Everything";
85+
if (tag.contains("httpAllowed")) {
86+
NbtElement httpAllowedElement = tag.get("httpAllowed");
87+
if (httpAllowedElement != null) {
88+
httpAllowedString = String.valueOf(httpAllowedElement.asString());
89+
// Remove quotes if present (asString() may wrap in quotes)
90+
if (httpAllowedString.startsWith("\"") && httpAllowedString.endsWith("\"")) {
91+
httpAllowedString = httpAllowedString.substring(1, httpAllowedString.length() - 1);
92+
}
93+
if (httpAllowedString.startsWith("Optional[")) {
94+
httpAllowedString = httpAllowedString.substring(9, httpAllowedString.length() - 1);
95+
}
96+
}
8797
}
8898

8999
try {
90-
// Convert the cleaned string to the HttpAllowed enum
91100
httpAllowed = HttpAllowed.valueOf(httpAllowedString);
92101
} catch (IllegalArgumentException e) {
93-
// Handle invalid enum value (optional)
94102
java.lang.System.err.println("Invalid value for httpAllowed: " + httpAllowedString);
95-
httpAllowed = HttpAllowed.Everything; // Default to Everything in case of error
103+
httpAllowed = HttpAllowed.Everything;
96104
}
97105

98-
httpUserAgent = String.valueOf(tag.getString("httpUserAgent"));
99-
loadSystemFonts = Boolean.parseBoolean(String.valueOf(tag.getBoolean("loadSystemFonts")));
100-
duplicateModuleNames = Boolean.parseBoolean(String.valueOf(tag.getBoolean("duplicateModuleNames")));
106+
httpUserAgent = tag.contains("httpUserAgent") ? String.valueOf(tag.getString("httpUserAgent")) : "Meteor Client";
107+
loadSystemFonts = tag.contains("loadSystemFonts") && tag.getBoolean("loadSystemFonts").orElse(false);
108+
duplicateModuleNames = tag.contains("duplicateModuleNames") && tag.getBoolean("duplicateModuleNames").orElse(false);
101109

102110
NbtList valueTag = tag.getListOrEmpty("hiddenModules");
103111
for (NbtElement tagI : valueTag) {
@@ -106,5 +114,4 @@ public RejectsConfig fromTag(NbtCompound tag) {
106114

107115
return this;
108116
}
109-
110117
}

0 commit comments

Comments
 (0)