@@ -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