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:
Gabriele C
2017-08-31 19:36:57 +02:00
committed by GitHub
parent b96ae61697
commit 6b875a9ba4
7 changed files with 39 additions and 25 deletions
@@ -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.