mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 08:56:04 +01:00
add /language command (#780)
* 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 * add /language command,each account has their own Locate
This commit is contained in:
@@ -8,6 +8,7 @@ import emu.grasscutter.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
@@ -28,10 +29,12 @@ public class Account {
|
||||
private String token;
|
||||
private String sessionKey; // Session token for dispatch server
|
||||
private List<String> permissions;
|
||||
private Locale locale;
|
||||
|
||||
@Deprecated
|
||||
public Account() {
|
||||
this.permissions = new ArrayList<>();
|
||||
this.locale = Grasscutter.getConfig().LocaleLanguage;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
@@ -96,6 +99,14 @@ public class Account {
|
||||
return this.sessionKey;
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* The collection of a player's permissions.
|
||||
*/
|
||||
@@ -166,5 +177,10 @@ public class Account {
|
||||
if (!document.containsKey("permissions")) {
|
||||
this.addPermission("*");
|
||||
}
|
||||
|
||||
// Set account default language as server default language
|
||||
if (!document.containsKey("locale")) {
|
||||
this.locale = Grasscutter.getConfig().LocaleLanguage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user