Add option to apply the protection also to registered users #860

This commit is contained in:
Gabriele C 2016-07-16 21:10:29 +02:00
parent 674a051586
commit b439a0391c
5 changed files with 7 additions and 6 deletions

View File

@ -164,7 +164,7 @@ class OnJoinVerifier implements Reloadable {
*/
public void checkPlayerCountry(boolean isAuthAvailable,
PlayerLoginEvent event) throws FailedVerificationException {
if (!isAuthAvailable && settings.getProperty(ProtectionSettings.ENABLE_PROTECTION)) {
if ((!isAuthAvailable || settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED) ) && settings.getProperty(ProtectionSettings.ENABLE_PROTECTION)) {
String playerIp = event.getAddress().getHostAddress();
if (!validationService.isCountryAdmitted(playerIp)) {
throw new FailedVerificationException(MessageKey.COUNTRY_BANNED_ERROR);

View File

@ -11,7 +11,6 @@ import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SyncProcessManager;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.Utils;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -41,9 +40,6 @@ public class AsynchronousQuit implements AsynchronousProcess {
@Inject
private SpawnLoader spawnLoader;
@Inject
private BukkitService bukkitService;
AsynchronousQuit() {
}

View File

@ -16,6 +16,10 @@ public class ProtectionSettings implements SettingsClass {
public static final Property<Boolean> ENABLE_PROTECTION =
newProperty("Protection.enableProtection", false);
@Comment("Apply the protection also to registered usernames")
public static final Property<Boolean> ENABLE_PROTECTION_REGISTERED =
newProperty("Protection.enableProtectionRegistered", true);
@Comment({"Countries allowed to join the server and register, see http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/ for countries' codes",
"PLEASE USE QUOTES!"})
public static final Property<List<String>> COUNTRIES_WHITELIST =

View File

@ -410,6 +410,8 @@ Purge:
Protection:
# Enable some servers protection ( country based login, antibot )
enableProtection: false
# Apply the protection also to registered usernames
enableProtectionRegistered: true
# Countries allowed to join the server and register, see http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/ for countries' codes
# PLEASE USE QUOTES!
countries:

View File

@ -90,7 +90,6 @@ public class SessionManagerTest {
}
@Test
@SuppressWarnings("unchecked")
public void shouldDenySessionIfTimeoutHasExpired() {
// given
int timeout = 20;