Don't check the country if nothing defined on configuration.

- no need to enable protection to use country blacklist. #507
This commit is contained in:
DNx5 2016-02-18 09:34:04 +07:00
parent fbdd56d9de
commit 481cbaec2f
2 changed files with 24 additions and 22 deletions

View File

@ -12,7 +12,6 @@ import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerPermission;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.GeoLiteAPI;
@ -109,7 +108,7 @@ public class AuthMePlayerListener implements Listener {
if (Settings.useEssentialsMotd && cmd.equals("/motd")) {
return;
}
if(!Settings.isForcedRegistrationEnabled && Settings.allowAllCommandsIfRegIsOptional) {
if (!Settings.isForcedRegistrationEnabled && Settings.allowAllCommandsIfRegIsOptional) {
return;
}
if (Settings.allowCommands.contains(cmd)) {
@ -255,18 +254,20 @@ public class AuthMePlayerListener implements Listener {
}
}
String playerIP = event.getAddress().getHostAddress();
if (auth == null && Settings.enableProtection) {
String countryCode = GeoLiteAPI.getCountryCode(playerIP);
if (!Settings.countriesBlacklist.isEmpty() && Settings.countriesBlacklist.contains(countryCode)) {
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
return;
}
if (!Settings.countries.isEmpty() && !Settings.countries.contains(countryCode)) {
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
return;
if (auth == null) {
if (!Settings.countriesBlacklist.isEmpty() || !Settings.countries.isEmpty()) {
String playerIP = event.getAddress().getHostAddress();
String countryCode = GeoLiteAPI.getCountryCode(playerIP);
if (Settings.countriesBlacklist.contains(countryCode)) {
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
return;
}
if (Settings.enableProtection && !Settings.countries.contains(countryCode)) {
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
return;
}
}
}

View File

@ -32,14 +32,15 @@ public class AuthMeServerListener implements Listener {
return;
}
String countryCode = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
if (!Settings.countriesBlacklist.isEmpty() && Settings.countriesBlacklist.contains(countryCode)) {
event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
return;
}
if (!Settings.countries.isEmpty() && !Settings.countries.contains(countryCode)) {
event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
if (!Settings.countriesBlacklist.isEmpty() || !Settings.countries.isEmpty()){
String countryCode = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
if( Settings.countriesBlacklist.contains(countryCode)) {
event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
return;
}
if (!Settings.countries.contains(countryCode)) {
event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
}
}
}