From 4c265f18797284ce017a327675dcf0396265ce70 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 4 Feb 2016 15:03:52 +0100 Subject: [PATCH] Add an option to allow unlogged users to run all the commands Fix #456 --- .../fr/xephi/authme/listener/AuthMePlayerListener.java | 3 +++ src/main/java/fr/xephi/authme/settings/Settings.java | 7 ++++++- src/main/resources/config.yml | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 2e365e93..bae29ab7 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -108,6 +108,9 @@ public class AuthMePlayerListener implements Listener { if (Settings.useEssentialsMotd && cmd.equals("/motd")) { return; } + if(!Settings.isForcedRegistrationEnabled && Settings.allowAllCommandsIfRegIsOptional) { + return; + } if (Settings.allowCommands.contains(cmd)) { return; } diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index 005a922b..3fa43754 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -77,7 +77,7 @@ public final class Settings { enableProtection, enableAntiBot, recallEmail, useWelcomeMessage, broadcastWelcomeMessage, forceRegKick, forceRegLogin, checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect, - kickPlayersBeforeStopping, + kickPlayersBeforeStopping, allowAllCommandsIfRegIsOptional, customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase; public static String helpHeader, getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase, @@ -211,6 +211,7 @@ public final class Settings { isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true); reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true); + allowAllCommandsIfRegIsOptional = configFile.getBoolean("settings.restrictions.allowAllCommandsIfRegistrationIsOptional", false); allowCommands = new ArrayList<>(); allowCommands.addAll(Arrays.asList("/login", "/l", "/register", "/reg", "/email", "/captcha")); for (String cmd : configFile.getStringList("settings.restrictions.allowCommands")) { @@ -576,6 +577,10 @@ public final class Settings { set("settings.restrictions.enablePasswordVerifier", null); changes = true; } + if(!contains("settings.restrictions.allowAllCommandsIfRegistrationIsOptional")) { + set("settings.restrictions.allowAllCommandsIfRegistrationIsOptional", false); + changes = true; + } if (!contains("settings.security.unsafePasswords")) { List str = new ArrayList<>(); str.add("123456"); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d2e0a9e7..67fa18a4 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -67,6 +67,9 @@ settings: # Care that this feature blocks also all the commands not # listed in the list below. allowChat: false + # WARNING: use this only if you need it! + # Allow unlogged users to use all the commands if registration is not forced! + allowAllCommandsIfRegistrationIsOptional: false # Commands allowed when a player is not authenticated allowCommands: - /login