#449 Migrate remaining non-group legacy Settings
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package fr.xephi.authme.util;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -15,14 +14,6 @@ public final class Utils {
|
||||
private Utils() {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isUnrestricted(Player player) {
|
||||
// TODO ljacqu 20160602: Checking for Settings.isAllowRestrictedIp is wrong! Nothing in the config suggests
|
||||
// that this setting has anything to do with unrestricted names
|
||||
return Settings.isAllowRestrictedIp
|
||||
&& Settings.getUnrestrictedName.contains(player.getName().toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get player's UUID if can, name otherwise.
|
||||
*
|
||||
|
||||
@@ -16,7 +16,9 @@ import org.bukkit.command.CommandSender;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
@@ -34,6 +36,7 @@ public class ValidationService implements Reloadable {
|
||||
private GeoLiteAPI geoLiteApi;
|
||||
|
||||
private Pattern passwordRegex;
|
||||
private Set<String> unrestrictedNames;
|
||||
|
||||
ValidationService() { }
|
||||
|
||||
@@ -41,6 +44,8 @@ public class ValidationService implements Reloadable {
|
||||
@Override
|
||||
public void reload() {
|
||||
passwordRegex = Utils.safePatternCompile(settings.getProperty(RestrictionSettings.ALLOWED_PASSWORD_REGEX));
|
||||
// Use Set for more efficient contains() lookup
|
||||
unrestrictedNames = new HashSet<>(settings.getProperty(RestrictionSettings.UNRESTRICTED_NAMES));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,6 +118,16 @@ public class ValidationService implements Reloadable {
|
||||
ProtectionSettings.COUNTRIES_BLACKLIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the name is unrestricted according to the configured settings.
|
||||
*
|
||||
* @param name the name to verify
|
||||
* @return true if unrestricted, false otherwise
|
||||
*/
|
||||
public boolean isUnrestricted(String name) {
|
||||
return unrestrictedNames.contains(name.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies whether the given value is allowed according to the given whitelist and blacklist settings.
|
||||
* Whitelist has precedence over blacklist: if a whitelist is set, the value is rejected if not present
|
||||
|
||||
Reference in New Issue
Block a user