mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-01-15 04:41:33 +01:00
Add config option to allow invalid usernames (#516)
This commit is contained in:
parent
6e429d6c78
commit
ecfbed00b1
@ -70,6 +70,12 @@ use-server-uuids: true
|
|||||||
# in the LuckPerms cache.
|
# in the LuckPerms cache.
|
||||||
use-server-uuid-cache: false
|
use-server-uuid-cache: false
|
||||||
|
|
||||||
|
# If set to true, LuckPerms will allow usernames with non alphanumeric characters.
|
||||||
|
#
|
||||||
|
# Note that due to the design of the storage implementation, usernames must still be
|
||||||
|
# 16 characters or less.
|
||||||
|
allow-invalid-usernames: false
|
||||||
|
|
||||||
# If LuckPerms should produce extra logging output when it handles logins.
|
# If LuckPerms should produce extra logging output when it handles logins.
|
||||||
# Useful if you're having issues with UUID forwarding or data not being loaded.
|
# Useful if you're having issues with UUID forwarding or data not being loaded.
|
||||||
debug-logins: false
|
debug-logins: false
|
||||||
|
@ -73,6 +73,12 @@ use-server-uuids: true
|
|||||||
# try to find a uuid for a username using RedisBungee, if installed.
|
# try to find a uuid for a username using RedisBungee, if installed.
|
||||||
use-server-uuid-cache: false
|
use-server-uuid-cache: false
|
||||||
|
|
||||||
|
# If set to true, LuckPerms will allow usernames with non alphanumeric characters.
|
||||||
|
#
|
||||||
|
# Note that due to the design of the storage implementation, usernames must still be
|
||||||
|
# 16 characters or less.
|
||||||
|
allow-invalid-usernames: false
|
||||||
|
|
||||||
# If LuckPerms should produce extra logging output when it handles logins.
|
# If LuckPerms should produce extra logging output when it handles logins.
|
||||||
# Useful if you're having issues with UUID forwarding or data not being loaded.
|
# Useful if you're having issues with UUID forwarding or data not being loaded.
|
||||||
debug-logins: false
|
debug-logins: false
|
||||||
|
@ -73,10 +73,17 @@ public class LogRecent extends SubCommand<Log> {
|
|||||||
final String target = args.get(0);
|
final String target = args.get(0);
|
||||||
UUID uuid = Util.parseUuid(target.toLowerCase());
|
UUID uuid = Util.parseUuid(target.toLowerCase());
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
|
if (!plugin.getConfiguration().get(ConfigKeys.ALLOW_INVALID_USERNAMES)) {
|
||||||
if (!DataConstraints.PLAYER_USERNAME_TEST.test(target)) {
|
if (!DataConstraints.PLAYER_USERNAME_TEST.test(target)) {
|
||||||
Message.USER_INVALID_ENTRY.send(sender, target);
|
Message.USER_INVALID_ENTRY.send(sender, target);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (!DataConstraints.PLAYER_USERNAME_TEST_LENIENT.test(target)) {
|
||||||
|
Message.USER_INVALID_ENTRY.send(sender, target);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uuid = plugin.getStorage().getUUID(target.toLowerCase()).join();
|
uuid = plugin.getStorage().getUUID(target.toLowerCase()).join();
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
|
@ -68,22 +68,29 @@ public class LogUserHistory extends SubCommand<Log> {
|
|||||||
|
|
||||||
UUID uuid = Util.parseUuid(target.toLowerCase());
|
UUID uuid = Util.parseUuid(target.toLowerCase());
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
|
if (!plugin.getConfiguration().get(ConfigKeys.ALLOW_INVALID_USERNAMES)) {
|
||||||
if (!DataConstraints.PLAYER_USERNAME_TEST.test(target)) {
|
if (!DataConstraints.PLAYER_USERNAME_TEST.test(target)) {
|
||||||
Message.USER_INVALID_ENTRY.send(sender, target);
|
Message.USER_INVALID_ENTRY.send(sender, target);
|
||||||
return null;
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!DataConstraints.PLAYER_USERNAME_TEST_LENIENT.test(target)) {
|
||||||
|
Message.USER_INVALID_ENTRY.send(sender, target);
|
||||||
|
return CommandResult.INVALID_ARGS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uuid = plugin.getStorage().getUUID(target.toLowerCase()).join();
|
uuid = plugin.getStorage().getUUID(target.toLowerCase()).join();
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
if (!plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUID_CACHE)) {
|
if (!plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUID_CACHE)) {
|
||||||
Message.USER_NOT_FOUND.send(sender, target);
|
Message.USER_NOT_FOUND.send(sender, target);
|
||||||
return null;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
uuid = plugin.lookupUuid(target).orElse(null);
|
uuid = plugin.lookupUuid(target).orElse(null);
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
Message.USER_NOT_FOUND.send(sender, target);
|
Message.USER_NOT_FOUND.send(sender, target);
|
||||||
return null;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,10 +83,17 @@ public class UserMainCommand extends MainCommand<User, UserIdentifier> {
|
|||||||
protected UserIdentifier parseTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
protected UserIdentifier parseTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||||
UUID uuid = Util.parseUuid(target.toLowerCase());
|
UUID uuid = Util.parseUuid(target.toLowerCase());
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
|
if (!plugin.getConfiguration().get(ConfigKeys.ALLOW_INVALID_USERNAMES)) {
|
||||||
if (!DataConstraints.PLAYER_USERNAME_TEST.test(target)) {
|
if (!DataConstraints.PLAYER_USERNAME_TEST.test(target)) {
|
||||||
Message.USER_INVALID_ENTRY.send(sender, target);
|
Message.USER_INVALID_ENTRY.send(sender, target);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (!DataConstraints.PLAYER_USERNAME_TEST_LENIENT.test(target)) {
|
||||||
|
Message.USER_INVALID_ENTRY.send(sender, target);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uuid = plugin.getStorage().getUUID(target.toLowerCase()).join();
|
uuid = plugin.getStorage().getUUID(target.toLowerCase()).join();
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
|
@ -122,6 +122,11 @@ public class ConfigKeys {
|
|||||||
*/
|
*/
|
||||||
public static final ConfigKey<Boolean> USE_SERVER_UUID_CACHE = BooleanKey.of("use-server-uuid-cache", false);
|
public static final ConfigKey<Boolean> USE_SERVER_UUID_CACHE = BooleanKey.of("use-server-uuid-cache", false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If LuckPerms should allow usernames with non alphanumeric characters.
|
||||||
|
*/
|
||||||
|
public static final ConfigKey<Boolean> ALLOW_INVALID_USERNAMES = BooleanKey.of("allow-invalid-usernames", false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If LuckPerms should produce extra logging output when it handles logins.
|
* If LuckPerms should produce extra logging output when it handles logins.
|
||||||
*/
|
*/
|
||||||
|
@ -68,6 +68,14 @@ public class DataConstraints {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static final Predicate<String> PLAYER_USERNAME_TEST_LENIENT = s -> {
|
||||||
|
if (s.length() <= 0 || s.length() > MAX_PLAYER_USERNAME_LENGTH) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
public static final Predicate<String> GROUP_NAME_TEST = s -> {
|
public static final Predicate<String> GROUP_NAME_TEST = s -> {
|
||||||
if (s.length() <= 0 || s.length() > MAX_GROUP_NAME_LENGTH) {
|
if (s.length() <= 0 || s.length() > MAX_GROUP_NAME_LENGTH) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -69,6 +69,12 @@ use-server-uuids=true
|
|||||||
# in the LuckPerms cache.
|
# in the LuckPerms cache.
|
||||||
use-server-uuid-cache=false
|
use-server-uuid-cache=false
|
||||||
|
|
||||||
|
# If set to true, LuckPerms will allow usernames with non alphanumeric characters.
|
||||||
|
#
|
||||||
|
# Note that due to the design of the storage implementation, usernames must still be
|
||||||
|
# 16 characters or less.
|
||||||
|
allow-invalid-usernames=false
|
||||||
|
|
||||||
# If LuckPerms should produce extra logging output when it handles logins.
|
# If LuckPerms should produce extra logging output when it handles logins.
|
||||||
# Useful if you're having issues with UUID forwarding or data not being loaded.
|
# Useful if you're having issues with UUID forwarding or data not being loaded.
|
||||||
debug-logins=false
|
debug-logins=false
|
||||||
|
Loading…
Reference in New Issue
Block a user