mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-11-09 12:30:03 +01:00
Localized provider using country ISO standard codes instead of country names
This commit is contained in:
parent
36d9eeff13
commit
fe2f7f22ce
@ -42,20 +42,20 @@ public enum ProviderType {
|
|||||||
InetAddress address = player.getAddress().getAddress();
|
InetAddress address = player.getAddress().getAddress();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CountryResponse countryResponse = plugin.getGeolocationManager().getReader().country(address);
|
CountryResponse response = plugin.getGeolocationManager().getReader().country(address);
|
||||||
Country country = countryResponse.getCountry();
|
Country country = response.getCountry();
|
||||||
|
|
||||||
if (ConfigEntries.GEOLOCATION_PRINT_INFO.get()) {
|
if (ConfigEntries.GEOLOCATION_PRINT_INFO.get()) {
|
||||||
plugin.getLogger().info(String.format(
|
plugin.getLogger().info(String.format(
|
||||||
"Player Address: \"%s\", Country Name: \"%s\"",
|
"Player Address: \"%s\", Country Code: \"%s\"",
|
||||||
address.toString(),
|
address.toString(),
|
||||||
country.getName()
|
country.getIsoCode()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String name : rule.getKeys()) {
|
for (String name : rule.getKeys()) {
|
||||||
List<String> countries = rule.getStringList(name);
|
List<String> countries = rule.getStringList(name);
|
||||||
if (countries.contains(country.getName())) {
|
if (countries.contains(country.getIsoCode())) {
|
||||||
ServerInfo server = plugin.getProxy().getServerInfo(name);
|
ServerInfo server = plugin.getProxy().getServerInfo(name);
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
return server;
|
return server;
|
||||||
|
@ -93,7 +93,7 @@ settings:
|
|||||||
rules: {}
|
rules: {}
|
||||||
|
|
||||||
# This gets the country of a player and decides to which server the player should go
|
# This gets the country of a player and decides to which server the player should go
|
||||||
# Country codes: http://dev.maxmind.com/geoip/legacy/codes/iso3166/
|
# Country ISO codes: http://dev.maxmind.com/geoip/legacy/codes/iso3166/
|
||||||
# WARNING: In testing stage
|
# WARNING: In testing stage
|
||||||
geolocation:
|
geolocation:
|
||||||
# If disabled the localized provider will choose a random server
|
# If disabled the localized provider will choose a random server
|
||||||
|
Loading…
Reference in New Issue
Block a user