Fix conversion of old placeholders with dots in them

This commit is contained in:
filoghost 2021-03-11 17:40:20 +01:00
parent 65a54165eb
commit 5371acfd2c
2 changed files with 11 additions and 6 deletions

View File

@ -6,12 +6,15 @@
package me.filoghost.holographicdisplays.disk;
import me.filoghost.fcommons.Colors;
import me.filoghost.fcommons.config.ConfigPath;
import me.filoghost.fcommons.config.ConfigSection;
import me.filoghost.fcommons.config.ConfigType;
import me.filoghost.fcommons.config.FileConfig;
import me.filoghost.fcommons.logging.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
public class CustomPlaceholders {
@ -25,11 +28,9 @@ public class CustomPlaceholders {
return;
}
for (String placeholder : placeholdersSection.getKeys()) {
String replacement = Colors.addColors(placeholdersSection.getString(placeholder));
if (replacement == null) {
return;
}
for (Entry<ConfigPath, String> entry : placeholdersSection.toMap(ConfigType.STRING).entrySet()) {
String placeholder = entry.getKey().asRawKey();
String replacement = Colors.addColors(entry.getValue());
if (placeholder.length() == 0) {
Log.warning("Error in \"" + config.getSourceFile() + "\": placeholder cannot be empty (skipped).");

View File

@ -9,6 +9,8 @@ import me.filoghost.fcommons.Strings;
import me.filoghost.fcommons.config.Config;
import me.filoghost.fcommons.config.ConfigErrors;
import me.filoghost.fcommons.config.ConfigLoader;
import me.filoghost.fcommons.config.ConfigPath;
import me.filoghost.fcommons.config.ConfigSection;
import me.filoghost.fcommons.config.exception.ConfigLoadException;
import me.filoghost.fcommons.config.exception.ConfigSaveException;
import me.filoghost.fcommons.logging.Log;
@ -36,6 +38,8 @@ public class LegacySymbolsUpgrader {
}
Config newConfig = new Config();
ConfigSection placeholdersSection = newConfig.getOrCreateSection("placeholders");
List<String> lines;
try {
lines = Files.readAllLines(oldFile);
@ -59,7 +63,7 @@ public class LegacySymbolsUpgrader {
String placeholder = unquote(parts[0]);
String replacement = StringEscapeUtils.unescapeJava(unquote(parts[1]));
newConfig.setString("placeholders." + placeholder, replacement);
placeholdersSection.setString(ConfigPath.literal(placeholder), replacement);
}
try {