Fix the following issues:

1. HashMap non-thread-safe issus
2. Fix the same problem in pr621, but use a better implementation

Add the following functions:
1. There is now a language cache inside getLanguage to prepare for different languages corresponding to different time zones where the accounts in the server are located
This commit is contained in:
Secretboy-SMR
2022-05-09 17:30:51 +08:00
committed by Melledy
parent d179b5c7dc
commit 5a37acde2b
4 changed files with 22 additions and 12 deletions

View File

@@ -9,6 +9,7 @@ import java.time.temporal.TemporalAdjusters;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Locale;
import emu.grasscutter.Config;
import emu.grasscutter.Grasscutter;
@@ -306,4 +307,12 @@ public final class Utils {
return map;
}
/**
* get language code from Locale
*/
public static String getLanguageCode(Locale locale) {
return String.format("%s-%s", locale.getLanguage(), locale.getCountry());
}
}