Skip to content

Commit

Permalink
fixed not saving/loading
Browse files Browse the repository at this point in the history
  • Loading branch information
firef1a committed Jun 3, 2024
1 parent c34ed11 commit e22f45e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/main/java/dev/fire/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Config {
public boolean DebugMode = DefaultConfig.DebugMode;
public boolean VipEnabled = true;

public Map<String, MiniMessageChatTag> chatTags = convertToMinimessage(DefaultConfig.oldChatTags);
public Map<String, MiniMessageChatTag> chatTags = Map.copyOf(convertToMinimessage(DefaultConfig.oldChatTags));

public static Map<String, MiniMessageChatTag> convertToMinimessage(Map<String, ChatTag> map) {
Map<String, MiniMessageChatTag> new_map = new HashMap<String, MiniMessageChatTag>();
Expand All @@ -52,7 +52,7 @@ public static Map<String, MiniMessageChatTag> convertToMinimessage(Map<String, C
}
new_map.put(key, mmobj);
}
return new_map;
return Map.copyOf(new_map);
}

public Config() { }
Expand Down Expand Up @@ -86,18 +86,16 @@ public static Config getConfig() {
});

Map<String, MiniMessageChatTag> copy_chatmap = Map.copyOf(chattaghashmap);

if (copy_chatmap.size() != DefaultConfig.newChatTags.size()) {
throw new DfrevertException("Invalid Config!");
}
//instance.chatTags = copy_chatmap;
instance.chatTags = copy_chatmap;

// load primitives
instance.VipEnabled = object.get("VipEnabled").getAsBoolean();
instance.ShortenedChatTags = object.get("ShortenedChatTags").getAsBoolean();
instance.DisableMod = object.get("DisableMod").getAsBoolean();
instance.DebugMode = object.get("DebugMode").getAsBoolean();

DFrevert.LOGGER.info("Successfully loaded config!");

} catch (Exception exception) {
DFrevert.LOGGER.info("Config didn't load: " + exception);
DFrevert.LOGGER.info("Making a new one.");
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/dev/fire/utils/MiniMessageChatTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.google.gson.JsonObject;
import net.minecraft.text.*;

public class MiniMessageChatTag {
import java.io.Serializable;

public class MiniMessageChatTag implements Serializable {
public String mainvalue;
public String leftvalue;
public String rightvalue;
Expand Down

0 comments on commit e22f45e

Please sign in to comment.