Skip to content

Commit

Permalink
Add defensive code to log an warning on YAML config issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Feb 8, 2024
1 parent 8217b37 commit 2d0d9ac
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,13 @@ private void serializeMap(Map<Object, Object> value, YamlConfiguration config, S
Map<Object, Object> result = new HashMap<>();
for (Entry<Object, Object> object : value.entrySet()) {
// Serialize all key and values
String key = (String)serialize(object.getKey());
key = key.replace("\\.", ":dot:");
result.put(key, serialize(object.getValue()));
if (serialize(object.getKey()) instanceof String key) {
key = key.replace("\\.", ":dot:");
result.put(key, serialize(object.getValue()));
} else {
plugin.logWarning("Map key in config file could not be serialized, skipping. Entry is "
+ object.getKey() + ": " + object.getValue());
}
}
// Save the list in the config file
config.set(storageLocation, result);
Expand Down

0 comments on commit 2d0d9ac

Please sign in to comment.