Add permission to bypass country check (#1323)
* Add permission to bypass country check #1321 Still need to fix unit tests * Fix test
This commit is contained in:
@@ -168,15 +168,15 @@ public class OnJoinVerifier implements Reloadable {
|
||||
/**
|
||||
* Checks that the player's country is admitted.
|
||||
*
|
||||
* @param player the player
|
||||
* @param isAuthAvailable whether or not the user is registered
|
||||
* @param playerIp the ip address of the player
|
||||
* @throws FailedVerificationException if the verification fails
|
||||
*/
|
||||
public void checkPlayerCountry(boolean isAuthAvailable,
|
||||
String playerIp) throws FailedVerificationException {
|
||||
public void checkPlayerCountry(Player player, boolean isAuthAvailable) throws FailedVerificationException {
|
||||
if ((!isAuthAvailable || settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED))
|
||||
&& settings.getProperty(ProtectionSettings.ENABLE_PROTECTION)
|
||||
&& !validationService.isCountryAdmitted(playerIp)) {
|
||||
&& !permissionsManager.hasPermission(player, PlayerStatePermission.BYPASS_COUNTRY_CHECK)
|
||||
&& !validationService.isCountryAdmitted(player.getAddress().getAddress().getHostAddress())) {
|
||||
throw new FailedVerificationException(MessageKey.COUNTRY_BANNED_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ public class PlayerListener implements Listener {
|
||||
onJoinVerifier.checkKickNonRegistered(isAuthAvailable);
|
||||
onJoinVerifier.checkAntibot(player, isAuthAvailable);
|
||||
onJoinVerifier.checkNameCasing(player, auth);
|
||||
onJoinVerifier.checkPlayerCountry(isAuthAvailable, event.getAddress().getHostAddress());
|
||||
onJoinVerifier.checkPlayerCountry(player, isAuthAvailable);
|
||||
} catch (FailedVerificationException e) {
|
||||
event.setKickMessage(m.retrieveSingle(e.getReason(), e.getArgs()));
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
|
||||
@@ -29,7 +29,12 @@ public enum PlayerStatePermission implements PermissionNode {
|
||||
/**
|
||||
* Permission to bypass the purging process.
|
||||
*/
|
||||
BYPASS_PURGE("authme.bypasspurge", DefaultPermission.NOT_ALLOWED);
|
||||
BYPASS_PURGE("authme.bypasspurge", DefaultPermission.NOT_ALLOWED),
|
||||
|
||||
/**
|
||||
* Permission to use to see own other accounts.
|
||||
*/
|
||||
BYPASS_COUNTRY_CHECK("authme.bypasscountrycheck", DefaultPermission.NOT_ALLOWED);
|
||||
|
||||
/**
|
||||
* The permission node.
|
||||
|
||||
@@ -154,6 +154,9 @@ permissions:
|
||||
authme.bypassantibot:
|
||||
description: Permission node to bypass AntiBot protection.
|
||||
default: op
|
||||
authme.bypasscountrycheck:
|
||||
description: Permission to use to see own other accounts.
|
||||
default: false
|
||||
authme.bypassforcesurvival:
|
||||
description: Permission for users to bypass force-survival mode.
|
||||
default: op
|
||||
|
||||
Reference in New Issue
Block a user