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