mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Fix issues with new Locale.
This commit is contained in:
parent
46622d7993
commit
6dea4ecb95
@ -25,7 +25,7 @@ public enum Settings {
|
||||
COMBINE_COMMAND_ALIASES_TO_MAIN_COMMAND("Customization.Data.CombineCommandAliasesToMainCommand"),
|
||||
SECURITY_IP_UUID("Settings.WebServer.Security.DisplayIPsAndUUIDs"),
|
||||
PLAYERLIST_SHOW_IMAGES("Customization.SmallHeadImagesOnAnalysisPlayerlist"),
|
||||
WRITE_NEW_LOCALE("WriteNewLocaleFileOnStart"),
|
||||
WRITE_NEW_LOCALE("Settings.WriteNewLocaleFileOnStart"),
|
||||
// Integer
|
||||
ANALYSIS_MINUTES_FOR_ACTIVE("Settings.Analysis.MinutesPlayedUntilConsidiredActive"),
|
||||
SAVE_CACHE_MIN("Settings.Cache.DataCache.SaveEveryXMinutes"),
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.ChatColor;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -42,10 +43,11 @@ public class Locale {
|
||||
messages = new HashMap<>();
|
||||
}
|
||||
|
||||
public void loadLocale() throws IOException {
|
||||
public void loadLocale() {
|
||||
String locale = Settings.LOCALE.toString().toUpperCase();
|
||||
Benchmark.start("Initializing locale");
|
||||
loadDefault();
|
||||
try {
|
||||
if (Settings.WRITE_NEW_LOCALE.isTrue()) {
|
||||
writeNewDefaultLocale();
|
||||
}
|
||||
@ -57,6 +59,10 @@ public class Locale {
|
||||
} else {
|
||||
loadFromResource("locale_" + locale + ".txt");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
|
||||
}
|
||||
Benchmark.stop("Enable", "Initializing locale");
|
||||
}
|
||||
|
||||
@ -68,9 +74,9 @@ public class Locale {
|
||||
.get().length() + 2;
|
||||
List<String> lines = messages.entrySet().stream()
|
||||
.sorted(new LocaleEntryComparator())
|
||||
.map(entry -> getSpacedIdentifier(entry.getKey().getIdentifier(), length) + "| " + entry.getValue().toString())
|
||||
.map(entry -> getSpacedIdentifier(entry.getKey().getIdentifier(), length) + "|| " + entry.getValue().toString())
|
||||
.collect(Collectors.toList());
|
||||
Files.write(new File(plugin.getDataFolder(), "locale.txt").toPath(), lines);
|
||||
Files.write(new File(plugin.getDataFolder(), "locale.txt").toPath(), lines, StandardCharsets.UTF_8);
|
||||
plugin.getConfig().set(Settings.WRITE_NEW_LOCALE.getPath(), false);
|
||||
}
|
||||
|
||||
@ -278,7 +284,7 @@ public class Locale {
|
||||
}
|
||||
|
||||
private void loadFromFile(File localeFile) throws IOException {
|
||||
loadFromContents(Files.lines(localeFile.toPath()).collect(Collectors.toList()), "Custom File");
|
||||
loadFromContents(Files.lines(localeFile.toPath(), StandardCharsets.UTF_8).collect(Collectors.toList()), "Custom File");
|
||||
}
|
||||
|
||||
private void loadFromResource(String fileName) {
|
||||
@ -297,7 +303,7 @@ public class Locale {
|
||||
Log.info("Using Locale: " + name);
|
||||
Map<String, Msg> identifiers = Msg.getIdentifiers();
|
||||
locale.forEach(line -> {
|
||||
String[] split = line.split(" \\| ");
|
||||
String[] split = line.split(" \\|\\| ");
|
||||
if (split.length == 2) {
|
||||
String identifier = split[0].trim();
|
||||
Msg msg = identifiers.get(identifier);
|
||||
|
Loading…
Reference in New Issue
Block a user