Add unit tests for country validation
This commit is contained in:
@@ -157,15 +157,15 @@ class OnJoinVerifier implements Reloadable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the player's country is admitted if he is not registered.
|
||||
* Checks that the player's country is admitted.
|
||||
*
|
||||
* @param isAuthAvailable whether or not the user is registered
|
||||
* @param event the login event of the player
|
||||
* @param playerIp the ip address of the player
|
||||
*/
|
||||
public void checkPlayerCountry(boolean isAuthAvailable,
|
||||
PlayerLoginEvent event) throws FailedVerificationException {
|
||||
if ((!isAuthAvailable || settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED) ) && settings.getProperty(ProtectionSettings.ENABLE_PROTECTION)) {
|
||||
String playerIp = event.getAddress().getHostAddress();
|
||||
String playerIp) throws FailedVerificationException {
|
||||
if ((!isAuthAvailable || settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED))
|
||||
&& settings.getProperty(ProtectionSettings.ENABLE_PROTECTION)) {
|
||||
if (!validationService.isCountryAdmitted(playerIp)) {
|
||||
throw new FailedVerificationException(MessageKey.COUNTRY_BANNED_ERROR);
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ public class PlayerListener implements Listener {
|
||||
onJoinVerifier.checkAntibot(lowerName, isAuthAvailable);
|
||||
onJoinVerifier.checkKickNonRegistered(isAuthAvailable);
|
||||
onJoinVerifier.checkNameCasing(player, auth);
|
||||
onJoinVerifier.checkPlayerCountry(isAuthAvailable, event);
|
||||
onJoinVerifier.checkPlayerCountry(isAuthAvailable, event.getAddress().getHostAddress());
|
||||
} catch (FailedVerificationException e) {
|
||||
event.setKickMessage(m.retrieveSingle(e.getReason(), e.getArgs()));
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
|
||||
Reference in New Issue
Block a user