mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-27 13:15:44 +01:00
Fix toLowerCase/toUpperCase locale sensitivity
This commit is contained in:
parent
062fca3f75
commit
9cd33d26f2
@ -31,6 +31,8 @@ import net.luckperms.api.node.types.SuffixNode;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Represents a type of chat meta
|
||||
*/
|
||||
@ -70,7 +72,7 @@ public enum ChatMetaType {
|
||||
private final NodeType<? extends ChatMetaNode<?, ?>> nodeType;
|
||||
|
||||
ChatMetaType(NodeType<? extends ChatMetaNode<?, ?>> nodeType) {
|
||||
this.name = nodeType.name().toLowerCase();
|
||||
this.name = nodeType.name().toLowerCase(Locale.ROOT);
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ package net.luckperms.api.node.metadata;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
final class SimpleNodeMetadataKey<T> implements NodeMetadataKey<T> {
|
||||
@ -34,7 +35,7 @@ final class SimpleNodeMetadataKey<T> implements NodeMetadataKey<T> {
|
||||
private final Class<T> type;
|
||||
|
||||
SimpleNodeMetadataKey(String name, Class<T> type) {
|
||||
this.name = name.toLowerCase();
|
||||
this.name = name.toLowerCase(Locale.ROOT);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ package net.luckperms.api.query;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
final class SimpleOptionKey<T> implements OptionKey<T> {
|
||||
@ -35,7 +36,7 @@ final class SimpleOptionKey<T> implements OptionKey<T> {
|
||||
private final int hashCode;
|
||||
|
||||
SimpleOptionKey(String name, Class<T> type) {
|
||||
this.name = name.toLowerCase();
|
||||
this.name = name.toLowerCase(Locale.ROOT);
|
||||
this.type = type;
|
||||
this.hashCode = Objects.hash(this.name, this.type); // cache hashcode
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@ -239,7 +240,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
Objects.requireNonNull(name, "name is null");
|
||||
Preconditions.checkArgument(!name.isEmpty(), "name is empty");
|
||||
|
||||
String permission = name.toLowerCase();
|
||||
String permission = name.toLowerCase(Locale.ROOT);
|
||||
|
||||
Boolean previous = this.perms.put(permission, value);
|
||||
if (previous != null && previous == value) {
|
||||
@ -264,7 +265,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
Objects.requireNonNull(name, "name is null");
|
||||
Preconditions.checkArgument(!name.isEmpty(), "name is empty");
|
||||
|
||||
String permission = name.toLowerCase();
|
||||
String permission = name.toLowerCase(Locale.ROOT);
|
||||
|
||||
Boolean previous = this.perms.remove(permission);
|
||||
if (previous == null) {
|
||||
|
@ -43,6 +43,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -140,7 +141,7 @@ public final class LuckPermsDefaultsMap implements Map<Boolean, Set<Permission>>
|
||||
protected @NonNull Map<String, Boolean> supply() {
|
||||
Map<String, Boolean> builder = new HashMap<>();
|
||||
for (Permission perm : LuckPermsDefaultsMap.this.get(this.op)) {
|
||||
String name = perm.getName().toLowerCase();
|
||||
String name = perm.getName().toLowerCase(Locale.ROOT);
|
||||
builder.put(name, true);
|
||||
for (Map.Entry<String, Boolean> child : LuckPermsDefaultsMap.this.plugin.getPermissionMap().getChildPermissions(name, true).entrySet()) {
|
||||
builder.putIfAbsent(child.getKey(), child.getValue());
|
||||
|
@ -40,6 +40,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -180,7 +181,7 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
||||
continue;
|
||||
}
|
||||
|
||||
String key = e.getKey().toLowerCase();
|
||||
String key = e.getKey().toLowerCase(Locale.ROOT);
|
||||
|
||||
if (accumulator.containsKey(key)) {
|
||||
continue; // Prevent infinite loops
|
||||
|
@ -38,6 +38,7 @@ import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class BukkitPlatformListener implements Listener {
|
||||
@ -51,17 +52,17 @@ public class BukkitPlatformListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
|
||||
handleCommand(e.getPlayer(), e.getMessage().toLowerCase(), e);
|
||||
handleCommand(e.getPlayer(), e.getMessage().toLowerCase(Locale.ROOT), e);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onServerCommand(ServerCommandEvent e) {
|
||||
handleCommand(e.getSender(), e.getCommand().toLowerCase(), e);
|
||||
handleCommand(e.getSender(), e.getCommand().toLowerCase(Locale.ROOT), e);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onRemoteServerCommand(RemoteServerCommandEvent e) {
|
||||
handleCommand(e.getSender(), e.getCommand().toLowerCase(), e);
|
||||
handleCommand(e.getSender(), e.getCommand().toLowerCase(Locale.ROOT), e);
|
||||
}
|
||||
|
||||
private void handleCommand(CommandSender sender, String cmdLine, Cancellable event) {
|
||||
|
@ -49,6 +49,7 @@ import net.luckperms.api.query.Flag;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -254,7 +255,7 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
|
||||
|
||||
private void setMeta(PermissionHolder holder, String key, Object value, String world) {
|
||||
if (key.equalsIgnoreCase(Prefix.NODE_KEY) || key.equalsIgnoreCase(Suffix.NODE_KEY)) {
|
||||
setChatMeta(holder, ChatMetaType.valueOf(key.toUpperCase()), value == null ? null : value.toString(), world);
|
||||
setChatMeta(holder, ChatMetaType.valueOf(key.toUpperCase(Locale.ROOT)), value == null ? null : value.toString(), world);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -277,7 +278,7 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
|
||||
private QueryOptions createQueryOptionsForWorldSet(String world) {
|
||||
ImmutableContextSet.Builder context = new ImmutableContextSetImpl.BuilderImpl();
|
||||
if (world != null && !world.isEmpty() && !world.equalsIgnoreCase("global")) {
|
||||
context.add(DefaultContextKeys.WORLD_KEY, world.toLowerCase());
|
||||
context.add(DefaultContextKeys.WORLD_KEY, world.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
context.add(DefaultContextKeys.SERVER_KEY, this.vaultPermission.getVaultServer());
|
||||
|
||||
|
@ -59,6 +59,7 @@ import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@ -348,7 +349,7 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
|
||||
// remove already accumulated worlds
|
||||
context.removeAll(DefaultContextKeys.WORLD_KEY);
|
||||
// add the vault world
|
||||
context.add(DefaultContextKeys.WORLD_KEY, world.toLowerCase());
|
||||
context.add(DefaultContextKeys.WORLD_KEY, world.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
// if we're using a special vault server
|
||||
|
@ -47,6 +47,7 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@ -126,10 +127,10 @@ public class LoggedAction implements Action {
|
||||
}
|
||||
|
||||
public boolean matchesSearch(String query) {
|
||||
query = Objects.requireNonNull(query, "query").toLowerCase();
|
||||
return this.source.name.toLowerCase().contains(query) ||
|
||||
this.target.name.toLowerCase().contains(query) ||
|
||||
this.description.toLowerCase().contains(query);
|
||||
query = Objects.requireNonNull(query, "query").toLowerCase(Locale.ROOT);
|
||||
return this.source.name.toLowerCase(Locale.ROOT).contains(query) ||
|
||||
this.target.name.toLowerCase(Locale.ROOT).contains(query) ||
|
||||
this.description.toLowerCase(Locale.ROOT).contains(query);
|
||||
}
|
||||
|
||||
public void submit(LuckPermsPlugin plugin, Sender sender) {
|
||||
|
@ -31,6 +31,7 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.storage.misc.DataConstraints;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public final class ApiUtils {
|
||||
@ -55,7 +56,7 @@ public final class ApiUtils {
|
||||
}
|
||||
|
||||
Preconditions.checkArgument(DataConstraints.GROUP_NAME_TEST.test(s), "Invalid name entry: " + s);
|
||||
return s.toLowerCase();
|
||||
return s.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -83,11 +84,11 @@ public class ApiUser extends ApiPermissionHolder implements net.luckperms.api.mo
|
||||
return DataMutateResult.FAIL_ALREADY_HAS;
|
||||
}
|
||||
|
||||
if (!this.handle.hasNode(DataType.NORMAL, Inheritance.builder(group.toLowerCase()).build(), NodeEqualityPredicate.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean()) {
|
||||
if (!this.handle.hasNode(DataType.NORMAL, Inheritance.builder(group.toLowerCase(Locale.ROOT)).build(), NodeEqualityPredicate.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean()) {
|
||||
return DataMutateResult.FAIL;
|
||||
}
|
||||
|
||||
this.handle.getPrimaryGroup().setStoredValue(group.toLowerCase());
|
||||
this.handle.getPrimaryGroup().setStoredValue(group.toLowerCase(Locale.ROOT));
|
||||
return DataMutateResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -167,7 +168,7 @@ public class Importer implements Runnable {
|
||||
for (JsonElement holderElement : holdersArray) {
|
||||
JsonObject jsonData = holderElement.getAsJsonObject();
|
||||
|
||||
HolderType type = HolderType.valueOf(jsonData.get("type").getAsString().toUpperCase());
|
||||
HolderType type = HolderType.valueOf(jsonData.get("type").getAsString().toUpperCase(Locale.ROOT));
|
||||
String id = jsonData.get("id").getAsString();
|
||||
|
||||
if (type == HolderType.GROUP) {
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
package me.lucko.luckperms.common.bulkupdate.query;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Represents a field being used in an update
|
||||
*/
|
||||
@ -38,7 +40,7 @@ public enum QueryField {
|
||||
|
||||
public static QueryField of(String s) {
|
||||
try {
|
||||
return valueOf(s.toUpperCase());
|
||||
return valueOf(s.toUpperCase(Locale.ROOT));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.SortedMap;
|
||||
@ -108,7 +109,7 @@ public class SimpleMetaCache extends UsageTracked implements CachedMetaData {
|
||||
|
||||
public String getMetaValue(String key, MetaCheckEvent.Origin origin) {
|
||||
Objects.requireNonNull(key, "key");
|
||||
return this.flattenedMeta.get(key.toLowerCase());
|
||||
return this.flattenedMeta.get(key.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -205,7 +206,7 @@ public class SimpleMetaCache extends UsageTracked implements CachedMetaData {
|
||||
}
|
||||
|
||||
String key = (String) k;
|
||||
return super.get(key.toLowerCase());
|
||||
return super.get(key.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ import net.luckperms.api.query.meta.MetaValueSelector;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class SimpleMetaValueSelector implements MetaValueSelector {
|
||||
@ -81,7 +82,7 @@ public class SimpleMetaValueSelector implements MetaValueSelector {
|
||||
|
||||
public static Strategy parse(String s) {
|
||||
try {
|
||||
return Strategy.valueOf(s.replace('-', '_').toUpperCase());
|
||||
return Strategy.valueOf(s.replace('-', '_').toUpperCase(Locale.ROOT));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@ -85,7 +86,7 @@ public class PermissionCalculator implements Function<String, TristateResult> {
|
||||
public TristateResult apply(@NonNull String permission) {
|
||||
// convert the permission to lowercase, as all values in the backing map are also lowercase.
|
||||
// this allows fast case insensitive lookups
|
||||
permission = permission.toLowerCase();
|
||||
permission = permission.toLowerCase(Locale.ROOT);
|
||||
|
||||
// offer the permission to the permission vault
|
||||
// we only need to do this once per permission, so it doesn't matter
|
||||
|
@ -75,6 +75,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@ -130,7 +131,7 @@ public class CommandManager {
|
||||
.add(new ListTracks())
|
||||
.build()
|
||||
.stream()
|
||||
.collect(ImmutableCollectors.toMap(c -> c.getName().toLowerCase(), Function.identity()));
|
||||
.collect(ImmutableCollectors.toMap(c -> c.getName().toLowerCase(Locale.ROOT), Function.identity()));
|
||||
}
|
||||
|
||||
public LuckPermsPlugin getPlugin() {
|
||||
@ -235,7 +236,7 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
// Look for the main command.
|
||||
Command<?> main = this.mainCommands.get(arguments.get(0).toLowerCase());
|
||||
Command<?> main = this.mainCommands.get(arguments.get(0).toLowerCase(Locale.ROOT));
|
||||
|
||||
// Main command not found
|
||||
if (main == null) {
|
||||
@ -276,7 +277,7 @@ public class CommandManager {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return TabCompleter.create()
|
||||
.at(0, CompletionSupplier.startsWith(() -> mains.stream().map(c -> c.getName().toLowerCase())))
|
||||
.at(0, CompletionSupplier.startsWith(() -> mains.stream().map(c -> c.getName().toLowerCase(Locale.ROOT))))
|
||||
.from(1, partial -> mains.stream()
|
||||
.filter(m -> m.getName().equalsIgnoreCase(arguments.get(0)))
|
||||
.findFirst()
|
||||
@ -333,7 +334,7 @@ public class CommandManager {
|
||||
// '/lp user Luck p set --> /lp user Luck permission set' etc
|
||||
// ^ ^^^^^^^^^^
|
||||
if (args.size() >= 3 && (rewriteLastArgument || args.size() >= 4)) {
|
||||
String arg0 = args.get(0).toLowerCase();
|
||||
String arg0 = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (arg0.equals("user") || arg0.equals("group")) {
|
||||
replaceArgs(args, 2, arg -> {
|
||||
switch (arg) {
|
||||
@ -353,7 +354,7 @@ public class CommandManager {
|
||||
// '/lp user Luck permission i' --> '/lp user Luck permission info' etc
|
||||
// ^ ^^^^
|
||||
if (args.size() >= 4 && (rewriteLastArgument || args.size() >= 5)) {
|
||||
String arg2 = args.get(2).toLowerCase();
|
||||
String arg2 = args.get(2).toLowerCase(Locale.ROOT);
|
||||
if (arg2.equals("permission") || arg2.equals("parent") || arg2.equals("meta")) {
|
||||
replaceArgs(args, 3, arg -> arg.equals("i") ? "info" : null);
|
||||
}
|
||||
@ -363,7 +364,7 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
private static void replaceArgs(List<String> args, int i, Function<String, String> rewrites) {
|
||||
String arg = args.get(i).toLowerCase();
|
||||
String arg = args.get(i).toLowerCase(Locale.ROOT);
|
||||
String rewrite = rewrites.apply(arg);
|
||||
if (rewrite != null) {
|
||||
args.remove(i);
|
||||
|
@ -36,6 +36,7 @@ import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -58,7 +59,7 @@ public abstract class ChildCommand<T> extends Command<T> {
|
||||
TextComponent.Builder builder = Component.text()
|
||||
.append(Component.text('>', NamedTextColor.DARK_AQUA))
|
||||
.append(Component.space())
|
||||
.append(Component.text(getName().toLowerCase(), NamedTextColor.GREEN));
|
||||
.append(Component.text(getName().toLowerCase(Locale.ROOT), NamedTextColor.GREEN));
|
||||
|
||||
if (getArgs().isPresent()) {
|
||||
List<Component> argUsages = getArgs().get().stream()
|
||||
|
@ -41,6 +41,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -106,7 +107,7 @@ public abstract class GenericChildCommand {
|
||||
TextComponent.Builder builder = Component.text()
|
||||
.append(Component.text('>', NamedTextColor.DARK_AQUA))
|
||||
.append(Component.space())
|
||||
.append(Component.text(getName().toLowerCase(), NamedTextColor.GREEN));
|
||||
.append(Component.text(getName().toLowerCase(Locale.ROOT), NamedTextColor.GREEN));
|
||||
|
||||
if (getArgs() != null) {
|
||||
List<Component> argUsages = getArgs().stream()
|
||||
|
@ -38,6 +38,7 @@ import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -96,7 +97,7 @@ public class GenericParentCommand<T extends PermissionHolder> extends ChildComma
|
||||
return TabCompleter.create()
|
||||
.at(0, CompletionSupplier.startsWith(() -> this.children.stream()
|
||||
.filter(s -> s.isAuthorized(sender, this.type))
|
||||
.map(s -> s.getName().toLowerCase())
|
||||
.map(s -> s.getName().toLowerCase(Locale.ROOT))
|
||||
))
|
||||
.from(1, partial -> this.children.stream()
|
||||
.filter(s -> s.isAuthorized(sender, this.type))
|
||||
@ -121,10 +122,10 @@ public class GenericParentCommand<T extends PermissionHolder> extends ChildComma
|
||||
if (!subs.isEmpty()) {
|
||||
switch (this.type) {
|
||||
case USER:
|
||||
Message.MAIN_COMMAND_USAGE_HEADER.send(sender, getName(), String.format("/%s user <user> " + getName().toLowerCase(), label));
|
||||
Message.MAIN_COMMAND_USAGE_HEADER.send(sender, getName(), String.format("/%s user <user> " + getName().toLowerCase(Locale.ROOT), label));
|
||||
break;
|
||||
case GROUP:
|
||||
Message.MAIN_COMMAND_USAGE_HEADER.send(sender, getName(), String.format("/%s group <group> " + getName().toLowerCase(), label));
|
||||
Message.MAIN_COMMAND_USAGE_HEADER.send(sender, getName(), String.format("/%s group <group> " + getName().toLowerCase(Locale.ROOT), label));
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError(this.type);
|
||||
|
@ -38,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -123,7 +124,7 @@ public abstract class ParentCommand<T, I> extends Command<Void> {
|
||||
.at(0, CompletionSupplier.startsWith(() -> getTargets(plugin).stream()))
|
||||
.at(1, CompletionSupplier.startsWith(() -> getChildren().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
.map(s -> s.getName().toLowerCase())
|
||||
.map(s -> s.getName().toLowerCase(Locale.ROOT))
|
||||
))
|
||||
.from(2, partial -> getChildren().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
@ -137,7 +138,7 @@ public abstract class ParentCommand<T, I> extends Command<Void> {
|
||||
return TabCompleter.create()
|
||||
.at(0, CompletionSupplier.startsWith(() -> getChildren().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
.map(s -> s.getName().toLowerCase())
|
||||
.map(s -> s.getName().toLowerCase(Locale.ROOT))
|
||||
))
|
||||
.from(1, partial -> getChildren().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
|
@ -38,6 +38,7 @@ import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -62,7 +63,7 @@ public abstract class SingleCommand extends Command<Void> {
|
||||
TextComponent.Builder builder = Component.text()
|
||||
.append(Component.text('>', NamedTextColor.DARK_AQUA))
|
||||
.append(Component.space())
|
||||
.append(Component.text(getName().toLowerCase(), NamedTextColor.GREEN));
|
||||
.append(Component.text(getName().toLowerCase(Locale.ROOT), NamedTextColor.GREEN));
|
||||
|
||||
if (getArgs().isPresent()) {
|
||||
List<Component> argUsages = getArgs().get().stream()
|
||||
|
@ -31,6 +31,7 @@ import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* An enumeration of the command defintion/usage messages used in the plugin.
|
||||
@ -437,7 +438,7 @@ public enum CommandSpec {
|
||||
}
|
||||
|
||||
public String key() {
|
||||
return name().toLowerCase().replace('_', '-');
|
||||
return name().toLowerCase(Locale.ROOT).replace('_', '-');
|
||||
}
|
||||
|
||||
private static PartialArgument arg(String id, String name, boolean required) {
|
||||
|
@ -29,6 +29,7 @@ import com.google.common.base.Preconditions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@ -112,7 +113,7 @@ public class TabCompleter {
|
||||
if (string.length() < substring.length()) {
|
||||
return false;
|
||||
}
|
||||
return string.toLowerCase().contains(substring.toLowerCase());
|
||||
return string.toLowerCase(Locale.ROOT).contains(substring.toLowerCase(Locale.ROOT));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ import net.luckperms.api.context.ImmutableContextSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -57,7 +58,7 @@ public final class TabCompletions {
|
||||
this.permissions = partial -> {
|
||||
PermissionRegistry cache = plugin.getPermissionRegistry();
|
||||
|
||||
String start = partial.toLowerCase();
|
||||
String start = partial.toLowerCase(Locale.ROOT);
|
||||
List<String> parts = new ArrayList<>(Splitter.on('.').splitToList(start));
|
||||
TreeNode root = cache.getRootNode();
|
||||
|
||||
|
@ -47,6 +47,7 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
@ -101,7 +102,7 @@ public class ArgumentList extends ForwardingList<String> {
|
||||
}
|
||||
|
||||
public String getLowercase(int index, Predicate<? super String> test) throws ArgumentException.DetailedUsage {
|
||||
String arg = get(index).toLowerCase();
|
||||
String arg = get(index).toLowerCase(Locale.ROOT);
|
||||
if (!test.test(arg)) {
|
||||
throw new ArgumentException.DetailedUsage();
|
||||
}
|
||||
@ -188,7 +189,7 @@ public class ArgumentList extends ForwardingList<String> {
|
||||
}
|
||||
|
||||
private static TemporaryNodeMergeStrategy parseTemporaryModifier(String s) {
|
||||
switch (s.toLowerCase()) {
|
||||
switch (s.toLowerCase(Locale.ROOT)) {
|
||||
case "accumulate":
|
||||
return TemporaryNodeMergeStrategy.ADD_NEW_DURATION_TO_EXISTING;
|
||||
case "replace":
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
package me.lucko.luckperms.common.command.utils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum SortType {
|
||||
|
||||
PRIORITY,
|
||||
@ -32,6 +34,6 @@ public enum SortType {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase();
|
||||
return name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MetaAddChatMeta extends GenericChildCommand {
|
||||
|
||||
@ -99,7 +100,7 @@ public class MetaAddChatMeta extends GenericChildCommand {
|
||||
Message.ADD_CHATMETA_SUCCESS.send(sender, target, this.type, meta, priority, context);
|
||||
|
||||
LoggedAction.build().source(sender).target(target)
|
||||
.description("meta" , "add" + this.type.name().toLowerCase(), priority, meta, context)
|
||||
.description("meta" , "add" + this.type.name().toLowerCase(Locale.ROOT), priority, meta, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
StorageAssistant.save(target, sender, plugin);
|
||||
|
@ -50,6 +50,7 @@ import net.luckperms.api.node.ChatMetaType;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MetaAddTempChatMeta extends GenericChildCommand {
|
||||
|
||||
@ -107,7 +108,7 @@ public class MetaAddTempChatMeta extends GenericChildCommand {
|
||||
Message.ADD_TEMP_CHATMETA_SUCCESS.send(sender, target, this.type, meta, priority, duration, context);
|
||||
|
||||
LoggedAction.build().source(sender).target(target)
|
||||
.description("meta" , "addtemp" + this.type.name().toLowerCase(), priority, meta, duration, context)
|
||||
.description("meta" , "addtemp" + this.type.name().toLowerCase(Locale.ROOT), priority, meta, duration, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
StorageAssistant.save(target, sender, plugin);
|
||||
|
@ -46,6 +46,7 @@ import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MetaClear extends GenericChildCommand {
|
||||
public MetaClear() {
|
||||
@ -61,7 +62,7 @@ public class MetaClear extends GenericChildCommand {
|
||||
|
||||
NodeType<?> type = null;
|
||||
if (!args.isEmpty()) {
|
||||
String typeId = args.get(0).toLowerCase();
|
||||
String typeId = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (typeId.equals("any") || typeId.equals("all") || typeId.equals("*")) {
|
||||
type = NodeType.META_OR_CHAT_META;
|
||||
}
|
||||
@ -104,7 +105,7 @@ public class MetaClear extends GenericChildCommand {
|
||||
}
|
||||
|
||||
int changed = before - target.normalData().size();
|
||||
Message.META_CLEAR_SUCCESS.send(sender, target, type.name().toLowerCase(), context, changed);
|
||||
Message.META_CLEAR_SUCCESS.send(sender, target, type.name().toLowerCase(Locale.ROOT), context, changed);
|
||||
|
||||
LoggedAction.build().source(sender).target(target)
|
||||
.description("meta", "clear", context)
|
||||
|
@ -47,6 +47,7 @@ import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MetaRemoveChatMeta extends GenericChildCommand {
|
||||
|
||||
@ -100,7 +101,7 @@ public class MetaRemoveChatMeta extends GenericChildCommand {
|
||||
Message.BULK_REMOVE_CHATMETA_SUCCESS.send(sender, target, this.type, priority, context);
|
||||
|
||||
LoggedAction.build().source(sender).target(target)
|
||||
.description("meta" , "remove" + this.type.name().toLowerCase(), priority, "*", context)
|
||||
.description("meta" , "remove" + this.type.name().toLowerCase(Locale.ROOT), priority, "*", context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
StorageAssistant.save(target, sender, plugin);
|
||||
@ -113,7 +114,7 @@ public class MetaRemoveChatMeta extends GenericChildCommand {
|
||||
Message.REMOVE_CHATMETA_SUCCESS.send(sender, target, this.type, meta, priority, context);
|
||||
|
||||
LoggedAction.build().source(sender).target(target)
|
||||
.description("meta" , "remove" + this.type.name().toLowerCase(), priority, meta, context)
|
||||
.description("meta" , "remove" + this.type.name().toLowerCase(Locale.ROOT), priority, meta, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
StorageAssistant.save(target, sender, plugin);
|
||||
|
@ -47,6 +47,7 @@ import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MetaRemoveTempChatMeta extends GenericChildCommand {
|
||||
|
||||
@ -100,7 +101,7 @@ public class MetaRemoveTempChatMeta extends GenericChildCommand {
|
||||
Message.BULK_REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, target, this.type, priority, context);
|
||||
|
||||
LoggedAction.build().source(sender).target(target)
|
||||
.description("meta" , "removetemp" + this.type.name().toLowerCase(), priority, "*", context)
|
||||
.description("meta" , "removetemp" + this.type.name().toLowerCase(Locale.ROOT), priority, "*", context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
StorageAssistant.save(target, sender, plugin);
|
||||
@ -113,7 +114,7 @@ public class MetaRemoveTempChatMeta extends GenericChildCommand {
|
||||
Message.REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, target, this.type, meta, priority, context);
|
||||
|
||||
LoggedAction.build().source(sender).target(target)
|
||||
.description("meta" , "removetemp" + this.type.name().toLowerCase(), priority, meta, context)
|
||||
.description("meta" , "removetemp" + this.type.name().toLowerCase(Locale.ROOT), priority, meta, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
StorageAssistant.save(target, sender, plugin);
|
||||
|
@ -50,6 +50,7 @@ import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public class MetaSetChatMeta extends GenericChildCommand {
|
||||
@ -134,7 +135,7 @@ public class MetaSetChatMeta extends GenericChildCommand {
|
||||
Message.ADD_CHATMETA_SUCCESS.send(sender, target, this.type, meta, priority, context);
|
||||
|
||||
LoggedAction.build().source(sender).target(target)
|
||||
.description("meta" , "set" + this.type.name().toLowerCase(), priority, meta, context)
|
||||
.description("meta" , "set" + this.type.name().toLowerCase(Locale.ROOT), priority, meta, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
StorageAssistant.save(target, sender, plugin);
|
||||
|
@ -53,6 +53,7 @@ import net.luckperms.api.node.ChatMetaType;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public class MetaSetTempChatMeta extends GenericChildCommand {
|
||||
@ -146,7 +147,7 @@ public class MetaSetTempChatMeta extends GenericChildCommand {
|
||||
Message.ADD_TEMP_CHATMETA_SUCCESS.send(sender, target, this.type, meta, priority, duration, context);
|
||||
|
||||
LoggedAction.build().source(sender).target(target)
|
||||
.description("meta" , "settemp" + this.type.name().toLowerCase(), priority, meta, duration, context)
|
||||
.description("meta" , "settemp" + this.type.name().toLowerCase(Locale.ROOT), priority, meta, duration, context)
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
StorageAssistant.save(target, sender, plugin);
|
||||
|
@ -50,6 +50,7 @@ import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ParentClearTrack extends GenericChildCommand {
|
||||
public ParentClearTrack() {
|
||||
@ -63,7 +64,7 @@ public class ParentClearTrack extends GenericChildCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final String trackName = args.get(0).toLowerCase();
|
||||
final String trackName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.TRACK_NAME_TEST.test(trackName)) {
|
||||
Message.TRACK_INVALID_ENTRY.send(sender, trackName);
|
||||
return;
|
||||
|
@ -50,6 +50,7 @@ import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ParentSetTrack extends GenericChildCommand {
|
||||
public ParentSetTrack() {
|
||||
@ -63,7 +64,7 @@ public class ParentSetTrack extends GenericChildCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final String trackName = args.get(0).toLowerCase();
|
||||
final String trackName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.TRACK_NAME_TEST.test(trackName)) {
|
||||
Message.TRACK_INVALID_ENTRY.send(sender, trackName);
|
||||
return;
|
||||
|
@ -51,6 +51,7 @@ import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class UserSwitchPrimaryGroup extends GenericChildCommand {
|
||||
public UserSwitchPrimaryGroup() {
|
||||
@ -74,9 +75,9 @@ public class UserSwitchPrimaryGroup extends GenericChildCommand {
|
||||
Message.USER_PRIMARYGROUP_WARN_OPTION.send(sender, opt);
|
||||
}
|
||||
|
||||
Group group = plugin.getGroupManager().getIfLoaded(args.get(0).toLowerCase());
|
||||
Group group = plugin.getGroupManager().getIfLoaded(args.get(0).toLowerCase(Locale.ROOT));
|
||||
if (group == null) {
|
||||
Message.DOES_NOT_EXIST.send(sender, args.get(0).toLowerCase());
|
||||
Message.DOES_NOT_EXIST.send(sender, args.get(0).toLowerCase(Locale.ROOT));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,8 @@ import net.luckperms.api.actionlog.Action;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class CreateGroup extends SingleCommand {
|
||||
public CreateGroup() {
|
||||
super(CommandSpec.CREATE_GROUP, "CreateGroup", CommandPermission.CREATE_GROUP, Predicates.notInRange(1, 3));
|
||||
@ -58,7 +60,7 @@ public class CreateGroup extends SingleCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
String groupName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(groupName)) {
|
||||
Message.GROUP_INVALID_ENTRY.send(sender, groupName);
|
||||
return;
|
||||
|
@ -56,6 +56,7 @@ import net.luckperms.api.actionlog.Action;
|
||||
import net.luckperms.api.event.cause.DeletionCause;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
public class DeleteGroup extends SingleCommand {
|
||||
@ -70,7 +71,7 @@ public class DeleteGroup extends SingleCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
String groupName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
|
||||
if (groupName.equalsIgnoreCase(GroupManager.DEFAULT_GROUP_NAME)) {
|
||||
Message.DELETE_GROUP_ERROR_DEFAULT.send(sender);
|
||||
|
@ -42,6 +42,8 @@ import me.lucko.luckperms.common.util.Predicates;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class GroupClone extends ChildCommand<Group> {
|
||||
public GroupClone() {
|
||||
super(CommandSpec.GROUP_CLONE, "clone", CommandPermission.GROUP_CLONE, Predicates.not(1));
|
||||
@ -54,7 +56,7 @@ public class GroupClone extends ChildCommand<Group> {
|
||||
return;
|
||||
}
|
||||
|
||||
String newGroupName = args.get(0).toLowerCase();
|
||||
String newGroupName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(newGroupName)) {
|
||||
Message.GROUP_INVALID_ENTRY.send(sender, newGroupName);
|
||||
return;
|
||||
|
@ -46,6 +46,7 @@ import me.lucko.luckperms.common.util.CaffeineFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@ -83,7 +84,7 @@ public class GroupParentCommand extends ParentCommand<Group, String> {
|
||||
if (group != null) {
|
||||
return group.getName();
|
||||
} else {
|
||||
return target.toLowerCase();
|
||||
return target.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ import net.luckperms.api.event.cause.DeletionCause;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class GroupRename extends ChildCommand<Group> {
|
||||
@ -69,7 +70,7 @@ public class GroupRename extends ChildCommand<Group> {
|
||||
return;
|
||||
}
|
||||
|
||||
String newGroupName = args.get(0).toLowerCase();
|
||||
String newGroupName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(newGroupName)) {
|
||||
Message.GROUP_INVALID_ENTRY.send(sender, newGroupName);
|
||||
return;
|
||||
|
@ -41,6 +41,7 @@ import me.lucko.luckperms.common.util.Paginated;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LogGroupHistory extends ChildCommand<Log> {
|
||||
private static final int ENTRIES_PER_PAGE = 10;
|
||||
@ -51,7 +52,7 @@ public class LogGroupHistory extends ChildCommand<Log> {
|
||||
|
||||
@Override
|
||||
public void execute(LuckPermsPlugin plugin, Sender sender, Log log, ArgumentList args, String label) {
|
||||
String group = args.get(0).toLowerCase();
|
||||
String group = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(group)) {
|
||||
Message.GROUP_INVALID_ENTRY.send(sender, group);
|
||||
return;
|
||||
|
@ -41,6 +41,7 @@ import me.lucko.luckperms.common.util.Paginated;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LogTrackHistory extends ChildCommand<Log> {
|
||||
private static final int ENTRIES_PER_PAGE = 10;
|
||||
@ -51,7 +52,7 @@ public class LogTrackHistory extends ChildCommand<Log> {
|
||||
|
||||
@Override
|
||||
public void execute(LuckPermsPlugin plugin, Sender sender, Log log, ArgumentList args, String label) {
|
||||
String track = args.get(0).toLowerCase();
|
||||
String track = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.TRACK_NAME_TEST.test(track)) {
|
||||
Message.TRACK_INVALID_ENTRY.send(sender, track);
|
||||
return;
|
||||
|
@ -51,6 +51,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.CaffeineFactory;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -90,13 +91,13 @@ public class BulkUpdateCommand extends SingleCommand {
|
||||
bulkUpdateBuilder.trackStatistics(!args.remove("-s"));
|
||||
|
||||
try {
|
||||
bulkUpdateBuilder.dataType(DataType.valueOf(args.remove(0).toUpperCase()));
|
||||
bulkUpdateBuilder.dataType(DataType.valueOf(args.remove(0).toUpperCase(Locale.ROOT)));
|
||||
} catch (IllegalArgumentException e) {
|
||||
Message.BULK_UPDATE_INVALID_DATA_TYPE.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
String action = args.remove(0).toLowerCase();
|
||||
String action = args.remove(0).toLowerCase(Locale.ROOT);
|
||||
switch (action) {
|
||||
case "delete":
|
||||
bulkUpdateBuilder.action(DeleteAction.create());
|
||||
|
@ -45,6 +45,7 @@ import net.luckperms.api.node.Node;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class EditorCommand extends SingleCommand {
|
||||
public EditorCommand() {
|
||||
@ -60,7 +61,7 @@ public class EditorCommand extends SingleCommand {
|
||||
String arg0 = args.getOrDefault(0, null);
|
||||
if (arg0 != null) {
|
||||
try {
|
||||
type = Type.valueOf(arg0.toUpperCase());
|
||||
type = Type.valueOf(arg0.toUpperCase(Locale.ROOT));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// assume they meant it as a filter
|
||||
filter = arg0;
|
||||
|
@ -45,6 +45,7 @@ import me.lucko.luckperms.common.verbose.VerboseListener;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class VerboseCommand extends SingleCommand {
|
||||
public VerboseCommand() {
|
||||
@ -59,7 +60,7 @@ public class VerboseCommand extends SingleCommand {
|
||||
}
|
||||
|
||||
VerboseHandler verboseHandler = plugin.getVerboseHandler();
|
||||
String mode = args.get(0).toLowerCase();
|
||||
String mode = args.get(0).toLowerCase(Locale.ROOT);
|
||||
|
||||
if (mode.equals("command") || mode.equals("cmd")) {
|
||||
if (args.size() < 3) {
|
||||
|
@ -40,6 +40,8 @@ import net.kyori.adventure.text.Component;
|
||||
import net.luckperms.api.actionlog.Action;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class CreateTrack extends SingleCommand {
|
||||
public CreateTrack() {
|
||||
super(CommandSpec.CREATE_TRACK, "CreateTrack", CommandPermission.CREATE_TRACK, Predicates.not(1));
|
||||
@ -52,7 +54,7 @@ public class CreateTrack extends SingleCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
String trackName = args.get(0).toLowerCase();
|
||||
String trackName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.TRACK_NAME_TEST.test(trackName)) {
|
||||
Message.TRACK_INVALID_ENTRY.send(sender, trackName);
|
||||
return;
|
||||
|
@ -44,6 +44,7 @@ import net.luckperms.api.actionlog.Action;
|
||||
import net.luckperms.api.event.cause.DeletionCause;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class DeleteTrack extends SingleCommand {
|
||||
public DeleteTrack() {
|
||||
@ -57,7 +58,7 @@ public class DeleteTrack extends SingleCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
String trackName = args.get(0).toLowerCase();
|
||||
String trackName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
Track track = plugin.getStorage().loadTrack(trackName).join().orElse(null);
|
||||
if (track == null) {
|
||||
Message.TRACK_LOAD_ERROR.send(sender);
|
||||
|
@ -45,6 +45,7 @@ import me.lucko.luckperms.common.util.Predicates;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class TrackAppend extends ChildCommand<Track> {
|
||||
public TrackAppend() {
|
||||
@ -58,7 +59,7 @@ public class TrackAppend extends ChildCommand<Track> {
|
||||
return;
|
||||
}
|
||||
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
String groupName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(groupName)) {
|
||||
sendDetailedUsage(sender, label);
|
||||
return;
|
||||
|
@ -42,6 +42,8 @@ import me.lucko.luckperms.common.util.Predicates;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class TrackClone extends ChildCommand<Track> {
|
||||
public TrackClone() {
|
||||
super(CommandSpec.TRACK_CLONE, "clone", CommandPermission.TRACK_CLONE, Predicates.not(1));
|
||||
@ -54,7 +56,7 @@ public class TrackClone extends ChildCommand<Track> {
|
||||
return;
|
||||
}
|
||||
|
||||
String newTrackName = args.get(0).toLowerCase();
|
||||
String newTrackName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.TRACK_NAME_TEST.test(newTrackName)) {
|
||||
Message.TRACK_INVALID_ENTRY.send(sender, newTrackName);
|
||||
return;
|
||||
|
@ -45,6 +45,7 @@ import me.lucko.luckperms.common.util.Predicates;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class TrackInsert extends ChildCommand<Track> {
|
||||
public TrackInsert() {
|
||||
@ -58,7 +59,7 @@ public class TrackInsert extends ChildCommand<Track> {
|
||||
return;
|
||||
}
|
||||
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
String groupName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(groupName)) {
|
||||
sendDetailedUsage(sender, label);
|
||||
return;
|
||||
|
@ -39,6 +39,7 @@ import me.lucko.luckperms.common.util.CaffeineFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@ -68,7 +69,7 @@ public class TrackParentCommand extends ParentCommand<Track, String> {
|
||||
|
||||
@Override
|
||||
protected String parseTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||
return target.toLowerCase();
|
||||
return target.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,6 +44,7 @@ import me.lucko.luckperms.common.util.Predicates;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class TrackRemove extends ChildCommand<Track> {
|
||||
public TrackRemove() {
|
||||
@ -57,7 +58,7 @@ public class TrackRemove extends ChildCommand<Track> {
|
||||
return;
|
||||
}
|
||||
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
String groupName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(groupName)) {
|
||||
sendDetailedUsage(sender, label);
|
||||
return;
|
||||
|
@ -43,6 +43,8 @@ import net.kyori.adventure.text.Component;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.event.cause.DeletionCause;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class TrackRename extends ChildCommand<Track> {
|
||||
public TrackRename() {
|
||||
super(CommandSpec.TRACK_RENAME, "rename", CommandPermission.TRACK_RENAME, Predicates.not(1));
|
||||
@ -55,7 +57,7 @@ public class TrackRename extends ChildCommand<Track> {
|
||||
return;
|
||||
}
|
||||
|
||||
String newTrackName = args.get(0).toLowerCase();
|
||||
String newTrackName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.TRACK_NAME_TEST.test(newTrackName)) {
|
||||
Message.TRACK_INVALID_ENTRY.send(sender, newTrackName);
|
||||
return;
|
||||
|
@ -47,6 +47,7 @@ import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.track.DemotionResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@ -77,7 +78,7 @@ public class UserDemote extends ChildCommand<User> {
|
||||
}
|
||||
}
|
||||
|
||||
final String trackName = args.get(0).toLowerCase();
|
||||
final String trackName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.TRACK_NAME_TEST.test(trackName)) {
|
||||
Message.TRACK_INVALID_ENTRY.send(sender, trackName);
|
||||
return;
|
||||
|
@ -47,6 +47,7 @@ import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.track.PromotionResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@ -77,7 +78,7 @@ public class UserPromote extends ChildCommand<User> {
|
||||
}
|
||||
}
|
||||
|
||||
final String trackName = args.get(0).toLowerCase();
|
||||
final String trackName = args.get(0).toLowerCase(Locale.ROOT);
|
||||
if (!DataConstraints.TRACK_NAME_TEST.test(trackName)) {
|
||||
Message.TRACK_INVALID_ENTRY.send(sender, trackName);
|
||||
return;
|
||||
|
@ -59,6 +59,7 @@ import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@ -86,9 +87,9 @@ public final class ConfigKeys {
|
||||
* The name of the server
|
||||
*/
|
||||
public static final ConfigKey<String> SERVER = key(c -> {
|
||||
String server = c.getString("server", "global").toLowerCase();
|
||||
String server = c.getString("server", "global").toLowerCase(Locale.ROOT);
|
||||
if (server.equals("load-from-system-property")) {
|
||||
server = System.getProperty("luckperms.server", "global").toLowerCase();
|
||||
server = System.getProperty("luckperms.server", "global").toLowerCase(Locale.ROOT);
|
||||
}
|
||||
return server;
|
||||
});
|
||||
@ -191,7 +192,7 @@ public final class ConfigKeys {
|
||||
*/
|
||||
public static final ConfigKey<TemporaryNodeMergeStrategy> TEMPORARY_ADD_BEHAVIOUR = key(c -> {
|
||||
String value = c.getString("temporary-add-behaviour", "deny");
|
||||
switch (value.toLowerCase()) {
|
||||
switch (value.toLowerCase(Locale.ROOT)) {
|
||||
case "accumulate":
|
||||
return TemporaryNodeMergeStrategy.ADD_NEW_DURATION_TO_EXISTING;
|
||||
case "replace":
|
||||
@ -205,7 +206,7 @@ public final class ConfigKeys {
|
||||
* How primary groups should be calculated.
|
||||
*/
|
||||
public static final ConfigKey<String> PRIMARY_GROUP_CALCULATION_METHOD = notReloadable(key(c -> {
|
||||
String option = c.getString("primary-group-calculation", "stored").toLowerCase();
|
||||
String option = c.getString("primary-group-calculation", "stored").toLowerCase(Locale.ROOT);
|
||||
if (!option.equals("stored") && !option.equals("parents-by-weight") && !option.equals("all-parents-by-weight")) {
|
||||
option = "stored";
|
||||
}
|
||||
@ -318,7 +319,7 @@ public final class ConfigKeys {
|
||||
*/
|
||||
public static final ConfigKey<TraversalAlgorithm> INHERITANCE_TRAVERSAL_ALGORITHM = key(c -> {
|
||||
String value = c.getString("inheritance-traversal-algorithm", "depth-first-pre-order");
|
||||
switch (value.toLowerCase()) {
|
||||
switch (value.toLowerCase(Locale.ROOT)) {
|
||||
case "breadth-first":
|
||||
return TraversalAlgorithm.BREADTH_FIRST;
|
||||
case "depth-first-post-order":
|
||||
@ -355,7 +356,7 @@ public final class ConfigKeys {
|
||||
*/
|
||||
public static final ConfigKey<Map<String, Integer>> GROUP_WEIGHTS = key(c -> {
|
||||
return c.getStringMap("group-weight", ImmutableMap.of()).entrySet().stream().collect(ImmutableCollectors.toMap(
|
||||
e -> e.getKey().toLowerCase(),
|
||||
e -> e.getKey().toLowerCase(Locale.ROOT),
|
||||
e -> {
|
||||
try {
|
||||
return Integer.parseInt(e.getValue());
|
||||
@ -378,7 +379,7 @@ public final class ConfigKeys {
|
||||
String middleSpacer = l.getString("meta-formatting.prefix.middle-spacer", " ");
|
||||
String endSpacer = l.getString("meta-formatting.prefix.end-spacer", "");
|
||||
DuplicateRemovalFunction duplicateRemovalFunction;
|
||||
switch (l.getString("meta-formatting.prefix.duplicates", "").toLowerCase()) {
|
||||
switch (l.getString("meta-formatting.prefix.duplicates", "").toLowerCase(Locale.ROOT)) {
|
||||
case "first-only":
|
||||
duplicateRemovalFunction = DuplicateRemovalFunction.FIRST_ONLY;
|
||||
break;
|
||||
@ -405,7 +406,7 @@ public final class ConfigKeys {
|
||||
String middleSpacer = l.getString("meta-formatting.suffix.middle-spacer", " ");
|
||||
String endSpacer = l.getString("meta-formatting.suffix.end-spacer", "");
|
||||
DuplicateRemovalFunction duplicateRemovalFunction;
|
||||
switch (l.getString("meta-formatting.prefix.duplicates", "").toLowerCase()) {
|
||||
switch (l.getString("meta-formatting.prefix.duplicates", "").toLowerCase(Locale.ROOT)) {
|
||||
case "first-only":
|
||||
duplicateRemovalFunction = DuplicateRemovalFunction.FIRST_ONLY;
|
||||
break;
|
||||
@ -493,7 +494,7 @@ public final class ConfigKeys {
|
||||
public static final ConfigKey<String> VAULT_SERVER = key(c -> {
|
||||
// default to true for backwards compatibility
|
||||
if (USE_VAULT_SERVER.get(c)) {
|
||||
return c.getString("vault-server", "global").toLowerCase();
|
||||
return c.getString("vault-server", "global").toLowerCase(Locale.ROOT);
|
||||
} else {
|
||||
return SERVER.get(c);
|
||||
}
|
||||
@ -520,8 +521,8 @@ public final class ConfigKeys {
|
||||
public static final ConfigKey<WorldNameRewriter> WORLD_REWRITES = key(c -> {
|
||||
return WorldNameRewriter.of(c.getStringMap("world-rewrite", ImmutableMap.of()).entrySet().stream()
|
||||
.collect(ImmutableCollectors.toMap(
|
||||
e -> e.getKey().toLowerCase(),
|
||||
e -> e.getValue().toLowerCase()
|
||||
e -> e.getKey().toLowerCase(Locale.ROOT),
|
||||
e -> e.getValue().toLowerCase(Locale.ROOT)
|
||||
)));
|
||||
});
|
||||
|
||||
|
@ -29,6 +29,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import me.lucko.luckperms.common.config.generic.adapter.ConfigurationAdapter;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@ -36,7 +37,7 @@ public interface ConfigKeyFactory<T> {
|
||||
|
||||
ConfigKeyFactory<Boolean> BOOLEAN = ConfigurationAdapter::getBoolean;
|
||||
ConfigKeyFactory<String> STRING = ConfigurationAdapter::getString;
|
||||
ConfigKeyFactory<String> LOWERCASE_STRING = (adapter, path, def) -> adapter.getString(path, def).toLowerCase();
|
||||
ConfigKeyFactory<String> LOWERCASE_STRING = (adapter, path, def) -> adapter.getString(path, def).toLowerCase(Locale.ROOT);
|
||||
ConfigKeyFactory<Map<String, String>> STRING_MAP = (config, path, def) -> ImmutableMap.copyOf(config.getStringMap(path, ImmutableMap.of()));
|
||||
|
||||
static <T> SimpleConfigKey<T> key(Function<ConfigurationAdapter, T> function) {
|
||||
|
@ -32,6 +32,7 @@ import net.luckperms.api.context.ContextConsumer;
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -69,7 +70,7 @@ public interface WorldNameRewriter {
|
||||
@Override
|
||||
public void rewriteAndSubmit(String worldName, ContextConsumer consumer) {
|
||||
Set<String> seen = new HashSet<>();
|
||||
worldName = worldName.toLowerCase();
|
||||
worldName = worldName.toLowerCase(Locale.ROOT);
|
||||
|
||||
while (Context.isValidValue(worldName) && seen.add(worldName)) {
|
||||
consumer.accept(DefaultContextKeys.WORLD_KEY, worldName);
|
||||
|
@ -39,6 +39,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.Spliterator;
|
||||
@ -127,7 +128,7 @@ public abstract class AbstractContextSet implements ContextSet {
|
||||
if (!Context.isValidKey(key)) {
|
||||
throw new IllegalArgumentException("key is (effectively) empty");
|
||||
}
|
||||
return key.toLowerCase();
|
||||
return key.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
static String sanitizeValue(String value) {
|
||||
@ -135,7 +136,7 @@ public abstract class AbstractContextSet implements ContextSet {
|
||||
if (!Context.isValidValue(value)) {
|
||||
throw new IllegalArgumentException("value is (effectively) empty");
|
||||
}
|
||||
return value.toLowerCase();
|
||||
return value.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
public static boolean isGlobalServerWorldEntry(String key, String value) {
|
||||
|
@ -35,6 +35,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* The dependencies used by LuckPerms.
|
||||
@ -314,7 +315,7 @@ public enum Dependency {
|
||||
}
|
||||
|
||||
public String getFileName(String classifier) {
|
||||
String name = name().toLowerCase().replace('_', '-');
|
||||
String name = name().toLowerCase(Locale.ROOT).replace('_', '-');
|
||||
String extra = classifier == null || classifier.isEmpty()
|
||||
? ""
|
||||
: "-" + classifier;
|
||||
|
@ -42,6 +42,8 @@ import net.luckperms.api.messenger.MessengerProvider;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class MessagingFactory<P extends LuckPermsPlugin> {
|
||||
private final P plugin;
|
||||
|
||||
@ -82,7 +84,7 @@ public class MessagingFactory<P extends LuckPermsPlugin> {
|
||||
return null;
|
||||
}
|
||||
|
||||
this.plugin.getLogger().info("Loading messaging service... [" + messagingType.toUpperCase() + "]");
|
||||
this.plugin.getLogger().info("Loading messaging service... [" + messagingType.toUpperCase(Locale.ROOT) + "]");
|
||||
|
||||
InternalMessagingService service = getServiceFor(messagingType);
|
||||
if (service != null) {
|
||||
|
@ -39,6 +39,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -48,7 +49,7 @@ public final class StandardStackElements {
|
||||
private StandardStackElements() {}
|
||||
|
||||
public static MetaStackElement parseFromString(LuckPermsPlugin plugin, String s) {
|
||||
s = s.toLowerCase();
|
||||
s = s.toLowerCase(Locale.ROOT);
|
||||
|
||||
// static
|
||||
if (s.equals("highest")) return HIGHEST;
|
||||
|
@ -40,6 +40,7 @@ import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
@ -68,7 +69,7 @@ public class Group extends PermissionHolder {
|
||||
|
||||
public Group(String name, LuckPermsPlugin plugin) {
|
||||
super(plugin);
|
||||
this.name = name.toLowerCase();
|
||||
this.name = name.toLowerCase(Locale.ROOT);
|
||||
|
||||
this.cachedData = new GroupCachedDataManager(this);
|
||||
getPlugin().getEventDispatcher().dispatchGroupCacheLoad(this, this.cachedData);
|
||||
|
@ -25,12 +25,14 @@
|
||||
|
||||
package me.lucko.luckperms.common.model;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum HolderType {
|
||||
USER,
|
||||
GROUP;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase();
|
||||
return name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.SortedSet;
|
||||
@ -363,7 +364,7 @@ public abstract class PermissionHolder {
|
||||
private static void processExportedPermissions(Map<String, Boolean> accumulator, List<Node> entries, boolean convertToLowercase, boolean resolveShorthand) {
|
||||
for (Node node : entries) {
|
||||
if (convertToLowercase) {
|
||||
accumulator.putIfAbsent(node.getKey().toLowerCase(), node.getValue());
|
||||
accumulator.putIfAbsent(node.getKey().toLowerCase(Locale.ROOT), node.getValue());
|
||||
} else {
|
||||
accumulator.putIfAbsent(node.getKey(), node.getValue());
|
||||
}
|
||||
@ -374,7 +375,7 @@ public abstract class PermissionHolder {
|
||||
Collection<String> shorthand = node.resolveShorthand();
|
||||
for (String s : shorthand) {
|
||||
if (convertToLowercase) {
|
||||
accumulator.putIfAbsent(s.toLowerCase(), node.getValue());
|
||||
accumulator.putIfAbsent(s.toLowerCase(Locale.ROOT), node.getValue());
|
||||
} else {
|
||||
accumulator.putIfAbsent(s, node.getValue());
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import net.luckperms.api.node.types.InheritanceNode;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -90,7 +91,7 @@ public interface PrimaryGroupHolder {
|
||||
if (value == null || value.isEmpty()) {
|
||||
this.value = null;
|
||||
} else {
|
||||
this.value = value.toLowerCase();
|
||||
this.value = value.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import net.luckperms.api.node.types.WeightNode;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
@ -62,7 +63,7 @@ public class WeightCache extends Cache<OptionalInt> {
|
||||
|
||||
if (!seen) {
|
||||
Map<String, Integer> configWeights = this.group.getPlugin().getConfiguration().get(ConfigKeys.GROUP_WEIGHTS);
|
||||
Integer value = configWeights.get(this.group.getObjectName().toLowerCase());
|
||||
Integer value = configWeights.get(this.group.getObjectName().toLowerCase(Locale.ROOT));
|
||||
if (value != null) {
|
||||
seen = true;
|
||||
weight = value;
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.model.manager.group;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.manager.AbstractManager;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class AbstractGroupManager<T extends Group> extends AbstractManager<String, Group, T> implements GroupManager<T> {
|
||||
@ -61,7 +62,7 @@ public abstract class AbstractGroupManager<T extends Group> extends AbstractMana
|
||||
|
||||
@Override
|
||||
protected String sanitizeIdentifier(String s) {
|
||||
return s.toLowerCase();
|
||||
return s.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,10 +28,12 @@ package me.lucko.luckperms.common.model.manager.track;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.model.manager.AbstractManager;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public abstract class AbstractTrackManager<T extends Track> extends AbstractManager<String, Track, T> implements TrackManager<T> {
|
||||
|
||||
@Override
|
||||
protected String sanitizeIdentifier(String s) {
|
||||
return s.toLowerCase();
|
||||
return s.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import net.luckperms.api.node.types.DisplayNameNode;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -72,7 +73,7 @@ public class DisplayName extends AbstractNode<DisplayNameNode, DisplayNameNode.B
|
||||
}
|
||||
|
||||
public static @Nullable Builder parse(String key) {
|
||||
if (!key.toLowerCase().startsWith(NODE_MARKER)) {
|
||||
if (!key.toLowerCase(Locale.ROOT).startsWith(NODE_MARKER)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ import net.luckperms.api.node.types.InheritanceNode;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -44,7 +45,7 @@ public class Inheritance extends AbstractNode<InheritanceNode, InheritanceNode.B
|
||||
private static final String NODE_MARKER = NODE_KEY + ".";
|
||||
|
||||
public static String key(String groupName) {
|
||||
return NODE_MARKER + groupName.toLowerCase();
|
||||
return NODE_MARKER + groupName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
@ -59,7 +60,7 @@ public class Inheritance extends AbstractNode<InheritanceNode, InheritanceNode.B
|
||||
|
||||
public Inheritance(String groupName, boolean value, long expireAt, ImmutableContextSet contexts, Map<NodeMetadataKey<?>, Object> metadata) {
|
||||
super(key(groupName), value, expireAt, contexts, metadata);
|
||||
this.groupName = groupName.toLowerCase();
|
||||
this.groupName = groupName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,7 +74,7 @@ public class Inheritance extends AbstractNode<InheritanceNode, InheritanceNode.B
|
||||
}
|
||||
|
||||
public static @Nullable Builder parse(String key) {
|
||||
key = key.toLowerCase();
|
||||
key = key.toLowerCase(Locale.ROOT);
|
||||
if (!key.startsWith(NODE_MARKER)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -45,7 +46,7 @@ public class Meta extends AbstractNode<MetaNode, MetaNode.Builder> implements Me
|
||||
private static final String NODE_MARKER = NODE_KEY + ".";
|
||||
|
||||
public static String key(String key, String value) {
|
||||
return NODE_MARKER + Delimiters.escapeCharacters(key).toLowerCase() + AbstractNode.NODE_SEPARATOR + Delimiters.escapeCharacters(value);
|
||||
return NODE_MARKER + Delimiters.escapeCharacters(key).toLowerCase(Locale.ROOT) + AbstractNode.NODE_SEPARATOR + Delimiters.escapeCharacters(value);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
@ -61,7 +62,7 @@ public class Meta extends AbstractNode<MetaNode, MetaNode.Builder> implements Me
|
||||
|
||||
public Meta(String metaKey, String metaValue, boolean value, long expireAt, ImmutableContextSet contexts, Map<NodeMetadataKey<?>, Object> metadata) {
|
||||
super(key(metaKey, metaValue), value, expireAt, contexts, metadata);
|
||||
this.metaKey = metaKey.toLowerCase();
|
||||
this.metaKey = metaKey.toLowerCase(Locale.ROOT);
|
||||
this.metaValue = metaValue;
|
||||
}
|
||||
|
||||
@ -81,7 +82,7 @@ public class Meta extends AbstractNode<MetaNode, MetaNode.Builder> implements Me
|
||||
}
|
||||
|
||||
public static @Nullable Builder parse(String key) {
|
||||
if (!key.toLowerCase().startsWith(NODE_MARKER)) {
|
||||
if (!key.toLowerCase(Locale.ROOT).startsWith(NODE_MARKER)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -87,7 +88,7 @@ public class Prefix extends AbstractNode<PrefixNode, PrefixNode.Builder> impleme
|
||||
}
|
||||
|
||||
public static @Nullable Builder parse(String key) {
|
||||
if (!key.toLowerCase().startsWith(NODE_MARKER)) {
|
||||
if (!key.toLowerCase(Locale.ROOT).startsWith(NODE_MARKER)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -87,7 +88,7 @@ public class Suffix extends AbstractNode<SuffixNode, SuffixNode.Builder> impleme
|
||||
}
|
||||
|
||||
public static @Nullable Builder parse(String key) {
|
||||
if (!key.toLowerCase().startsWith(NODE_MARKER)) {
|
||||
if (!key.toLowerCase(Locale.ROOT).startsWith(NODE_MARKER)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ import net.luckperms.api.node.types.WeightNode;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class Weight extends AbstractNode<WeightNode, WeightNode.Builder> implements WeightNode {
|
||||
@ -71,7 +72,7 @@ public class Weight extends AbstractNode<WeightNode, WeightNode.Builder> impleme
|
||||
}
|
||||
|
||||
public static @Nullable Builder parse(String key) {
|
||||
if (!key.toLowerCase().startsWith(NODE_MARKER)) {
|
||||
if (!key.toLowerCase(Locale.ROOT).startsWith(NODE_MARKER)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ import net.luckperms.api.node.NodeBuilder;
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
public class NodeJsonSerializer {
|
||||
@ -51,7 +52,7 @@ public class NodeJsonSerializer {
|
||||
for (Node node : nodes) {
|
||||
JsonObject attributes = new JsonObject();
|
||||
|
||||
attributes.addProperty("type", node.getType().name().toLowerCase());
|
||||
attributes.addProperty("type", node.getType().name().toLowerCase(Locale.ROOT));
|
||||
attributes.addProperty("key", node.getKey());
|
||||
attributes.addProperty("value", node.getValue());
|
||||
|
||||
|
@ -71,6 +71,7 @@ import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -336,7 +337,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
|
||||
@Override
|
||||
public Optional<UUID> lookupUniqueId(String username) {
|
||||
// get a result from the DB cache
|
||||
UUID uniqueId = getStorage().getPlayerUniqueId(username.toLowerCase()).join();
|
||||
UUID uniqueId = getStorage().getPlayerUniqueId(username.toLowerCase(Locale.ROOT)).join();
|
||||
|
||||
// fire the event
|
||||
uniqueId = getEventDispatcher().dispatchUniqueIdLookup(username, uniqueId);
|
||||
|
@ -49,6 +49,7 @@ import net.luckperms.api.node.Node;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -171,7 +172,7 @@ public class Storage {
|
||||
|
||||
public CompletableFuture<Group> createAndLoadGroup(String name, CreationCause cause) {
|
||||
return future(() -> {
|
||||
Group group = this.implementation.createAndLoadGroup(name.toLowerCase());
|
||||
Group group = this.implementation.createAndLoadGroup(name.toLowerCase(Locale.ROOT));
|
||||
if (group != null) {
|
||||
this.plugin.getEventDispatcher().dispatchGroupCreate(group, cause);
|
||||
}
|
||||
@ -181,7 +182,7 @@ public class Storage {
|
||||
|
||||
public CompletableFuture<Optional<Group>> loadGroup(String name) {
|
||||
return future(() -> {
|
||||
Optional<Group> group = this.implementation.loadGroup(name.toLowerCase());
|
||||
Optional<Group> group = this.implementation.loadGroup(name.toLowerCase(Locale.ROOT));
|
||||
if (group.isPresent()) {
|
||||
this.plugin.getEventDispatcher().dispatchGroupLoad(group.get());
|
||||
}
|
||||
@ -217,7 +218,7 @@ public class Storage {
|
||||
|
||||
public CompletableFuture<Track> createAndLoadTrack(String name, CreationCause cause) {
|
||||
return future(() -> {
|
||||
Track track = this.implementation.createAndLoadTrack(name.toLowerCase());
|
||||
Track track = this.implementation.createAndLoadTrack(name.toLowerCase(Locale.ROOT));
|
||||
if (track != null) {
|
||||
this.plugin.getEventDispatcher().dispatchTrackCreate(track, cause);
|
||||
}
|
||||
@ -227,7 +228,7 @@ public class Storage {
|
||||
|
||||
public CompletableFuture<Optional<Track>> loadTrack(String name) {
|
||||
return future(() -> {
|
||||
Optional<Track> track = this.implementation.loadTrack(name.toLowerCase());
|
||||
Optional<Track> track = this.implementation.loadTrack(name.toLowerCase(Locale.ROOT));
|
||||
if (track.isPresent()) {
|
||||
this.plugin.getEventDispatcher().dispatchTrackLoad(track.get());
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -200,11 +201,11 @@ public class FileUuidCache {
|
||||
// existing might be null
|
||||
if (!value.equalsIgnoreCase(existing)) {
|
||||
if (existing != null) {
|
||||
this.reverse.remove(existing.toLowerCase(), key);
|
||||
this.reverse.remove(existing.toLowerCase(Locale.ROOT), key);
|
||||
}
|
||||
}
|
||||
|
||||
this.reverse.put(value.toLowerCase(), key);
|
||||
this.reverse.put(value.toLowerCase(Locale.ROOT), key);
|
||||
return existing;
|
||||
}
|
||||
|
||||
@ -213,7 +214,7 @@ public class FileUuidCache {
|
||||
UUID key = (UUID) k;
|
||||
String username = super.remove(key);
|
||||
if (username != null) {
|
||||
this.reverse.remove(username.toLowerCase(), key);
|
||||
this.reverse.remove(username.toLowerCase(Locale.ROOT), key);
|
||||
}
|
||||
return username;
|
||||
}
|
||||
@ -223,7 +224,7 @@ public class FileUuidCache {
|
||||
}
|
||||
|
||||
public Set<UUID> lookupUuid(String name) {
|
||||
return this.reverse.get(name.toLowerCase());
|
||||
return this.reverse.get(name.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,7 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -521,7 +522,7 @@ public class MongoStorage implements StorageImplementation {
|
||||
|
||||
@Override
|
||||
public PlayerSaveResult savePlayerData(UUID uniqueId, String username) {
|
||||
username = username.toLowerCase();
|
||||
username = username.toLowerCase(Locale.ROOT);
|
||||
MongoCollection<Document> c = this.database.getCollection(this.prefix + "uuid");
|
||||
|
||||
// find any existing mapping
|
||||
@ -560,7 +561,7 @@ public class MongoStorage implements StorageImplementation {
|
||||
@Override
|
||||
public UUID getPlayerUniqueId(String username) {
|
||||
MongoCollection<Document> c = this.database.getCollection(this.prefix + "uuid");
|
||||
Document doc = c.find(new Document("name", username.toLowerCase())).first();
|
||||
Document doc = c.find(new Document("name", username.toLowerCase(Locale.ROOT))).first();
|
||||
if (doc != null) {
|
||||
return getDocumentId(doc);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import net.luckperms.api.node.Node;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -114,7 +115,7 @@ public class SplitStorage implements StorageImplementation {
|
||||
meta.put(
|
||||
Component.translatable("luckperms.command.info.storage.meta.split-types-key"),
|
||||
Message.formatStringList(this.types.entrySet().stream()
|
||||
.map(e -> e.getKey().toString().toLowerCase() + "->" + e.getValue().getName().toLowerCase())
|
||||
.map(e -> e.getKey().toString().toLowerCase(Locale.ROOT) + "->" + e.getValue().getName().toLowerCase(Locale.ROOT))
|
||||
.collect(Collectors.toList()))
|
||||
);
|
||||
for (StorageImplementation backing : this.implementations.values()) {
|
||||
|
@ -72,6 +72,7 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -173,7 +174,7 @@ public class SqlStorage implements StorageImplementation {
|
||||
private void applySchema() throws IOException, SQLException {
|
||||
List<String> statements;
|
||||
|
||||
String schemaFileName = "me/lucko/luckperms/schema/" + this.connectionFactory.getImplementationName().toLowerCase() + ".sql";
|
||||
String schemaFileName = "me/lucko/luckperms/schema/" + this.connectionFactory.getImplementationName().toLowerCase(Locale.ROOT) + ".sql";
|
||||
try (InputStream is = this.plugin.getBootstrap().getResourceStream(schemaFileName)) {
|
||||
if (is == null) {
|
||||
throw new IOException("Couldn't locate schema file for " + this.connectionFactory.getImplementationName());
|
||||
@ -375,7 +376,7 @@ public class SqlStorage implements StorageImplementation {
|
||||
updateUserPermissions(c, user.getUniqueId(), changes.getAdded(), changes.getRemoved());
|
||||
insertPlayerData(c, user.getUniqueId(), new SqlPlayerData(
|
||||
user.getPrimaryGroup().getStoredValue().orElse(GroupManager.DEFAULT_GROUP_NAME),
|
||||
user.getUsername().orElse("null").toLowerCase()
|
||||
user.getUsername().orElse("null").toLowerCase(Locale.ROOT)
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -605,7 +606,7 @@ public class SqlStorage implements StorageImplementation {
|
||||
|
||||
@Override
|
||||
public PlayerSaveResult savePlayerData(UUID uniqueId, String username) throws SQLException {
|
||||
username = username.toLowerCase();
|
||||
username = username.toLowerCase(Locale.ROOT);
|
||||
|
||||
// find any existing mapping
|
||||
String oldUsername = getPlayerName(uniqueId);
|
||||
@ -672,7 +673,7 @@ public class SqlStorage implements StorageImplementation {
|
||||
|
||||
@Override
|
||||
public UUID getPlayerUniqueId(String username) throws SQLException {
|
||||
username = username.toLowerCase();
|
||||
username = username.toLowerCase(Locale.ROOT);
|
||||
try (Connection c = this.connectionFactory.getConnection()) {
|
||||
try (PreparedStatement ps = c.prepareStatement(this.statementProcessor.apply(PLAYER_SELECT_UUID_BY_USERNAME))) {
|
||||
ps.setString(1, username);
|
||||
@ -907,7 +908,7 @@ public class SqlStorage implements StorageImplementation {
|
||||
try (PreparedStatement ps = c.prepareStatement(this.statementProcessor.apply(GROUP_SELECT_ALL))) {
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
groups.add(rs.getString("name").toLowerCase());
|
||||
groups.add(rs.getString("name").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -992,7 +993,7 @@ public class SqlStorage implements StorageImplementation {
|
||||
try (PreparedStatement ps = c.prepareStatement(this.statementProcessor.apply(TRACK_SELECT_ALL))) {
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
tracks.add(rs.getString("name").toLowerCase());
|
||||
tracks.add(rs.getString("name").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import me.lucko.luckperms.common.plugin.scheduler.SchedulerTask;
|
||||
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
@ -93,7 +94,7 @@ public class PermissionRegistry implements AutoCloseable {
|
||||
}
|
||||
|
||||
private void doInsert(String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
permission = permission.toLowerCase(Locale.ROOT);
|
||||
|
||||
// split the permission up into parts
|
||||
Iterable<String> parts = DOT_SPLIT.split(permission);
|
||||
|
@ -46,6 +46,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
@ -160,7 +161,7 @@ public class TreeView {
|
||||
checks = new JObject();
|
||||
for (Map.Entry<Integer, String> node : this.view.getNodeEndings()) {
|
||||
String permission = prefix + node.getValue();
|
||||
checks.add(permission, checker.checkPermission(permission, PermissionCheckEvent.Origin.INTERNAL).result().name().toLowerCase());
|
||||
checks.add(permission, checker.checkPermission(permission, PermissionCheckEvent.Origin.INTERNAL).result().name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
} else {
|
||||
checks = null;
|
||||
|
@ -34,6 +34,7 @@ import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Formats durations to a readable form
|
||||
@ -115,7 +116,7 @@ public class DurationFormatter {
|
||||
|
||||
private TranslatableComponent formatPart(long amount, ChronoUnit unit) {
|
||||
String format = this.concise ? "short" : amount == 1 ? "singular" : "plural";
|
||||
String translationKey = "luckperms.duration.unit." + unit.name().toLowerCase() + "." + format;
|
||||
String translationKey = "luckperms.duration.unit." + unit.name().toLowerCase(Locale.ROOT) + "." + format;
|
||||
return Component.translatable(translationKey, Component.text(amount));
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
package me.lucko.luckperms.common.util;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@ -35,7 +36,7 @@ import java.util.function.Function;
|
||||
* @param <E> the enum type
|
||||
*/
|
||||
public class EnumNamer<E extends Enum<E>> {
|
||||
public static final Function<Enum<?>, String> LOWER_CASE_NAME = value -> value.name().toLowerCase();
|
||||
public static final Function<Enum<?>, String> LOWER_CASE_NAME = value -> value.name().toLowerCase(Locale.ROOT);
|
||||
|
||||
private final String[] names;
|
||||
private final Function<? super E, String> namingFunction;
|
||||
|
@ -30,6 +30,8 @@ import me.lucko.luckperms.common.verbose.VerboseCheckTarget;
|
||||
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class MetaCheckEvent extends VerboseEvent {
|
||||
|
||||
/**
|
||||
@ -71,14 +73,14 @@ public class MetaCheckEvent extends VerboseEvent {
|
||||
object.add("type", "meta")
|
||||
.add("key", this.key)
|
||||
.add("result", this.result)
|
||||
.add("origin", this.origin.name().toLowerCase());
|
||||
.add("origin", this.origin.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eval(String variable) {
|
||||
return variable.equals("meta") ||
|
||||
getCheckTarget().describe().equalsIgnoreCase(variable) ||
|
||||
getKey().toLowerCase().startsWith(variable.toLowerCase()) ||
|
||||
getKey().toLowerCase(Locale.ROOT).startsWith(variable.toLowerCase(Locale.ROOT)) ||
|
||||
getResult().equalsIgnoreCase(variable);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@ import me.lucko.luckperms.common.verbose.VerboseCheckTarget;
|
||||
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class PermissionCheckEvent extends VerboseEvent {
|
||||
|
||||
/**
|
||||
@ -72,7 +74,7 @@ public class PermissionCheckEvent extends VerboseEvent {
|
||||
object.add("type", "permission");
|
||||
object.add("permission", this.permission);
|
||||
|
||||
object.add("result", this.result.result().name().toLowerCase());
|
||||
object.add("result", this.result.result().name().toLowerCase(Locale.ROOT));
|
||||
if (this.result.processorClass() != null || this.result.cause() != null) {
|
||||
JObject resultInfo = new JObject();
|
||||
if (this.result.processorClass() != null) {
|
||||
@ -84,14 +86,14 @@ public class PermissionCheckEvent extends VerboseEvent {
|
||||
object.add("resultInfo", resultInfo);
|
||||
}
|
||||
|
||||
object.add("origin", this.origin.name().toLowerCase());
|
||||
object.add("origin", this.origin.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eval(String variable) {
|
||||
return variable.equals("permission") ||
|
||||
getCheckTarget().describe().equalsIgnoreCase(variable) ||
|
||||
getPermission().toLowerCase().startsWith(variable.toLowerCase()) ||
|
||||
getPermission().toLowerCase(Locale.ROOT).startsWith(variable.toLowerCase(Locale.ROOT)) ||
|
||||
getResult().result().name().equalsIgnoreCase(variable);
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ import net.luckperms.api.context.Context;
|
||||
import net.luckperms.api.query.QueryMode;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -113,7 +114,7 @@ public abstract class VerboseEvent implements VariableEvaluator {
|
||||
}
|
||||
})
|
||||
)
|
||||
.add("queryMode", this.checkQueryOptions.mode().name().toLowerCase())
|
||||
.add("queryMode", this.checkQueryOptions.mode().name().toLowerCase(Locale.ROOT))
|
||||
.consume(obj -> {
|
||||
if (this.checkQueryOptions.mode() == QueryMode.CONTEXTUAL) {
|
||||
obj.add("context", new JArray()
|
||||
|
@ -29,6 +29,8 @@ import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class EnumNamerTest {
|
||||
@ -38,7 +40,7 @@ public class EnumNamerTest {
|
||||
EnumNamer<TestEnum> namer = new EnumNamer<>(
|
||||
TestEnum.class,
|
||||
ImmutableMap.of(TestEnum.THING, "hi"),
|
||||
v -> v.name().toLowerCase().replace('_', '-')
|
||||
v -> v.name().toLowerCase(Locale.ROOT).replace('_', '-')
|
||||
);
|
||||
|
||||
assertEquals("test", namer.name(TestEnum.TEST));
|
||||
|
@ -47,6 +47,7 @@ import cn.nukkit.event.entity.EntityLevelChangeEvent;
|
||||
import cn.nukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import cn.nukkit.level.Level;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
public class NukkitPlayerCalculator implements ContextCalculator<Player>, Listener {
|
||||
@ -111,7 +112,7 @@ public class NukkitPlayerCalculator implements ContextCalculator<Player>, Listen
|
||||
case Player.CREATIVE: return "creative";
|
||||
case Player.ADVENTURE: return "adventure";
|
||||
case Player.SPECTATOR: return "spectator";
|
||||
default: return Server.getGamemodeString(mode, true).toLowerCase();
|
||||
default: return Server.getGamemodeString(mode, true).toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import cn.nukkit.permission.Permission;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -84,7 +85,7 @@ public enum PermissionDefault {
|
||||
* @return Specified value, or null if not found
|
||||
*/
|
||||
public static @Nullable PermissionDefault getByName(String name) {
|
||||
return LOOKUP.get(name.toLowerCase().replaceAll("[^a-z!]", ""));
|
||||
return LOOKUP.get(name.toLowerCase(Locale.ROOT).replaceAll("[^a-z!]", ""));
|
||||
}
|
||||
|
||||
public static @Nullable PermissionDefault fromPermission(@Nullable Permission permission) {
|
||||
|
@ -47,6 +47,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@ -238,7 +239,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
Objects.requireNonNull(name, "name is null");
|
||||
Preconditions.checkArgument(!name.isEmpty(), "name is empty");
|
||||
|
||||
String permission = name.toLowerCase();
|
||||
String permission = name.toLowerCase(Locale.ROOT);
|
||||
|
||||
Boolean previous = this.perms.put(permission, value);
|
||||
if (previous != null && previous == value) {
|
||||
@ -275,7 +276,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
Objects.requireNonNull(name, "name is null");
|
||||
Preconditions.checkArgument(!name.isEmpty(), "name is empty");
|
||||
|
||||
String permission = name.toLowerCase();
|
||||
String permission = name.toLowerCase(Locale.ROOT);
|
||||
|
||||
Boolean previous = this.perms.remove(permission);
|
||||
if (previous == null) {
|
||||
|
@ -40,6 +40,7 @@ import cn.nukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -159,7 +160,7 @@ public final class LuckPermsDefaultsMap {
|
||||
protected @NonNull Map<String, Boolean> supply() {
|
||||
Map<String, Boolean> builder = new HashMap<>();
|
||||
for (Permission perm : LuckPermsDefaultsMap.this.get(this.op).values()) {
|
||||
String name = perm.getName().toLowerCase();
|
||||
String name = perm.getName().toLowerCase(Locale.ROOT);
|
||||
builder.put(name, true);
|
||||
for (Map.Entry<String, Boolean> child : LuckPermsDefaultsMap.this.plugin.getPermissionMap().getChildPermissions(name, true).entrySet()) {
|
||||
builder.putIfAbsent(child.getKey(), child.getValue());
|
||||
|
@ -41,6 +41,7 @@ import cn.nukkit.plugin.PluginManager;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -180,7 +181,7 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
||||
continue;
|
||||
}
|
||||
|
||||
String key = e.getKey().toLowerCase();
|
||||
String key = e.getKey().toLowerCase(Locale.ROOT);
|
||||
|
||||
if (accumulator.containsKey(key)) {
|
||||
continue; // Prevent infinite loops
|
||||
|
@ -37,6 +37,7 @@ import cn.nukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import cn.nukkit.event.server.RemoteServerCommandEvent;
|
||||
import cn.nukkit.event.server.ServerCommandEvent;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class NukkitPlatformListener implements Listener {
|
||||
@ -50,17 +51,17 @@ public class NukkitPlatformListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
|
||||
handleCommand(e.getPlayer(), e.getMessage().toLowerCase(), e);
|
||||
handleCommand(e.getPlayer(), e.getMessage().toLowerCase(Locale.ROOT), e);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onServerCommand(ServerCommandEvent e) {
|
||||
handleCommand(e.getSender(), e.getCommand().toLowerCase(), e);
|
||||
handleCommand(e.getSender(), e.getCommand().toLowerCase(Locale.ROOT), e);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onRemoteServerCommand(RemoteServerCommandEvent e) {
|
||||
handleCommand(e.getSender(), e.getCommand().toLowerCase(), e);
|
||||
handleCommand(e.getSender(), e.getCommand().toLowerCase(Locale.ROOT), e);
|
||||
}
|
||||
|
||||
private void handleCommand(CommandSender sender, String cmdLine, Cancellable event) {
|
||||
|
@ -44,6 +44,7 @@ import org.spongepowered.api.service.permission.SubjectCollection;
|
||||
import org.spongepowered.api.service.permission.SubjectReference;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@ -85,12 +86,12 @@ public final class PermissionServiceProxy implements PermissionService, ProxiedS
|
||||
|
||||
@Override
|
||||
public @NonNull Optional<SubjectCollection> getCollection(String s) {
|
||||
return Optional.ofNullable(this.handle.getLoadedCollections().get(s.toLowerCase())).map(LPSubjectCollection::sponge);
|
||||
return Optional.ofNullable(this.handle.getLoadedCollections().get(s.toLowerCase(Locale.ROOT))).map(LPSubjectCollection::sponge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> hasCollection(String s) {
|
||||
return CompletableFuture.completedFuture(this.handle.getLoadedCollections().containsKey(s.toLowerCase()));
|
||||
return CompletableFuture.completedFuture(this.handle.getLoadedCollections().containsKey(s.toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -113,7 +114,7 @@ public final class PermissionServiceProxy implements PermissionService, ProxiedS
|
||||
Objects.requireNonNull(subjectIdentifier, "subjectIdentifier");
|
||||
|
||||
// test the identifiers
|
||||
String collection = collectionIdentifier.toLowerCase();
|
||||
String collection = collectionIdentifier.toLowerCase(Locale.ROOT);
|
||||
if (collection.equals("user") && !this.handle.getUserSubjects().getIdentifierValidityPredicate().test(subjectIdentifier)) {
|
||||
throw new IllegalArgumentException("Subject identifier '" + subjectIdentifier + "' does not pass the validity predicate for the user subject collection");
|
||||
} else if (collection.equals("group") && !this.handle.getGroupSubjects().getIdentifierValidityPredicate().test(subjectIdentifier)) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user