mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-03-17 17:09:54 +01:00
Handle country blacklist effectively
This commit is contained in:
parent
37b24d4e72
commit
2fdd5ef325
src/main/java/fr/xephi/authme/listener
@ -204,6 +204,20 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.enableProtection) {
|
||||
String countryCode = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
final String name = event.getName().toLowerCase();
|
||||
final Player player = Utils.getPlayer(name);
|
||||
if (player == null) {
|
||||
@ -263,24 +277,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
final String name = player.getName().toLowerCase();
|
||||
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
||||
|
||||
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, UserPermission.BYPASS_ANTIBOT)) {
|
||||
String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
||||
if (Settings.countriesBlacklist.contains(code)) {
|
||||
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, UserPermission.BYPASS_ANTIBOT)) {
|
||||
String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
||||
if (!Settings.countries.contains(code)) {
|
||||
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add message to the messages file!!!
|
||||
if (Settings.isKickNonRegisteredEnabled && !isAuthAvailable) {
|
||||
if (Settings.antiBotInAction) {
|
||||
|
@ -43,19 +43,13 @@ public class AuthMeServerListener implements Listener {
|
||||
}
|
||||
|
||||
String countryCode = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
||||
if (!Settings.countriesBlacklist.isEmpty()) {
|
||||
if (Settings.countriesBlacklist.contains(countryCode)) {
|
||||
event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
||||
return;
|
||||
}
|
||||
if (!Settings.countriesBlacklist.isEmpty() && Settings.countriesBlacklist.contains(countryCode)) {
|
||||
event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Settings.countries.isEmpty()) {
|
||||
if (Settings.countries.contains(countryCode)) {
|
||||
event.setMotd(plugin.getServer().getMotd());
|
||||
} else {
|
||||
event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
||||
}
|
||||
if (!Settings.countries.isEmpty() && !Settings.countries.contains(countryCode)) {
|
||||
event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user