General tidy up

This commit is contained in:
Luck 2017-11-18 23:20:42 +00:00
parent 987ea51264
commit 6ca9eb13dd
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
130 changed files with 850 additions and 763 deletions

View File

@ -25,8 +25,8 @@
package me.lucko.luckperms.api;
import me.lucko.luckperms.api.caching.CachedData;
import me.lucko.luckperms.api.caching.MetaContexts;
import me.lucko.luckperms.api.caching.UserData;
import me.lucko.luckperms.api.context.ContextSet;
import javax.annotation.Nonnull;
@ -36,9 +36,9 @@ import javax.annotation.Nonnull;
*
* <p></p>
* <ul>
* <li>{@link UserData#getPermissionData(Contexts)}</li>
* <li>{@link UserData#getMetaData(Contexts)}</li>
* <li>{@link UserData#getMetaData(MetaContexts)}</li>
* <li>{@link CachedData#getPermissionData(Contexts)}</li>
* <li>{@link CachedData#getMetaData(Contexts)}</li>
* <li>{@link CachedData#getMetaData(MetaContexts)}</li>
* </ul>
*
* <p>... will always satisfy all contextual requirements.</p>

View File

@ -30,7 +30,6 @@ import com.google.common.base.Splitter;
import me.lucko.luckperms.common.commands.CommandManager;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -54,7 +53,7 @@ public class BukkitCommandExecutor extends CommandManager implements CommandExec
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Sender lpSender = plugin.getSenderFactory().wrap(sender);
List<String> arguments = Util.stripQuotes(ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
List<String> arguments = stripQuotes(ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
onCommand(lpSender, label, arguments);
return true;
@ -63,7 +62,7 @@ public class BukkitCommandExecutor extends CommandManager implements CommandExec
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
Sender lpSender = plugin.getSenderFactory().wrap(sender);
List<String> arguments = Util.stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
List<String> arguments = stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
return onTabComplete(lpSender, arguments);
}

View File

@ -27,7 +27,7 @@ package me.lucko.luckperms.bukkit.migration;
import lombok.experimental.UtilityClass;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.logging.ProgressLogger;
import org.bukkit.Bukkit;
@ -39,7 +39,7 @@ public class BukkitMigrationUtils {
@SuppressWarnings("deprecation")
public static UUID lookupUuid(ProgressLogger log, String s) {
UUID uuid = Util.parseUuid(s);
UUID uuid = CommandUtils.parseUuid(s);
if (uuid == null) {
try {
uuid = Bukkit.getOfflinePlayer(s).getUniqueId();

View File

@ -31,7 +31,7 @@ import me.lucko.luckperms.api.ChatMetaType;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.caching.MetaData;
import me.lucko.luckperms.common.caching.MetaAccumulator;
import me.lucko.luckperms.common.caching.type.MetaAccumulator;
import me.lucko.luckperms.common.model.Group;
import me.lucko.luckperms.common.model.PermissionHolder;
import me.lucko.luckperms.common.model.User;
@ -42,8 +42,6 @@ import net.milkbowl.vault.chat.Chat;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.Map;
/**
* An implementation of the Vault {@link Chat} API using LuckPerms.
*
@ -85,7 +83,7 @@ public class VaultChatHook extends Chat {
@Override
public String getPlayerPrefix(String world, @NonNull String player) {
final User user = getUser(player);
return getUserChatMeta(user, ChatMetaType.PREFIX, world);
return getHolderChatMeta(user, ChatMetaType.PREFIX, world);
}
@Override
@ -97,7 +95,7 @@ public class VaultChatHook extends Chat {
@Override
public String getPlayerSuffix(String world, @NonNull String player) {
final User user = getUser(player);
return getUserChatMeta(user, ChatMetaType.SUFFIX, world);
return getHolderChatMeta(user, ChatMetaType.SUFFIX, world);
}
@Override
@ -109,7 +107,7 @@ public class VaultChatHook extends Chat {
@Override
public String getGroupPrefix(String world, @NonNull String group) {
final Group g = perms.getPlugin().getGroupManager().getByDisplayName(group);
return getGroupChatMeta(g, ChatMetaType.PREFIX, world);
return getHolderChatMeta(g, ChatMetaType.PREFIX, world);
}
@Override
@ -121,7 +119,7 @@ public class VaultChatHook extends Chat {
@Override
public String getGroupSuffix(String world, @NonNull String group) {
final Group g = perms.getPlugin().getGroupManager().getByDisplayName(group);
return getGroupChatMeta(g, ChatMetaType.SUFFIX, world);
return getHolderChatMeta(g, ChatMetaType.SUFFIX, world);
}
@Override
@ -134,7 +132,7 @@ public class VaultChatHook extends Chat {
public int getPlayerInfoInteger(String world, @NonNull String player, @NonNull String node, int defaultValue) {
final User user = getUser(player);
try {
return Integer.parseInt(getUserMeta(user, node, world, String.valueOf(defaultValue)));
return Integer.parseInt(getHolderMeta(user, node, world, String.valueOf(defaultValue)));
} catch (NumberFormatException e) {
return defaultValue;
}
@ -150,7 +148,7 @@ public class VaultChatHook extends Chat {
public int getGroupInfoInteger(String world, @NonNull String group, @NonNull String node, int defaultValue) {
final Group g = perms.getPlugin().getGroupManager().getByDisplayName(group);
try {
return Integer.parseInt(getGroupMeta(g, node, world, String.valueOf(defaultValue)));
return Integer.parseInt(getHolderMeta(g, node, world, String.valueOf(defaultValue)));
} catch (NumberFormatException e) {
return defaultValue;
}
@ -166,7 +164,7 @@ public class VaultChatHook extends Chat {
public double getPlayerInfoDouble(String world, @NonNull String player, @NonNull String node, double defaultValue) {
final User user = getUser(player);
try {
return Double.parseDouble(getUserMeta(user, node, world, String.valueOf(defaultValue)));
return Double.parseDouble(getHolderMeta(user, node, world, String.valueOf(defaultValue)));
} catch (NumberFormatException e) {
return defaultValue;
}
@ -182,7 +180,7 @@ public class VaultChatHook extends Chat {
public double getGroupInfoDouble(String world, @NonNull String group, @NonNull String node, double defaultValue) {
final Group g = perms.getPlugin().getGroupManager().getByDisplayName(group);
try {
return Double.parseDouble(getGroupMeta(g, node, world, String.valueOf(defaultValue)));
return Double.parseDouble(getHolderMeta(g, node, world, String.valueOf(defaultValue)));
} catch (NumberFormatException e) {
return defaultValue;
}
@ -197,7 +195,7 @@ public class VaultChatHook extends Chat {
@Override
public boolean getPlayerInfoBoolean(String world, @NonNull String player, @NonNull String node, boolean defaultValue) {
final User user = getUser(player);
String s = getUserMeta(user, node, world, String.valueOf(defaultValue));
String s = getHolderMeta(user, node, world, String.valueOf(defaultValue));
if (!s.equalsIgnoreCase("true") && !s.equalsIgnoreCase("false")) {
return defaultValue;
}
@ -213,7 +211,7 @@ public class VaultChatHook extends Chat {
@Override
public boolean getGroupInfoBoolean(String world, @NonNull String group, @NonNull String node, boolean defaultValue) {
final Group g = perms.getPlugin().getGroupManager().getByDisplayName(group);
String s = getGroupMeta(g, node, world, String.valueOf(defaultValue));
String s = getHolderMeta(g, node, world, String.valueOf(defaultValue));
if (!s.equalsIgnoreCase("true") && !s.equalsIgnoreCase("false")) {
return defaultValue;
}
@ -229,7 +227,7 @@ public class VaultChatHook extends Chat {
@Override
public String getPlayerInfoString(String world, @NonNull String player, @NonNull String node, String defaultValue) {
final User user = getUser(player);
return getUserMeta(user, node, world, defaultValue);
return getHolderMeta(user, node, world, defaultValue);
}
@Override
@ -241,7 +239,7 @@ public class VaultChatHook extends Chat {
@Override
public String getGroupInfoString(String world, @NonNull String group, @NonNull String node, String defaultValue) {
final Group g = perms.getPlugin().getGroupManager().getByDisplayName(group);
return getGroupMeta(g, node, world, defaultValue);
return getHolderMeta(g, node, world, defaultValue);
}
@Override
@ -296,78 +294,43 @@ public class VaultChatHook extends Chat {
});
}
private String getUserMeta(User user, String node, String world, String defaultValue) {
if (user == null) {
private String getHolderMeta(PermissionHolder holder, String node, String world, String defaultValue) {
if (holder == null) {
return defaultValue;
}
world = perms.correctWorld(world);
perms.log("Getting meta: '" + node + "' for user " + user.getFriendlyName() + " on world " + world + ", server " + perms.getServer());
perms.log("Getting meta: '" + node + "' for holder " + holder.getFriendlyName() + " on world " + world + ", server " + perms.getServer());
String ret = user.getCachedData().getMetaData(perms.createContextForWorldLookup(perms.getPlugin().getPlayer(user), world)).getMeta().get(node);
Contexts contexts;
if (holder instanceof User) {
contexts = perms.createContextForWorldLookup(perms.getPlugin().getPlayer((User) holder), world);
} else {
contexts = perms.createContextForWorldLookup(world);
}
String ret = holder.getCachedData().getMetaData(contexts).getMeta().get(node);
return ret != null ? ret : defaultValue;
}
private String getUserChatMeta(User user, ChatMetaType type, String world) {
if (user == null) {
private String getHolderChatMeta(PermissionHolder holder, ChatMetaType type, String world) {
if (holder == null) {
return "";
}
world = perms.correctWorld(world);
perms.log("Getting " + type.name().toLowerCase() + " for user " + user.getFriendlyName() + " on world " + world + ", server " + perms.getServer());
perms.log("Getting " + type.name().toLowerCase() + " for holder " + holder.getFriendlyName() + " on world " + world + ", server " + perms.getServer());
MetaData data = user.getCachedData().getMetaData(perms.createContextForWorldLookup(perms.getPlugin().getPlayer(user), world));
Contexts contexts;
if (holder instanceof User) {
contexts = perms.createContextForWorldLookup(perms.getPlugin().getPlayer((User) holder), world);
} else {
contexts = perms.createContextForWorldLookup(world);
}
MetaData data = holder.getCachedData().getMetaData(contexts);
String ret = type == ChatMetaType.PREFIX ? data.getPrefix() : data.getSuffix();
return ret != null ? ret : "";
}
private String getGroupMeta(Group group, String node, String world, String defaultValue) {
if (group == null || node.equals("")) {
return defaultValue;
}
world = perms.correctWorld(world);
perms.log("Getting meta: '" + node + "' for group " + group.getName() + " on world " + world + ", server " + perms.getServer());
for (Node n : group.getOwnNodes()) {
if (!n.getValuePrimitive()) continue;
if (!n.isMeta()) continue;
if (!n.shouldApplyWithContext(perms.createContextForWorldLookup(world).getContexts())) continue;
Map.Entry<String, String> meta = n.getMeta();
if (meta.getKey().equalsIgnoreCase(node)) {
return meta.getValue();
}
}
return defaultValue;
}
private String getGroupChatMeta(Group group, ChatMetaType type, String world) {
if (group == null) {
return "";
}
world = perms.correctWorld(world);
perms.log("Getting " + type.name().toLowerCase() + " for group " + group + " on world " + world + ", server " + perms.getServer());
int priority = Integer.MIN_VALUE;
String meta = null;
Contexts contexts = Contexts.of(perms.createContextForWorldLookup(world).getContexts(), perms.isIncludeGlobal(), true, true, true, true, false);
for (Node n : group.getAllNodes(contexts)) {
if (!n.getValuePrimitive()) continue;
if (type.shouldIgnore(n)) continue;
if (!n.shouldApplyWithContext(perms.createContextForWorldLookup(world).getContexts())) continue;
Map.Entry<Integer, String> value = type.getEntry(n);
if (value.getKey() > priority) {
meta = value.getValue();
priority = value.getKey();
}
}
return meta != null ? meta : "";
}
}

View File

@ -29,8 +29,8 @@ import me.lucko.luckperms.bukkit.LPBukkitPlugin;
import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
/**
@ -39,7 +39,7 @@ import java.util.concurrent.Executor;
public class VaultExecutor implements Runnable, Executor {
private BukkitTask task = null;
private final List<Runnable> tasks = new ArrayList<>();
private final Queue<Runnable> tasks = new ConcurrentLinkedQueue<>();
public VaultExecutor(LPBukkitPlugin plugin) {
task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, this, 1L, 1L);
@ -47,25 +47,12 @@ public class VaultExecutor implements Runnable, Executor {
@Override
public void execute(Runnable r) {
synchronized (tasks) {
tasks.add(r);
}
tasks.offer(r);
}
@Override
public void run() {
List<Runnable> toRun;
synchronized (tasks) {
if (tasks.isEmpty()) {
return;
}
toRun = new ArrayList<>(tasks.size());
toRun.addAll(tasks);
tasks.clear();
}
for (Runnable runnable : toRun) {
for (Runnable runnable; (runnable = tasks.poll()) != null; ) {
try {
runnable.run();
} catch (Exception e) {

View File

@ -30,7 +30,6 @@ import com.google.common.base.Splitter;
import me.lucko.luckperms.common.commands.CommandManager;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command;
@ -55,7 +54,7 @@ public class BungeeCommandExecutor extends Command implements TabExecutor {
@Override
public void execute(CommandSender sender, String[] args) {
Sender lpSender = plugin.getSenderFactory().wrap(sender);
List<String> arguments = Util.stripQuotes(ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
List<String> arguments = CommandManager.stripQuotes(ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
manager.onCommand(lpSender, "lpb", arguments);
}
@ -63,7 +62,7 @@ public class BungeeCommandExecutor extends Command implements TabExecutor {
@Override
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
Sender lpSender = plugin.getSenderFactory().wrap(sender);
List<String> arguments = Util.stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
List<String> arguments = CommandManager.stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
return manager.onTabComplete(lpSender, arguments);
}

View File

@ -51,7 +51,7 @@ public class BungeePermissionCheckListener implements Listener {
return;
}
final ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
User user = plugin.getUserManager().getIfLoaded(plugin.getUuidCache().getUUID(player.getUniqueId()));
if (user == null) {
@ -74,7 +74,7 @@ public class BungeePermissionCheckListener implements Listener {
return;
}
final ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
User user = plugin.getUserManager().getIfLoaded(plugin.getUuidCache().getUUID(player.getUniqueId()));
if (user == null) {

View File

@ -76,14 +76,6 @@ public class ExtendedLogEntry implements LogEntry {
.thenComparing(LogEntry::getActedName, String.CASE_INSENSITIVE_ORDER)
.thenComparing(LogEntry::getAction);
/**
* Compares two LogEntries in reverse order
*
* @since 3.3
* @see #COMPARATOR
*/
public static final Comparator<LogEntry> REVERSE_ORDER = COMPARATOR.reversed();
/**
* Creates a new log entry builder
*

View File

@ -0,0 +1,151 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.assignments;
import com.google.common.collect.ImmutableList;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.common.model.PermissionHolder;
import me.lucko.luckperms.common.node.LegacyNodeFactory;
import me.lucko.luckperms.common.utils.Scripting;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.script.ScriptEngine;
public class AssignmentExpression {
public static AssignmentExpression compile(String expression) {
return new AssignmentExpression(expression);
}
private final List<Token> expression;
private AssignmentExpression(String expression) {
this.expression = generateExpression(expression);
}
public boolean parse(PermissionHolder holder, Tristate tristate) throws IllegalArgumentException {
ScriptEngine engine = Scripting.getScriptEngine();
if (engine == null) {
throw new NullPointerException("script engine");
}
Predicate<Node> checker = node -> holder.hasPermission(node) == tristate;
String exp = expression.stream().map(t -> t.forExpression(checker)).collect(Collectors.joining())
.replace("&", "&&").replace("|", "||");
try {
String result = engine.eval(exp).toString();
if (!result.equals("true") && !result.equals("false")) {
throw new IllegalArgumentException();
}
return Boolean.parseBoolean(result);
} catch (Throwable t) {
throw new IllegalArgumentException(exp, t);
}
}
private static List<Token> generateExpression(String input) {
ImmutableList.Builder<Token> exp = ImmutableList.builder();
while (true) {
int start = input.indexOf("<");
int end = input.indexOf(">");
if (start == -1 || end == -1) {
break;
}
if (start != 0) {
Token before = new StringToken(input.substring(0, start));
exp.add(before);
}
String match = input.substring(start, end + 1);
String matchContent = match.substring(1, match.length() - 1);
Token permission = new PermissionToken(matchContent);
exp.add(permission);
input = input.substring(end + 1);
}
if (!input.isEmpty()) {
exp.add(new StringToken(input));
}
return exp.build();
}
private interface Token {
String forExpression(Predicate<Node> checker);
}
private static final class StringToken implements Token {
private final String string;
private StringToken(String string) {
this.string = string;
}
@Override
public String forExpression(Predicate<Node> checker) {
return string;
}
@Override
public String toString() {
return string;
}
}
private static final class PermissionToken implements Token {
private final String permission;
private final Node node;
private PermissionToken(String permission) {
this.permission = permission;
this.node = LegacyNodeFactory.fromSerializedNode(permission, true);
}
@Override
public String forExpression(Predicate<Node> checker) {
return Boolean.toString(checker.test(node));
}
@Override
public String toString() {
return "<" + permission + ">";
}
}
}

View File

@ -23,34 +23,43 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.defaults;
package me.lucko.luckperms.common.assignments;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.node.NodeFactory;
import me.lucko.luckperms.common.node.LegacyNodeFactory;
import me.lucko.luckperms.common.utils.ImmutableCollectors;
import java.util.List;
@Getter
@ToString
@AllArgsConstructor
public class Rule {
private final String hasTrueExpression;
private final String hasFalseExpression;
private final String lacksExpression;
public class AssignmentRule {
private final AssignmentExpression hasTrueExpression;
private final AssignmentExpression hasFalseExpression;
private final AssignmentExpression lacksExpression;
private final List<String> toGive;
private final List<String> toTake;
private final List<Node> toGive;
private final List<Node> toTake;
private final String setPrimaryGroup;
public AssignmentRule(String hasTrueExpression, String hasFalseExpression, String lacksExpression, List<String> toGive, List<String> toTake, String setPrimaryGroup) {
this.hasTrueExpression = AssignmentExpression.compile(hasTrueExpression);
this.hasFalseExpression = AssignmentExpression.compile(hasFalseExpression);
this.lacksExpression = AssignmentExpression.compile(lacksExpression);
this.toGive = toGive.stream().map(s -> LegacyNodeFactory.fromSerializedNode(s, true)).collect(ImmutableCollectors.toImmutableList());;
this.toTake = toTake.stream().map(s -> LegacyNodeFactory.fromSerializedNode(s, true)).collect(ImmutableCollectors.toImmutableList());
this.setPrimaryGroup = setPrimaryGroup;
}
public boolean apply(User user) {
if (hasTrueExpression != null) {
try {
boolean b = LogicParser.parse(hasTrueExpression, user, Tristate.TRUE);
boolean b = hasTrueExpression.parse(user, Tristate.TRUE);
if (!b) {
// The holder does not meet this requirement
return false;
@ -64,7 +73,7 @@ public class Rule {
if (hasFalseExpression != null) {
try {
boolean b = LogicParser.parse(hasFalseExpression, user, Tristate.FALSE);
boolean b = hasFalseExpression.parse(user, Tristate.FALSE);
if (!b) {
// The holder does not meet this requirement
return false;
@ -78,7 +87,7 @@ public class Rule {
if (lacksExpression != null) {
try {
boolean b = LogicParser.parse(lacksExpression, user, Tristate.UNDEFINED);
boolean b = lacksExpression.parse(user, Tristate.UNDEFINED);
if (!b) {
// The holder does not meet this requirement
return false;
@ -91,12 +100,12 @@ public class Rule {
}
// The holder meets all of the requirements of this rule.
for (String s : toTake) {
user.unsetPermission(NodeFactory.fromSerializedNode(s, true));
for (Node n : toTake) {
user.unsetPermission(n);
}
for (String s : toGive) {
user.setPermission(NodeFactory.fromSerializedNode(s, true));
for (Node n : toGive) {
user.setPermission(n);
}
if (setPrimaryGroup != null) {

View File

@ -38,19 +38,19 @@ import net.kyori.text.Component;
import java.util.UUID;
@Getter
public abstract class ImporterSender implements Sender {
public abstract class DummySender implements Sender {
private final LuckPermsPlugin platform;
private final UUID uuid;
private final String name;
public ImporterSender(LuckPermsPlugin plugin, UUID uuid, String name) {
public DummySender(LuckPermsPlugin plugin, UUID uuid, String name) {
this.platform = plugin;
this.uuid = uuid;
this.name = name;
}
public ImporterSender(LuckPermsPlugin plugin) {
public DummySender(LuckPermsPlugin plugin) {
this(plugin, Constants.IMPORT_UUID, Constants.IMPORT_NAME);
}

View File

@ -27,7 +27,7 @@ package me.lucko.luckperms.common.backup;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.locale.Message;
import me.lucko.luckperms.common.logging.ProgressLogger;
import me.lucko.luckperms.common.model.Group;
@ -180,7 +180,7 @@ public class Exporter implements Runnable {
write(writer, "# Export users");
// divide into 16 pools.
Cycle<List<UUID>> userPools = new Cycle<>(Util.nInstances(32, ArrayList::new));
Cycle<List<UUID>> userPools = new Cycle<>(CommandUtils.nInstances(32, ArrayList::new));
for (UUID uuid : users) {
userPools.next().add(uuid);
}

View File

@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableSet;
import me.lucko.luckperms.common.commands.CommandManager;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.locale.Message;
import me.lucko.luckperms.common.utils.Cycle;
@ -97,7 +97,7 @@ public class Importer implements Runnable {
}
// divide commands up into pools
Cycle<List<ImportCommand>> commandPools = new Cycle<>(Util.nInstances(128, ArrayList::new));
Cycle<List<ImportCommand>> commandPools = new Cycle<>(CommandUtils.nInstances(128, ArrayList::new));
String lastTarget = null;
for (ImportCommand cmd : toExecute) {
@ -191,7 +191,7 @@ public class Importer implements Runnable {
}
@Getter
private static class ImportCommand extends ImporterSender {
private static class ImportCommand extends DummySender {
private static final Splitter SPACE_SPLIT = Splitter.on(" ");
private final CommandManager commandManager;
@ -230,7 +230,7 @@ public class Importer implements Runnable {
CommandResult result = commandManager.onCommand(
this,
"lp",
Util.stripQuotes(Splitter.on(CommandManager.COMMAND_SEPARATOR_PATTERN).omitEmptyStrings().splitToList(getCommand()))
CommandManager.stripQuotes(Splitter.on(CommandManager.COMMAND_SEPARATOR_PATTERN).omitEmptyStrings().splitToList(getCommand()))
).get();
setResult(result);

View File

@ -31,9 +31,9 @@ import me.lucko.luckperms.common.model.Group;
/**
* Holds an easily accessible cache of a groups's data in a number of contexts
*/
public class GroupCache extends HolderCache<Group> implements GroupData {
public class GroupCachedData extends HolderCachedData<Group> implements GroupData {
public GroupCache(Group holder) {
public GroupCachedData(Group holder) {
super(holder);
}

View File

@ -36,6 +36,9 @@ import me.lucko.luckperms.api.ChatMetaType;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.caching.CachedData;
import me.lucko.luckperms.api.caching.MetaContexts;
import me.lucko.luckperms.common.caching.type.MetaAccumulator;
import me.lucko.luckperms.common.caching.type.MetaCache;
import me.lucko.luckperms.common.caching.type.PermissionCache;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.metastacking.SimpleMetaStack;
import me.lucko.luckperms.common.model.PermissionHolder;
@ -50,7 +53,7 @@ import java.util.concurrent.TimeUnit;
* Holds an easily accessible cache of a holders data in a number of contexts
*/
@RequiredArgsConstructor
public abstract class HolderCache<T extends PermissionHolder> implements CachedData {
public abstract class HolderCachedData<T extends PermissionHolder> implements CachedData {
/**
* The holder whom this data instance is representing

View File

@ -31,9 +31,9 @@ import me.lucko.luckperms.common.model.User;
/**
* Holds an easily accessible cache of a user's data in a number of contexts
*/
public class UserCache extends HolderCache<User> implements UserData {
public class UserCachedData extends HolderCachedData<User> implements UserData {
public UserCache(User holder) {
public UserCachedData(User holder) {
super(holder);
}

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.caching;
package me.lucko.luckperms.common.caching.type;
import lombok.AccessLevel;
import lombok.Getter;

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.caching;
package me.lucko.luckperms.common.caching.type;
import lombok.AccessLevel;
import lombok.Getter;

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.caching;
package me.lucko.luckperms.common.caching.type;
import lombok.NonNull;

View File

@ -55,7 +55,7 @@ import me.lucko.luckperms.common.commands.impl.track.TrackMainCommand;
import me.lucko.luckperms.common.commands.impl.user.UserMainCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -70,6 +70,7 @@ import net.kyori.text.event.HoverEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Pattern;
@ -240,7 +241,7 @@ public class CommandManager {
}
private void sendCommandUsage(Sender sender, String label) {
Util.sendPluginMessage(sender, "&2Running &bLuckPerms v" + plugin.getVersion() + "&2.");
CommandUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + plugin.getVersion() + "&2.");
mainCommands.stream()
.filter(Command::shouldDisplay)
.filter(c -> c.isAuthorized(sender))
@ -358,6 +359,9 @@ public class CommandManager {
args.remove(2);
args.add(2, "parent");
break;
case "e":
args.remove(2);
args.add(2, "editor");
// Provide backwards compatibility
case "setprimarygroup":
@ -465,4 +469,27 @@ public class CommandManager {
}
}
}
/**
* Strips outer quote marks from a list of parsed arguments.
*
* @param input the list of arguments to strip quotes from
* @return an ArrayList containing the contents of input without quotes
*/
public static List<String> stripQuotes(List<String> input) {
input = new ArrayList<>(input);
ListIterator<String> iterator = input.listIterator();
while (iterator.hasNext()) {
String value = iterator.next();
if (value.length() < 3) {
continue;
}
if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') {
iterator.set(value.substring(1, value.length() - 1));
}
}
return input;
}
}

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandManager;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.locale.LocalizedSpec;
import me.lucko.luckperms.common.locale.Message;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -173,7 +173,7 @@ public abstract class MainCommand<T, I> extends Command<Void, T> {
.collect(Collectors.toList());
if (subs.size() > 0) {
Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format(getUsage(), label) + " ...)");
CommandUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format(getUsage(), label) + " ...)");
for (Command s : subs) {
s.sendUsage(sender, label);

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.locale.LocalizedSpec;
import me.lucko.luckperms.common.locale.Message;
import me.lucko.luckperms.common.model.PermissionHolder;
@ -147,9 +147,9 @@ public class SharedMainCommand<T extends PermissionHolder> extends SubCommand<T>
if (subs.size() > 0) {
if (user) {
Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s user <user> " + getName().toLowerCase() + " ...)", label));
CommandUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s user <user> " + getName().toLowerCase() + " ...)", label));
} else {
Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s group <group> " + getName().toLowerCase() + " ...)", label));
CommandUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s group <group> " + getName().toLowerCase() + " ...)", label));
}
for (SharedSubCommand s : subs) {

View File

@ -31,7 +31,7 @@ import me.lucko.luckperms.common.commands.Arg;
import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.LocalizedSpec;
import me.lucko.luckperms.common.model.Group;
@ -91,16 +91,16 @@ public abstract class SharedSubCommand {
}
}
Util.sendPluginMessage(sender, "&3> &a" + getName() + sb.toString());
CommandUtils.sendPluginMessage(sender, "&3> &a" + getName() + sb.toString());
}
public void sendDetailedUsage(Sender sender) {
Util.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
Util.sendPluginMessage(sender, "&b> &7" + getDescription());
CommandUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
CommandUtils.sendPluginMessage(sender, "&b> &7" + getDescription());
if (getArgs() != null) {
Util.sendPluginMessage(sender, "&3Arguments:");
CommandUtils.sendPluginMessage(sender, "&3Arguments:");
for (Arg arg : getArgs()) {
Util.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
CommandUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
}
}
}

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.common.commands.Arg;
import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.LocalizedSpec;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -63,17 +63,17 @@ public abstract class SingleCommand extends Command<Void, Void> {
}
}
Util.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString());
CommandUtils.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString());
}
@Override
public void sendDetailedUsage(Sender sender, String label) {
Util.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
Util.sendPluginMessage(sender, "&b> &7" + getDescription());
CommandUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
CommandUtils.sendPluginMessage(sender, "&b> &7" + getDescription());
if (getArgs().isPresent()) {
Util.sendPluginMessage(sender, "&3Arguments:");
CommandUtils.sendPluginMessage(sender, "&3Arguments:");
for (Arg arg : getArgs().get()) {
Util.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
CommandUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
}
}
}

View File

@ -31,7 +31,7 @@ import com.google.common.base.Splitter;
import me.lucko.luckperms.common.commands.Arg;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.LocalizedSpec;
@ -78,17 +78,17 @@ public abstract class SubCommand<T> extends Command<T, Void> {
}
}
Util.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString());
CommandUtils.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString());
}
@Override
public void sendDetailedUsage(Sender sender, String label) {
Util.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
Util.sendPluginMessage(sender, "&b> &7" + getDescription());
CommandUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName());
CommandUtils.sendPluginMessage(sender, "&b> &7" + getDescription());
if (getArgs().isPresent()) {
Util.sendPluginMessage(sender, "&3Arguments:");
CommandUtils.sendPluginMessage(sender, "&3Arguments:");
for (Arg arg : getArgs().get()) {
Util.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
CommandUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription());
}
}
}

View File

@ -35,7 +35,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -84,7 +84,7 @@ public class MetaAddChatMeta extends SharedSubCommand {
DataMutateResult result = holder.setPermission(NodeFactory.makeChatMetaNode(type, priority, meta).withExtraContext(context).build());
if (result.asBoolean()) {
TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder();
TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder();
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
'¥'
@ -99,7 +99,7 @@ public class MetaAddChatMeta extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.ALREADY_HAS_CHAT_META.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context));
Message.ALREADY_HAS_CHAT_META.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -36,7 +36,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
@ -94,7 +94,7 @@ public class MetaAddTempChatMeta extends SharedSubCommand {
if (ret.getKey().asBoolean()) {
duration = ret.getValue().getExpiryUnixTime();
TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, DateUtil.formatDateDiff(duration), Util.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder();
TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder();
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
'¥'
@ -109,7 +109,7 @@ public class MetaAddTempChatMeta extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.ALREADY_HAS_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context));
Message.ALREADY_HAS_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -33,7 +33,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -102,9 +102,9 @@ public class MetaClear extends SharedSubCommand {
int changed = before - holder.getEnduringNodes().size();
if (changed == 1) {
Message.META_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), Util.contextSetToString(context), changed);
Message.META_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), CommandUtils.contextSetToString(context), changed);
} else {
Message.META_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), Util.contextSetToString(context), changed);
Message.META_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), CommandUtils.contextSetToString(context), changed);
}
ExtendedLogEntry.build().actor(sender).acted(holder)

View File

@ -34,8 +34,8 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.commands.utils.MetaComparator;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -125,7 +125,7 @@ public class MetaInfo extends SharedSubCommand {
for (LocalizedNode m : meta) {
String location = processLocation(m, holder);
if (m.hasSpecificContext()) {
String context = Util.getAppendableNodeContextString(m);
String context = CommandUtils.getAppendableNodeContextString(m);
TextComponent.Builder builder = TextUtils.fromLegacy(Message.META_ENTRY_WITH_CONTEXT.asString(sender.getPlatform().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location, context), Constants.COLOR_CHAR).toBuilder();
builder.applyDeep(makeFancy(holder, label, m));
sender.sendMessage(builder.build());
@ -141,7 +141,7 @@ public class MetaInfo extends SharedSubCommand {
for (Map.Entry<Integer, LocalizedNode> e : meta) {
String location = processLocation(e.getValue(), holder);
if (e.getValue().hasSpecificContext()) {
String context = Util.getAppendableNodeContextString(e.getValue());
String context = CommandUtils.getAppendableNodeContextString(e.getValue());
TextComponent.Builder builder = TextUtils.fromLegacy(Message.CHAT_META_ENTRY_WITH_CONTEXT.asString(sender.getPlatform().getLocaleManager(), e.getKey(), type.getEntry(e.getValue()).getValue(), location, context), Constants.COLOR_CHAR).toBuilder();
builder.applyDeep(makeFancy(type, holder, label, e.getValue()));
sender.sendMessage(builder.build());

View File

@ -35,7 +35,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -90,7 +90,7 @@ public class MetaRemoveChatMeta extends SharedSubCommand {
!n.isTemporary() &&
n.getFullContexts().makeImmutable().equals(context.makeImmutable())
);
Message.BULK_REMOVE_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), priority, Util.contextSetToString(context));
Message.BULK_REMOVE_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), priority, CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("meta" , "remove" + type.name().toLowerCase(), priority, "*", context)
@ -103,7 +103,7 @@ public class MetaRemoveChatMeta extends SharedSubCommand {
DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(type, priority, meta).withExtraContext(context).build());
if (result.asBoolean()) {
TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder();
TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder();
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
'¥'
@ -118,7 +118,7 @@ public class MetaRemoveChatMeta extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.DOES_NOT_HAVE_CHAT_META.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context));
Message.DOES_NOT_HAVE_CHAT_META.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -35,7 +35,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -90,7 +90,7 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand {
!n.isPermanent() &&
n.getFullContexts().makeImmutable().equals(context.makeImmutable())
);
Message.BULK_REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), priority, Util.contextSetToString(context));
Message.BULK_REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), priority, CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("meta" , "removetemp" + type.name().toLowerCase(), priority, "*", context)
@ -103,7 +103,7 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand {
DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(type, priority, meta).setExpiry(10L).withExtraContext(context).build());
if (result.asBoolean()) {
TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder();
TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder();
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
'¥'
@ -118,7 +118,7 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.DOES_NOT_HAVE_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context));
Message.DOES_NOT_HAVE_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -34,7 +34,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -79,14 +79,14 @@ public class MetaSet extends SharedSubCommand {
Node n = NodeFactory.makeMetaNode(key, value).withExtraContext(context).build();
if (holder.hasPermission(n).asBoolean()) {
Message.ALREADY_HAS_META.send(sender, holder.getFriendlyName(), key, value, Util.contextSetToString(context));
Message.ALREADY_HAS_META.send(sender, holder.getFriendlyName(), key, value, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
holder.clearMetaKeys(key, context, false);
holder.setPermission(n);
TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), Util.contextSetToString(context))).toBuilder();
TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), CommandUtils.contextSetToString(context))).toBuilder();
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value),
'¥'

View File

@ -34,7 +34,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
@ -85,14 +85,14 @@ public class MetaSetTemp extends SharedSubCommand {
Node n = NodeFactory.makeMetaNode(key, value).withExtraContext(context).setExpiry(duration).build();
if (holder.hasPermission(n).asBoolean()) {
Message.ALREADY_HAS_TEMP_META.send(sender, holder.getFriendlyName(), key, value, Util.contextSetToString(context));
Message.ALREADY_HAS_TEMP_META.send(sender, holder.getFriendlyName(), key, value, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
holder.clearMetaKeys(key, context, true);
duration = holder.setPermission(n, modifier).getValue().getExpiryUnixTime();
TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_TEMP_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), Util.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder();
TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_TEMP_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder();
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value),
'¥'

View File

@ -33,7 +33,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -70,7 +70,7 @@ public class MetaUnset extends SharedSubCommand {
}
if (holder.clearMetaKeys(key, context, false)) {
Message.UNSET_META_SUCCESS.send(sender, key, holder.getFriendlyName(), Util.contextSetToString(context));
Message.UNSET_META_SUCCESS.send(sender, key, holder.getFriendlyName(), CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("meta", "unset", key, context)
@ -79,7 +79,7 @@ public class MetaUnset extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.DOESNT_HAVE_META.send(sender, holder.getFriendlyName(), key, Util.contextSetToString(context));
Message.DOESNT_HAVE_META.send(sender, holder.getFriendlyName(), key, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -33,7 +33,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -70,7 +70,7 @@ public class MetaUnsetTemp extends SharedSubCommand {
}
if (holder.clearMetaKeys(key, context, true)) {
Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFriendlyName(), Util.contextSetToString(context));
Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFriendlyName(), CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("meta", "unsettemp", key, context)
@ -79,7 +79,7 @@ public class MetaUnsetTemp extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.DOESNT_HAVE_TEMP_META.send(sender, holder.getFriendlyName(), key, Util.contextSetToString(context));
Message.DOESNT_HAVE_TEMP_META.send(sender, holder.getFriendlyName(), key, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -34,7 +34,7 @@ import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -74,9 +74,9 @@ public class HolderClear<T extends PermissionHolder> extends SubCommand<T> {
int changed = before - holder.getEnduringNodes().size();
if (changed == 1) {
Message.CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), Util.contextSetToString(context), changed);
Message.CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed);
} else {
Message.CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), Util.contextSetToString(context), changed);
Message.CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed);
}
ExtendedLogEntry.build().actor(sender).acted(holder)

View File

@ -31,7 +31,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -76,8 +76,8 @@ public class HolderShowTracks<T extends PermissionHolder> extends SubCommand<T>
.forEach(t -> sb.append("&a")
.append(t.getName())
.append(": ")
.append(Util.listToArrowSep(t.getGroups(), name))
.append(Util.getAppendableNodeContextString(node))
.append(CommandUtils.listToArrowSep(t.getGroups(), name))
.append(CommandUtils.getAppendableNodeContextString(node))
.append("\n")
);
}

View File

@ -34,7 +34,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -87,7 +87,7 @@ public class ParentAdd extends SharedSubCommand {
DataMutateResult result = holder.setInheritGroup(group, context);
if (result.asBoolean()) {
Message.SET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), Util.contextSetToString(context));
Message.SET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("parent", "add", group.getName(), context)
@ -96,7 +96,7 @@ public class ParentAdd extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.ALREADY_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), Util.contextSetToString(context));
Message.ALREADY_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -35,7 +35,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -93,7 +93,7 @@ public class ParentAddTemp extends SharedSubCommand {
}
if (group.getName().equalsIgnoreCase(holder.getObjectName())) {
Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), Util.contextSetToString(context));
Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
@ -101,7 +101,7 @@ public class ParentAddTemp extends SharedSubCommand {
if (ret.getKey().asBoolean()) {
duration = ret.getValue().getExpiryUnixTime();
Message.SET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), DateUtil.formatDateDiff(duration), Util.contextSetToString(context));
Message.SET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("parent", "addtemp", group.getName(), duration, context)
@ -110,7 +110,7 @@ public class ParentAddTemp extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), Util.contextSetToString(context));
Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -33,7 +33,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -73,9 +73,9 @@ public class ParentClear extends SharedSubCommand {
int changed = before - holder.getEnduringNodes().size();
if (changed == 1) {
Message.PARENT_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), Util.contextSetToString(context), changed);
Message.PARENT_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed);
} else {
Message.PARENT_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), Util.contextSetToString(context), changed);
Message.PARENT_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed);
}
ExtendedLogEntry.build().actor(sender).acted(holder)

View File

@ -33,7 +33,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.DataConstraints;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -110,9 +110,9 @@ public class ParentClearTrack extends SharedSubCommand {
int changed = before - holder.getEnduringNodes().size();
if (changed == 1) {
Message.PARENT_CLEAR_TRACK_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), track.getName(), Util.contextSetToString(context), changed);
Message.PARENT_CLEAR_TRACK_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), track.getName(), CommandUtils.contextSetToString(context), changed);
} else {
Message.PARENT_CLEAR_TRACK_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), Util.contextSetToString(context), changed);
Message.PARENT_CLEAR_TRACK_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), CommandUtils.contextSetToString(context), changed);
}
ExtendedLogEntry.build().actor(sender).acted(holder)

View File

@ -32,7 +32,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -95,7 +95,7 @@ public class ParentInfo extends SharedSubCommand {
TextComponent.Builder message = TextComponent.builder("");
for (Node node : page) {
String s = "&3> &a" + node.getGroupName() + Util.getAppendableNodeContextString(node) + "\n";
String s = "&3> &a" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node) + "\n";
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build());
}
return message.build();
@ -115,7 +115,7 @@ public class ParentInfo extends SharedSubCommand {
TextComponent.Builder message = TextComponent.builder("");
for (Node node : page) {
String s = "&3> &a" + node.getGroupName() + Util.getAppendableNodeContextString(node) + "\n&2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "\n";
String s = "&3> &a" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node) + "\n&2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "\n";
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build());
}
return message.build();

View File

@ -34,7 +34,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -91,7 +91,7 @@ public class ParentRemove extends SharedSubCommand {
DataMutateResult result = holder.unsetPermission(NodeFactory.newBuilder("group." + groupName).withExtraContext(context).build());
if (result.asBoolean()) {
Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, Util.contextSetToString(context));
Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("parent", "remove", groupName, context)
@ -104,7 +104,7 @@ public class ParentRemove extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.DOES_NOT_INHERIT.send(sender, holder.getFriendlyName(), groupName, Util.contextSetToString(context));
Message.DOES_NOT_INHERIT.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -34,7 +34,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -76,7 +76,7 @@ public class ParentRemoveTemp extends SharedSubCommand {
DataMutateResult result = holder.unsetPermission(NodeFactory.newBuilder("group." + groupName).setExpiry(10L).withExtraContext(context).build());
if (result.asBoolean()) {
Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, Util.contextSetToString(context));
Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("parent", "removetemp", groupName, context)
@ -85,7 +85,7 @@ public class ParentRemoveTemp extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.DOES_NOT_TEMP_INHERIT.send(sender, holder.getFriendlyName(), groupName, Util.contextSetToString(context));
Message.DOES_NOT_TEMP_INHERIT.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -33,7 +33,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -90,7 +90,7 @@ public class ParentSet extends SharedSubCommand {
((User) holder).getPrimaryGroup().setStoredValue(group.getName());
}
Message.SET_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), Util.contextSetToString(context));
Message.SET_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("parent", "set", group.getName(), context)

View File

@ -33,7 +33,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.DataConstraints;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -127,7 +127,7 @@ public class ParentSetTrack extends SharedSubCommand {
holder.removeIf(node -> node.isGroupNode() && node.getFullContexts().equals(context) && track.containsGroup(node.getGroupName()));
holder.setInheritGroup(group, context);
Message.SET_TRACK_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), group.getFriendlyName(), Util.contextSetToString(context));
Message.SET_TRACK_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), group.getFriendlyName(), CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("parent", "settrack", track.getName(), groupName, context)

View File

@ -33,7 +33,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -63,9 +63,9 @@ public class PermissionCheck extends SharedSubCommand {
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
Tristate result = holder.hasPermission(NodeFactory.newBuilder(node).withExtraContext(context).build());
String s = Util.formatTristate(result);
String s = CommandUtils.formatTristate(result);
Message.CHECK_PERMISSION.send(sender, holder.getFriendlyName(), node, s, Util.contextSetToString(context));
Message.CHECK_PERMISSION.send(sender, holder.getFriendlyName(), node, s, CommandUtils.contextSetToString(context));
return CommandResult.SUCCESS;
}

View File

@ -32,7 +32,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -69,8 +69,8 @@ public class PermissionCheckInherits extends SharedSubCommand {
location = "self";
}
String s = Util.formatTristate(result.getResult());
Message.CHECK_INHERITS_PERMISSION.send(sender, holder.getFriendlyName(), node, s, Util.contextSetToString(context), String.valueOf(location));
String s = CommandUtils.formatTristate(result.getResult());
Message.CHECK_INHERITS_PERMISSION.send(sender, holder.getFriendlyName(), node, s, CommandUtils.contextSetToString(context), String.valueOf(location));
return CommandResult.SUCCESS;
}

View File

@ -35,7 +35,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -153,7 +153,7 @@ public class PermissionInfo extends SharedSubCommand {
}
int index = pageNumber - 1;
List<List<Node>> pages = Util.divideList(l, 15);
List<List<Node>> pages = CommandUtils.divideList(l, 15);
if (index < 0 || index >= pages.size()) {
pageNumber = 1;
@ -171,7 +171,7 @@ public class PermissionInfo extends SharedSubCommand {
}
for (Node node : page) {
String s = "&3> " + (node.getValuePrimitive() ? "&a" : "&c") + node.getPermission() + (console ? " &7(" + node.getValuePrimitive() + "&7)" : "") + Util.getAppendableNodeContextString(node) + "\n";
String s = "&3> " + (node.getValuePrimitive() ? "&a" : "&c") + node.getPermission() + (console ? " &7(" + node.getValuePrimitive() + "&7)" : "") + CommandUtils.getAppendableNodeContextString(node) + "\n";
if (temp) {
s += "&2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "\n";
}

View File

@ -34,7 +34,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -78,7 +78,7 @@ public class PermissionSet extends SharedSubCommand {
DataMutateResult result = holder.setPermission(NodeFactory.newBuilder(node).setValue(b).withExtraContext(context).build());
if (result.asBoolean()) {
Message.SETPERMISSION_SUCCESS.send(sender, node, b, holder.getFriendlyName(), Util.contextSetToString(context));
Message.SETPERMISSION_SUCCESS.send(sender, node, b, holder.getFriendlyName(), CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("permission", "set", node, b, context)
@ -87,7 +87,7 @@ public class PermissionSet extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.ALREADY_HASPERMISSION.send(sender, holder.getFriendlyName(), node, Util.contextSetToString(context));
Message.ALREADY_HASPERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -35,7 +35,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -86,7 +86,7 @@ public class PermissionSetTemp extends SharedSubCommand {
if (result.getKey().asBoolean()) {
duration = result.getValue().getExpiryUnixTime();
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, b, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), Util.contextSetToString(context));
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, b, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("permission", "settemp", node, b, duration, context)
@ -95,7 +95,7 @@ public class PermissionSetTemp extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.ALREADY_HAS_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, Util.contextSetToString(context));
Message.ALREADY_HAS_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -34,7 +34,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -76,7 +76,7 @@ public class PermissionUnset extends SharedSubCommand {
DataMutateResult result = holder.unsetPermission(NodeFactory.newBuilder(node).withExtraContext(context).build());
if (result.asBoolean()) {
Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), Util.contextSetToString(context));
Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("permission", "unset", node, context)
@ -85,7 +85,7 @@ public class PermissionUnset extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.DOES_NOT_HAVE_PERMISSION.send(sender, holder.getFriendlyName(), node, Util.contextSetToString(context));
Message.DOES_NOT_HAVE_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -34,7 +34,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -76,7 +76,7 @@ public class PermissionUnsetTemp extends SharedSubCommand {
DataMutateResult result = holder.unsetPermission(NodeFactory.newBuilder(node).setExpiry(10L).withExtraContext(context).build());
if (result.asBoolean()) {
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), Util.contextSetToString(context));
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder)
.action("permission", "unsettemp", node, context)
@ -85,7 +85,7 @@ public class PermissionUnsetTemp extends SharedSubCommand {
save(holder, sender, plugin);
return CommandResult.SUCCESS;
} else {
Message.DOES_NOT_HAVE_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, Util.contextSetToString(context));
Message.DOES_NOT_HAVE_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
return CommandResult.STATE_ERROR;
}
}

View File

@ -31,7 +31,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -81,14 +81,14 @@ public class GroupInfo extends SubCommand<Group> {
if (!parents.isEmpty()) {
Message.INFO_PARENT_HEADER.send(sender);
for (Node node : parents) {
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getAppendableNodeContextString(node));
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node));
}
}
if (!tempParents.isEmpty()) {
Message.INFO_TEMP_PARENT_HEADER.send(sender);
for (Node node : tempParents) {
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getAppendableNodeContextString(node));
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node));
Message.EMPTY.send(sender, "&f- &2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()));
}
}

View File

@ -35,7 +35,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -130,7 +130,7 @@ public class GroupListMembers extends SubCommand<Group> {
sorted.sort(Comparator.comparing(HeldPermission::getHolder));
int index = pageNumber - 1;
List<List<HeldPermission<UUID>>> pages = Util.divideList(sorted, 15);
List<List<HeldPermission<UUID>>> pages = CommandUtils.divideList(sorted, 15);
if (index < 0 || index >= pages.size()) {
pageNumber = 1;
@ -146,7 +146,7 @@ public class GroupListMembers extends SubCommand<Group> {
String title = "&7(page &f" + pageNumber + "&7 of &f" + pages.size() + "&7 - &f" + sorted.size() + "&7 entries)";
for (Map.Entry<String, HeldPermission<UUID>> ent : uuidMappedPage) {
String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().asNode()) + Util.getAppendableNodeContextString(ent.getValue().asNode()) + "\n";
String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().asNode()) + CommandUtils.getAppendableNodeContextString(ent.getValue().asNode()) + "\n";
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), false, label, ent.getValue())).build());
}
@ -162,7 +162,7 @@ public class GroupListMembers extends SubCommand<Group> {
sorted.sort(Comparator.comparing(HeldPermission::getHolder));
int index = pageNumber - 1;
List<List<HeldPermission<String>>> pages = Util.divideList(sorted, 15);
List<List<HeldPermission<String>>> pages = CommandUtils.divideList(sorted, 15);
if (index < 0 || index >= pages.size()) {
pageNumber = 1;
@ -175,7 +175,7 @@ public class GroupListMembers extends SubCommand<Group> {
String title = "&7(page &f" + pageNumber + "&7 of &f" + pages.size() + "&7 - &f" + sorted.size() + "&7 entries)";
for (HeldPermission<String> ent : page) {
String s = "&3> &b" + ent.getHolder() + " " + getNodeExpiryString(ent.asNode()) + Util.getAppendableNodeContextString(ent.asNode()) + "\n";
String s = "&3> &b" + ent.getHolder() + " " + getNodeExpiryString(ent.asNode()) + CommandUtils.getAppendableNodeContextString(ent.asNode()) + "\n";
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getHolder(), true, label, ent)).build());
}

View File

@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.impl.group;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -78,7 +78,7 @@ public class ListGroups extends SingleCommand {
component = TextUtils.fromLegacy(Message.GROUPS_LIST_ENTRY_WITH_TRACKS.asString(plugin.getLocaleManager(),
group.getFriendlyName(),
group.getWeight().orElse(0),
Util.toCommaSep(tracks)
CommandUtils.toCommaSep(tracks)
), Constants.COLOR_CHAR);
}

View File

@ -31,7 +31,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.DataConstraints;
@ -71,7 +71,7 @@ public class LogRecent extends SubCommand<Log> {
// User and possibly page
final String target = args.get(0);
UUID uuid = Util.parseUuid(target.toLowerCase());
UUID uuid = CommandUtils.parseUuid(target.toLowerCase());
if (uuid == null) {
if (!plugin.getConfiguration().get(ConfigKeys.ALLOW_INVALID_USERNAMES)) {
if (!DataConstraints.PLAYER_USERNAME_TEST.test(target)) {

View File

@ -31,7 +31,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.DataConstraints;
@ -66,7 +66,7 @@ public class LogUserHistory extends SubCommand<Log> {
}
}
UUID uuid = Util.parseUuid(target.toLowerCase());
UUID uuid = CommandUtils.parseUuid(target.toLowerCase());
if (uuid == null) {
if (!plugin.getConfiguration().get(ConfigKeys.ALLOW_INVALID_USERNAMES)) {
if (!DataConstraints.PLAYER_USERNAME_TEST.test(target)) {

View File

@ -39,7 +39,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand;
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.contexts.ContextSetJsonSerializer;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -118,7 +118,7 @@ public class ApplyEditsCommand extends SingleCommand {
}
} else if (who.startsWith("user/")) {
String user = who.substring("user/".length());
UUID uuid = Util.parseUuid(user);
UUID uuid = CommandUtils.parseUuid(user);
if (uuid == null) {
Message.APPLY_EDITS_TARGET_USER_NOT_UUID.send(sender, user);
return CommandResult.STATE_ERROR;

View File

@ -31,7 +31,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -56,7 +56,7 @@ public class CheckCommand extends SingleCommand {
String permission = args.get(1);
User user;
UUID u = Util.parseUuid(target);
UUID u = CommandUtils.parseUuid(target);
if (u != null) {
user = plugin.getUserManager().getIfLoaded(u);
} else {
@ -69,7 +69,7 @@ public class CheckCommand extends SingleCommand {
}
Tristate tristate = user.getCachedData().getPermissionData(plugin.getContextForUser(user)).getPermissionValue(permission, CheckOrigin.INTERNAL);
Message.CHECK_RESULT.send(sender, user.getFriendlyName(), permission, Util.formatTristate(tristate));
Message.CHECK_RESULT.send(sender, user.getFriendlyName(), permission, CommandUtils.formatTristate(tristate));
return CommandResult.SUCCESS;
}

View File

@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.impl.misc;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -94,7 +94,7 @@ public class InfoCommand extends SingleCommand {
private static String formatValue(String value) {
if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) {
return Util.formatBoolean(Boolean.parseBoolean(value));
return CommandUtils.formatBoolean(Boolean.parseBoolean(value));
}
try {

View File

@ -35,7 +35,7 @@ import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -129,7 +129,7 @@ public class SearchCommand extends SingleCommand {
sorted.sort(Comparator.comparing(HeldPermission::getHolder));
int index = pageNumber - 1;
List<List<HeldPermission<UUID>>> pages = Util.divideList(sorted, 15);
List<List<HeldPermission<UUID>>> pages = CommandUtils.divideList(sorted, 15);
if (index < 0 || index >= pages.size()) {
pageNumber = 1;
@ -145,7 +145,7 @@ public class SearchCommand extends SingleCommand {
String title = "&7(page &f" + pageNumber + "&7 of &f" + pages.size() + "&7 - &f" + sorted.size() + "&7 entries)";
for (Map.Entry<String, HeldPermission<UUID>> ent : uuidMappedPage) {
String s = "&3> &b" + ent.getKey() + " &7- " + (ent.getValue().getValue() ? "&a" : "&c") + ent.getValue().getValue() + getNodeExpiryString(ent.getValue().asNode()) + Util.getAppendableNodeContextString(ent.getValue().asNode()) + "\n";
String s = "&3> &b" + ent.getKey() + " &7- " + (ent.getValue().getValue() ? "&a" : "&c") + ent.getValue().getValue() + getNodeExpiryString(ent.getValue().asNode()) + CommandUtils.getAppendableNodeContextString(ent.getValue().asNode()) + "\n";
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), false, label, ent.getValue())).build());
}
@ -161,7 +161,7 @@ public class SearchCommand extends SingleCommand {
sorted.sort(Comparator.comparing(HeldPermission::getHolder));
int index = pageNumber - 1;
List<List<HeldPermission<String>>> pages = Util.divideList(sorted, 15);
List<List<HeldPermission<String>>> pages = CommandUtils.divideList(sorted, 15);
if (index < 0 || index >= pages.size()) {
pageNumber = 1;
@ -174,7 +174,7 @@ public class SearchCommand extends SingleCommand {
String title = "&7(page &f" + pageNumber + "&7 of &f" + pages.size() + "&7 - &f" + sorted.size() + "&7 entries)";
for (HeldPermission<String> ent : page) {
String s = "&3> &b" + ent.getHolder() + " &7- " + (ent.getValue() ? "&a" : "&c") + ent.getValue() + getNodeExpiryString(ent.asNode()) + Util.getAppendableNodeContextString(ent.asNode()) + "\n";
String s = "&3> &b" + ent.getHolder() + " &7- " + (ent.getValue() ? "&a" : "&c") + ent.getValue() + getNodeExpiryString(ent.asNode()) + CommandUtils.getAppendableNodeContextString(ent.asNode()) + "\n";
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getHolder(), true, label, ent)).build());
}

View File

@ -25,13 +25,13 @@
package me.lucko.luckperms.common.commands.impl.misc;
import me.lucko.luckperms.common.caching.PermissionCache;
import me.lucko.luckperms.common.caching.type.PermissionCache;
import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -74,7 +74,7 @@ public class TreeCommand extends SingleCommand {
if (player != null) {
User user;
UUID u = Util.parseUuid(player);
UUID u = CommandUtils.parseUuid(player);
if (u != null) {
user = plugin.getUserManager().getIfLoaded(u);
} else {

View File

@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.impl.track;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -51,7 +51,7 @@ public class ListTracks extends SingleCommand {
return CommandResult.LOADING_ERROR;
}
Message.TRACKS_LIST.send(sender, Util.toCommaSep(plugin.getTrackManager().getAll().keySet().stream().sorted().collect(Collectors.toList())));
Message.TRACKS_LIST.send(sender, CommandUtils.toCommaSep(plugin.getTrackManager().getAll().keySet().stream().sorted().collect(Collectors.toList())));
return CommandResult.SUCCESS;
}
}

View File

@ -31,7 +31,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.DataConstraints;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -73,7 +73,7 @@ public class TrackAppend extends SubCommand<Track> {
if (result.asBoolean()) {
Message.TRACK_APPEND_SUCCESS.send(sender, group.getName(), track.getName());
if (track.getGroups().size() > 1) {
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), group.getName()));
Message.EMPTY.send(sender, CommandUtils.listToArrowSep(track.getGroups(), group.getName()));
}
ExtendedLogEntry.build().actor(sender).acted(track)

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -47,7 +47,7 @@ public class TrackInfo extends SubCommand<Track> {
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) throws CommandException {
Message.TRACK_INFO.send(sender, track.getName(), Util.listToArrowSep(track.getGroups()));
Message.TRACK_INFO.send(sender, track.getName(), CommandUtils.listToArrowSep(track.getGroups()));
return CommandResult.SUCCESS;
}
}

View File

@ -31,7 +31,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.DataConstraints;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -82,7 +82,7 @@ public class TrackInsert extends SubCommand<Track> {
if (result.asBoolean()) {
Message.TRACK_INSERT_SUCCESS.send(sender, group.getName(), track.getName(), pos);
if (track.getGroups().size() > 1) {
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), group.getName()));
Message.EMPTY.send(sender, CommandUtils.listToArrowSep(track.getGroups(), group.getName()));
}
ExtendedLogEntry.build().actor(sender).acted(track)

View File

@ -31,7 +31,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.DataConstraints;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -61,7 +61,7 @@ public class TrackRemove extends SubCommand<Track> {
if (result.asBoolean()) {
Message.TRACK_REMOVE_SUCCESS.send(sender, groupName, track.getName());
if (track.getGroups().size() > 1) {
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups()));
Message.EMPTY.send(sender, CommandUtils.listToArrowSep(track.getGroups()));
}
ExtendedLogEntry.build().actor(sender).acted(track)

View File

@ -36,7 +36,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.DataConstraints;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -160,9 +160,9 @@ public class UserDemote extends SubCommand<User> {
user.getPrimaryGroup().setStoredValue(previousGroup.getName());
}
Message.USER_DEMOTE_SUCCESS.send(sender, track.getName(), old, previousGroup.getFriendlyName(), Util.contextSetToString(context));
Message.USER_DEMOTE_SUCCESS.send(sender, track.getName(), old, previousGroup.getFriendlyName(), CommandUtils.contextSetToString(context));
if (!silent) {
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), previousGroup.getFriendlyName(), old, true));
Message.EMPTY.send(sender, CommandUtils.listToArrowSep(track.getGroups(), previousGroup.getFriendlyName(), old, true));
}
ExtendedLogEntry.build().actor(sender).acted(user)

View File

@ -33,7 +33,7 @@ import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -85,14 +85,14 @@ public class UserInfo extends SubCommand<User> {
if (!parents.isEmpty()) {
Message.INFO_PARENT_HEADER.send(sender);
for (Node node : parents) {
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getAppendableNodeContextString(node));
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node));
}
}
if (!tempParents.isEmpty()) {
Message.INFO_TEMP_PARENT_HEADER.send(sender);
for (Node node : tempParents) {
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getAppendableNodeContextString(node));
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node));
Message.EMPTY.send(sender, "&f- &2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()));
}
}
@ -103,7 +103,7 @@ public class UserInfo extends SubCommand<User> {
Contexts contexts = plugin.getContextForUser(user);
if (contexts != null) {
context = contexts.getContexts().toSet().stream()
.map(e -> Util.contextToString(e.getKey(), e.getValue()))
.map(e -> CommandUtils.contextToString(e.getKey(), e.getValue()))
.collect(Collectors.joining(" "));
MetaData meta = user.getCachedData().getMetaData(contexts);
@ -115,7 +115,7 @@ public class UserInfo extends SubCommand<User> {
}
}
Message.USER_INFO_DATA.send(sender, Util.formatBoolean(contexts != null), context, prefix, suffix);
Message.USER_INFO_DATA.send(sender, CommandUtils.formatBoolean(contexts != null), context, prefix, suffix);
return CommandResult.SUCCESS;
}
}

View File

@ -38,7 +38,7 @@ import me.lucko.luckperms.common.commands.impl.generic.other.HolderShowTracks;
import me.lucko.luckperms.common.commands.impl.generic.parent.CommandParent;
import me.lucko.luckperms.common.commands.impl.generic.permission.CommandPermission;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.constants.DataConstraints;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -82,7 +82,7 @@ public class UserMainCommand extends MainCommand<User, UserIdentifier> {
@Override
protected UserIdentifier parseTarget(String target, LuckPermsPlugin plugin, Sender sender) {
UUID uuid = Util.parseUuid(target.toLowerCase());
UUID uuid = CommandUtils.parseUuid(target.toLowerCase());
if (uuid == null) {
if (!plugin.getConfiguration().get(ConfigKeys.ALLOW_INVALID_USERNAMES)) {
if (!DataConstraints.PLAYER_USERNAME_TEST.test(target)) {

View File

@ -34,7 +34,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.CommandPermission;
import me.lucko.luckperms.common.constants.DataConstraints;
import me.lucko.luckperms.common.locale.CommandSpec;
@ -118,7 +118,7 @@ public class UserPromote extends SubCommand<User> {
user.setPermission(NodeFactory.newBuilder("group." + first).withExtraContext(context).build());
Message.USER_TRACK_ADDED_TO_FIRST.send(sender, user.getFriendlyName(), first, Util.contextSetToString(context));
Message.USER_TRACK_ADDED_TO_FIRST.send(sender, user.getFriendlyName(), first, CommandUtils.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(user)
.action("promote", track.getName(), context)
@ -172,9 +172,9 @@ public class UserPromote extends SubCommand<User> {
user.getPrimaryGroup().setStoredValue(nextGroup.getName());
}
Message.USER_PROMOTE_SUCCESS.send(sender, user.getFriendlyName(), track.getName(), old, nextGroup.getFriendlyName(), Util.contextSetToString(context));
Message.USER_PROMOTE_SUCCESS.send(sender, user.getFriendlyName(), track.getName(), old, nextGroup.getFriendlyName(), CommandUtils.contextSetToString(context));
if (!silent) {
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), old, nextGroup.getFriendlyName(), false));
Message.EMPTY.send(sender, CommandUtils.listToArrowSep(track.getGroups(), old, nextGroup.getFriendlyName(), false));
}
ExtendedLogEntry.build().actor(sender).acted(user)

View File

@ -37,14 +37,13 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.UUID;
import java.util.function.Supplier;
import java.util.regex.Pattern;
@UtilityClass
public class Util {
public class CommandUtils {
private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]");
/**
@ -61,28 +60,6 @@ public class Util {
sender.sendMessage(color(prefix + message));
}
/**
* Strips outer quote marks from a list of parsed arguments.
*
* @param input the list of arguments to strip quotes from
* @return an ArrayList containing the contents of input without quotes
*/
public static List<String> stripQuotes(List<String> input) {
input = new ArrayList<>(input);
ListIterator<String> iterator = input.listIterator();
while (iterator.hasNext()) {
String value = iterator.next();
if (value.length() < 3) {
continue;
}
if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') {
iterator.set(value.substring(1, value.length() - 1));
}
}
return input;
}
/**
* Colorizes a message.
*

View File

@ -25,16 +25,22 @@
package me.lucko.luckperms.common.commands.utils;
import me.lucko.luckperms.api.LocalizedNode;
import me.lucko.luckperms.common.node.NodeWithContextComparator;
import java.util.Comparator;
import java.util.Map;
public class MetaComparator implements Comparator<Map.Entry<Integer, ?>> {
public class MetaComparator implements Comparator<Map.Entry<Integer, LocalizedNode>> {
public static final MetaComparator INSTANCE = new MetaComparator();
@Override
public int compare(Map.Entry<Integer, ?> o1, Map.Entry<Integer, ?> o2) {
public int compare(Map.Entry<Integer, LocalizedNode> o1, Map.Entry<Integer, LocalizedNode> o2) {
int result = Integer.compare(o1.getKey(), o2.getKey());
return result != 0 ? result : 1;
if (result != 0) {
return result;
}
return NodeWithContextComparator.get().compare(o1.getValue(), o2.getValue());
}
}

View File

@ -31,6 +31,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
import me.lucko.luckperms.common.assignments.AssignmentRule;
import me.lucko.luckperms.common.config.keys.AbstractKey;
import me.lucko.luckperms.common.config.keys.BooleanKey;
import me.lucko.luckperms.common.config.keys.EnduringKey;
@ -39,7 +40,6 @@ import me.lucko.luckperms.common.config.keys.LowercaseStringKey;
import me.lucko.luckperms.common.config.keys.MapKey;
import me.lucko.luckperms.common.config.keys.StaticKey;
import me.lucko.luckperms.common.config.keys.StringKey;
import me.lucko.luckperms.common.defaults.Rule;
import me.lucko.luckperms.common.metastacking.SimpleMetaStackDefinition;
import me.lucko.luckperms.common.metastacking.StandardStackElements;
import me.lucko.luckperms.common.model.TemporaryModifier;
@ -343,7 +343,7 @@ public class ConfigKeys {
/**
* The default assignments being applied by the plugin
*/
public static final ConfigKey<List<Rule>> DEFAULT_ASSIGNMENTS = AbstractKey.of(c -> {
public static final ConfigKey<List<AssignmentRule>> DEFAULT_ASSIGNMENTS = AbstractKey.of(c -> {
return c.getObjectList("default-assignments", ImmutableList.of()).stream().map(name -> {
String hasTrue = c.getString("default-assignments." + name + ".if.has-true", null);
String hasFalse = c.getString("default-assignments." + name + ".if.has-false", null);
@ -351,7 +351,7 @@ public class ConfigKeys {
List<String> give = ImmutableList.copyOf(c.getList("default-assignments." + name + ".give", ImmutableList.of()));
List<String> take = ImmutableList.copyOf(c.getList("default-assignments." + name + ".take", ImmutableList.of()));
String pg = c.getString("default-assignments." + name + ".set-primary-group", null);
return new Rule(hasTrue, hasFalse, lacks, give, take, pg);
return new AssignmentRule(hasTrue, hasFalse, lacks, give, take, pg);
}).collect(ImmutableCollectors.toImmutableList());
});

View File

@ -66,6 +66,15 @@ public abstract class AbstractContextManager<T> implements ContextManager<T> {
.expireAfterWrite(50L, TimeUnit.MILLISECONDS) // expire roughly every tick
.build(new Loader());
// caches static context lookups
private final LoadingCache<Object, Contexts> staticLookupCache = Caffeine.newBuilder()
.initialCapacity(1)
.expireAfterWrite(50L, TimeUnit.MILLISECONDS) // expire roughly every tick
.build(new StaticLoader());
// the single key used in the static lookup cache
private final Object staticCacheKey = new Object();
protected AbstractContextManager(LuckPermsPlugin plugin, Class<T> subjectClass) {
this.plugin = plugin;
this.subjectClass = subjectClass;
@ -90,16 +99,14 @@ public abstract class AbstractContextManager<T> implements ContextManager<T> {
@Override
public ImmutableContextSet getStaticContext() {
MutableContextSet accumulator = MutableContextSet.create();
for (ContextCalculator<?> calculator : staticCalculators) {
calculator.giveApplicableContext(null, accumulator);
}
return accumulator.makeImmutable();
// this is actually already immutable, but the Contexts method signature returns the interface.
// using the makeImmutable method is faster than casting
return getStaticContexts().getContexts().makeImmutable();
}
@Override
public Contexts getStaticContexts() {
return formContexts(getStaticContext());
return staticLookupCache.get(staticCacheKey);
}
@Override
@ -156,26 +163,39 @@ public abstract class AbstractContextManager<T> implements ContextManager<T> {
return calculators.size();
}
// iterates the calculators in this manager and accumulates contexts from them all.
private void calculateApplicableContext(T subject, MutableContextSet accumulator) {
for (ContextCalculator<T> calculator : calculators) {
try {
calculator.giveApplicableContext(subject, accumulator);
} catch (Exception e) {
new RuntimeException("Exception thrown by ContextCalculator: " + calculator.getClass().getName(), e).printStackTrace();
}
}
}
private final class Loader implements CacheLoader<T, Contexts> {
@Override
public Contexts load(T subject) {
MutableContextSet accumulator = MutableContextSet.create();
calculateApplicableContext(subject, accumulator);
ImmutableContextSet ret = accumulator.makeImmutable();
return formContexts(subject, ret);
for (ContextCalculator<T> calculator : calculators) {
try {
calculator.giveApplicableContext(subject, accumulator);
} catch (Exception e) {
plugin.getLog().warn("An exception was thrown whilst calculating the context of subject " + subject);
e.printStackTrace();
}
}
return formContexts(subject, accumulator.makeImmutable());
}
}
private final class StaticLoader implements CacheLoader<Object, Contexts> {
@Override
public Contexts load(Object o) {
MutableContextSet accumulator = MutableContextSet.create();
for (StaticContextCalculator calculator : staticCalculators) {
try {
calculator.giveApplicableContext(accumulator);
} catch (Exception e) {
plugin.getLog().warn("An exception was thrown whilst calculating static contexts");
e.printStackTrace();
}
}
return formContexts(accumulator.makeImmutable());
}
}

View File

@ -1,78 +0,0 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.defaults;
import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.common.model.PermissionHolder;
import me.lucko.luckperms.common.node.NodeFactory;
import me.lucko.luckperms.common.utils.Scripting;
import java.util.function.Function;
import java.util.regex.Pattern;
import javax.script.ScriptEngine;
public class LogicParser {
public static boolean parse(String s, PermissionHolder holder, Tristate tristate) throws IllegalArgumentException {
try {
ScriptEngine engine = Scripting.getScriptEngine();
if (engine == null) {
throw new NullPointerException("script engine");
}
String expression = generateExpression(s, s1 -> holder.hasPermission(NodeFactory.fromSerializedNode(s1, true)) == tristate);
String result = engine.eval(expression).toString();
if (!result.equals("true") && !result.equals("false")) {
throw new IllegalArgumentException();
}
return Boolean.parseBoolean(result);
} catch (Throwable t) {
throw new IllegalArgumentException(s, t);
}
}
private static String generateExpression(String input, Function<String, Boolean> checker) {
while (true) {
int i = input.indexOf("<");
int i2 = input.indexOf(">");
if (i == -1 || i2 == -1) {
break;
}
String match = input.substring(i, i2 + 1);
String matchContent = match.substring(1, match.length() - 1);
String matchReplacement = (Boolean.toString(checker.apply(matchContent))).toLowerCase();
input = input.replaceFirst(Pattern.quote(match), matchReplacement);
}
return input.replace("&", "&&").replace("|", "||");
}
}

View File

@ -25,9 +25,7 @@
package me.lucko.luckperms.common.locale;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import com.google.common.collect.ImmutableList;
@ -36,7 +34,6 @@ import me.lucko.luckperms.common.commands.Arg;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
/**
* An enumeration of the command defintion/usage messages used in the plugin.
@ -565,18 +562,6 @@ public enum CommandSpec {
return new SimpleLocalizedSpec(this, localeManager);
}
/**
* The localized data for a {@link CommandSpec}.
*/
@Getter
@ToString
@AllArgsConstructor
public static final class CommandSpecData {
private final String description;
private final String usage;
private final Map<String, String> args;
}
private static final class SimpleLocalizedSpec implements LocalizedSpec {
@Getter

View File

@ -0,0 +1,46 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.locale;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import java.util.Map;
/**
* The localized data for a {@link CommandSpec}.
*/
@Getter
@ToString
@EqualsAndHashCode
@AllArgsConstructor
public final class CommandSpecData {
private final String description;
private final String usage;
private final Map<String, String> args;
}

View File

@ -71,6 +71,6 @@ public interface LocaleManager {
* @param key the key
* @return the translation data, or null if there isn't any translation available.
*/
CommandSpec.CommandSpecData getTranslation(CommandSpec key);
CommandSpecData getTranslation(CommandSpec key);
}

View File

@ -28,7 +28,7 @@ package me.lucko.luckperms.common.locale;
import lombok.Getter;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.utils.TextUtils;
/**
@ -474,7 +474,7 @@ public enum Message {
}
s = format(s.replace("{PREFIX}", prefix).replace("\\n", "\n"), objects);
return Util.color(showPrefix ? prefix + s : s);
return CommandUtils.color(showPrefix ? prefix + s : s);
}
public void send(Sender sender, Object... objects) {

View File

@ -52,7 +52,7 @@ public class NoopLocaleManager implements LocaleManager {
}
@Override
public CommandSpec.CommandSpecData getTranslation(CommandSpec key) {
public CommandSpecData getTranslation(CommandSpec key) {
return null;
}

View File

@ -40,7 +40,7 @@ import java.util.Map;
public class SimpleLocaleManager implements LocaleManager {
private Map<Message, String> messages = ImmutableMap.of();
private Map<CommandSpec, CommandSpec.CommandSpecData> commands = ImmutableMap.of();
private Map<CommandSpec, CommandSpecData> commands = ImmutableMap.of();
public void tryLoad(LuckPermsPlugin plugin, File file) {
if (file.exists()) {
@ -57,7 +57,7 @@ public class SimpleLocaleManager implements LocaleManager {
public void loadFromFile(File file) throws Exception {
try (BufferedReader reader = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
ImmutableMap.Builder<Message, String> messages = ImmutableMap.builder();
ImmutableMap.Builder<CommandSpec, CommandSpec.CommandSpecData> commands = ImmutableMap.builder();
ImmutableMap.Builder<CommandSpec, CommandSpecData> commands = ImmutableMap.builder();
Map<String, Object> data = (Map<String, Object>) new Yaml().load(reader);
for (Map.Entry<String, Object> entry : data.entrySet()) {
@ -97,7 +97,7 @@ public class SimpleLocaleManager implements LocaleManager {
args = null;
}
CommandSpec.CommandSpecData specData = new CommandSpec.CommandSpecData(description, usage, args == null ? null : ImmutableMap.copyOf(args));
CommandSpecData specData = new CommandSpecData(description, usage, args == null ? null : ImmutableMap.copyOf(args));
commands.put(spec, specData);
} catch (IllegalArgumentException e) {
@ -125,7 +125,7 @@ public class SimpleLocaleManager implements LocaleManager {
}
@Override
public CommandSpec.CommandSpecData getTranslation(CommandSpec key) {
public CommandSpecData getTranslation(CommandSpec key) {
return commands.get(key);
}

View File

@ -29,7 +29,7 @@ import lombok.AllArgsConstructor;
import lombok.NonNull;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.locale.Message;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -57,7 +57,7 @@ public class SenderLogger implements Logger {
private void msg(Message message, String s) {
String msg = message.asString(plugin.getLocaleManager(), s);
if (plugin.getConfiguration() != null && !plugin.getConfiguration().get(ConfigKeys.USE_COLORED_LOGGER)) {
msg = Util.stripColor(msg);
msg = CommandUtils.stripColor(msg);
}
console.sendMessage(msg);
}

View File

@ -62,23 +62,23 @@ public abstract class AbstractManager<I, T extends Identifiable<I>> implements M
@Override
public T getOrMake(I id) {
return objects.get(lowerCase(id));
return objects.get(sanitizeIdentifier(id));
}
@Override
public T getIfLoaded(I id) {
return objects.getIfPresent(lowerCase(id));
return objects.getIfPresent(sanitizeIdentifier(id));
}
@Override
public boolean isLoaded(I id) {
return objects.asMap().containsKey(lowerCase(id));
return objects.asMap().containsKey(sanitizeIdentifier(id));
}
@Override
public void unload(I id) {
if (id != null) {
objects.invalidate(lowerCase(id));
objects.invalidate(sanitizeIdentifier(id));
}
}
@ -94,13 +94,8 @@ public abstract class AbstractManager<I, T extends Identifiable<I>> implements M
objects.invalidateAll();
}
@SuppressWarnings("unchecked")
private static <I> I lowerCase(I i) {
if (i instanceof String) {
return (I) ((String) i).toLowerCase();
} else {
return i;
}
protected I sanitizeIdentifier(I i) {
return i;
}
}

View File

@ -63,4 +63,9 @@ public class GenericGroupManager extends AbstractManager<String, Group> implemen
return null;
}
@Override
protected String sanitizeIdentifier(String s) {
return s.toLowerCase();
}
}

View File

@ -39,4 +39,8 @@ public class GenericTrackManager extends AbstractManager<String, Track> implemen
return new Track(name, plugin);
}
@Override
protected String sanitizeIdentifier(String s) {
return s.toLowerCase();
}
}

View File

@ -33,7 +33,7 @@ import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.context.ImmutableContextSet;
import me.lucko.luckperms.common.api.delegates.model.ApiGroup;
import me.lucko.luckperms.common.buffers.BufferedRequest;
import me.lucko.luckperms.common.caching.GroupCache;
import me.lucko.luckperms.common.caching.GroupCachedData;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.references.GroupReference;
@ -59,7 +59,7 @@ public class Group extends PermissionHolder implements Identifiable<String> {
* The groups data cache instance
*/
@Getter
private final GroupCache cachedData;
private final GroupCachedData cachedData;
@Getter
private BufferedRequest<Void> refreshBuffer;
@ -69,7 +69,7 @@ public class Group extends PermissionHolder implements Identifiable<String> {
this.name = name.toLowerCase();
this.refreshBuffer = new GroupRefreshBuffer(plugin, this);
this.cachedData = new GroupCache(this);
this.cachedData = new GroupCachedData(this);
getPlugin().getApiProvider().getEventFactory().handleGroupCacheLoad(this, cachedData);
// invalidate out caches when data is updated

View File

@ -48,9 +48,9 @@ import me.lucko.luckperms.api.context.ImmutableContextSet;
import me.lucko.luckperms.common.api.delegates.model.ApiPermissionHolder;
import me.lucko.luckperms.common.buffers.BufferedRequest;
import me.lucko.luckperms.common.buffers.Cache;
import me.lucko.luckperms.common.caching.HolderCache;
import me.lucko.luckperms.common.caching.MetaAccumulator;
import me.lucko.luckperms.common.caching.HolderCachedData;
import me.lucko.luckperms.common.caching.handlers.StateListener;
import me.lucko.luckperms.common.caching.type.MetaAccumulator;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.contexts.ContextSetComparator;
import me.lucko.luckperms.common.node.ImmutableLocalizedNode;
@ -257,7 +257,7 @@ public abstract class PermissionHolder {
*
* @return the holders cached data
*/
public abstract HolderCache<?> getCachedData();
public abstract HolderCachedData<?> getCachedData();
public abstract BufferedRequest<Void> getRefreshBuffer();

View File

@ -32,7 +32,7 @@ import lombok.ToString;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.common.api.delegates.model.ApiUser;
import me.lucko.luckperms.common.buffers.BufferedRequest;
import me.lucko.luckperms.common.caching.UserCache;
import me.lucko.luckperms.common.caching.UserCachedData;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.primarygroup.PrimaryGroupHolder;
@ -69,7 +69,7 @@ public class User extends PermissionHolder implements Identifiable<UserIdentifie
* The users data cache instance
*/
@Getter
private final UserCache cachedData;
private final UserCachedData cachedData;
@Getter
private BufferedRequest<Void> refreshBuffer;
@ -84,7 +84,7 @@ public class User extends PermissionHolder implements Identifiable<UserIdentifie
this.refreshBuffer = new UserRefreshBuffer(plugin, this);
this.primaryGroup = plugin.getConfiguration().get(ConfigKeys.PRIMARY_GROUP_CALCULATION).apply(this);
this.cachedData = new UserCache(this);
this.cachedData = new UserCachedData(this);
getPlugin().getApiProvider().getEventFactory().handleUserCacheLoad(this, cachedData);
}
@ -96,7 +96,7 @@ public class User extends PermissionHolder implements Identifiable<UserIdentifie
this.refreshBuffer = new UserRefreshBuffer(plugin, this);
this.primaryGroup = plugin.getConfiguration().get(ConfigKeys.PRIMARY_GROUP_CALCULATION).apply(this);
this.cachedData = new UserCache(this);
this.cachedData = new UserCachedData(this);
getPlugin().getApiProvider().getEventFactory().handleUserCacheLoad(this, cachedData);
}

View File

@ -0,0 +1,143 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.node;
import lombok.experimental.UtilityClass;
import com.google.common.base.Splitter;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.common.utils.PatternCache;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@UtilityClass
public class LegacyNodeFactory {
// legacy node format delimiters
private static final Pattern LEGACY_SERVER_DELIM = PatternCache.compileDelimitedMatcher("/", "\\");
private static final Splitter LEGACY_SERVER_SPLITTER = Splitter.on(LEGACY_SERVER_DELIM).limit(2);
private static final Pattern LEGACY_WORLD_DELIM = PatternCache.compileDelimitedMatcher("-", "\\");
private static final Splitter LEGACY_WORLD_SPLITTER = Splitter.on(LEGACY_WORLD_DELIM).limit(2);
private static final Pattern LEGACY_EXPIRY_DELIM = PatternCache.compileDelimitedMatcher("$", "\\");
private static final Splitter LEGACY_EXPIRY_SPLITTER = Splitter.on(LEGACY_EXPIRY_DELIM).limit(2);
public static Node fromSerializedNode(String s, boolean b) {
if (b) {
return builderFromLegacyString(s, true).build();
} else {
return builderFromLegacyString(s, false).build();
}
}
private static Node.Builder builderFromLegacyString(String s, boolean b) {
// if contains /
if (LEGACY_SERVER_DELIM.matcher(s).find()) {
// 0=server(+world) 1=node
Iterator<String> parts = LEGACY_SERVER_SPLITTER.split(s).iterator();
String parts0 = parts.next();
String parts1 = parts.next();
// WORLD SPECIFIC
// if parts[0] contains -
if (LEGACY_WORLD_DELIM.matcher(parts0).find()) {
// 0=server 1=world
Iterator<String> serverParts = LEGACY_WORLD_SPLITTER.split(parts0).iterator();
String serverParts0 = serverParts.next();
String serverParts1 = serverParts.next();
// if parts[1] contains $
if (LEGACY_EXPIRY_DELIM.matcher(parts1).find()) {
// 0=node 1=expiry
Iterator<String> tempParts = LEGACY_EXPIRY_SPLITTER.split(parts1).iterator();
String tempParts0 = tempParts.next();
String tempParts1 = tempParts.next();
return new LegacyNodeBuilder(tempParts0).setServer(serverParts0).setWorld(serverParts1).setExpiry(Long.parseLong(tempParts1)).setValue(b);
} else {
return new LegacyNodeBuilder(parts1).setServer(serverParts0).setWorld(serverParts1).setValue(b);
}
} else {
// SERVER BUT NOT WORLD SPECIFIC
// if parts[1] contains $
if (LEGACY_EXPIRY_DELIM.matcher(parts1).find()) {
// 0=node 1=expiry
Iterator<String> tempParts = LEGACY_EXPIRY_SPLITTER.split(parts1).iterator();
String tempParts0 = tempParts.next();
String tempParts1 = tempParts.next();
return new LegacyNodeBuilder(tempParts0).setServer(parts0).setExpiry(Long.parseLong(tempParts1)).setValue(b);
} else {
return new LegacyNodeBuilder(parts1).setServer(parts0).setValue(b);
}
}
} else {
// NOT SERVER SPECIFIC
// if s contains $
if (LEGACY_EXPIRY_DELIM.matcher(s).find()) {
// 0=node 1=expiry
Iterator<String> tempParts = LEGACY_EXPIRY_SPLITTER.split(s).iterator();
String tempParts0 = tempParts.next();
String tempParts1 = tempParts.next();
return new LegacyNodeBuilder(tempParts0).setExpiry(Long.parseLong(tempParts1)).setValue(b);
} else {
return new LegacyNodeBuilder(s).setValue(b);
}
}
}
private static final class LegacyNodeBuilder extends NodeBuilder {
private static final Pattern NODE_CONTEXTS_PATTERN = Pattern.compile("\\(.+\\).*");
LegacyNodeBuilder(String permission) {
if (!NODE_CONTEXTS_PATTERN.matcher(permission).matches()) {
this.permission = permission;
} else {
List<String> contextParts = Splitter.on(PatternCache.compileDelimitedMatcher(")", "\\")).limit(2).splitToList(permission.substring(1));
// 0 = context, 1 = node
this.permission = contextParts.get(1);
try {
Map<String, String> map = Splitter.on(PatternCache.compileDelimitedMatcher(",", "\\")).withKeyValueSeparator(Splitter.on(PatternCache.compileDelimitedMatcher("=", "\\"))).split(contextParts.get(0));
for (Map.Entry<String, String> e : map.entrySet()) {
this.withExtraContext(NodeFactory.unescapeDelimiters(e.getKey(), "=", "(", ")", ","), NodeFactory.unescapeDelimiters(e.getValue(), "=", "(", ")", ","));
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
}
}
}

View File

@ -25,30 +25,20 @@
package me.lucko.luckperms.common.node;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import com.google.common.base.Splitter;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.context.ContextSet;
import me.lucko.luckperms.api.context.MutableContextSet;
import me.lucko.luckperms.common.utils.PatternCache;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
/**
* Builds Nodes
* Builds node instances
*/
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class NodeBuilder implements Node.Builder {
private static final Pattern NODE_CONTEXTS_PATTERN = Pattern.compile("\\(.+\\).*");
private final String permission;
protected String permission;
private final MutableContextSet extraContexts = MutableContextSet.create();
private Boolean value = true;
private boolean override = false;
@ -56,28 +46,12 @@ class NodeBuilder implements Node.Builder {
private String world = null;
private long expireAt = 0L;
NodeBuilder(String permission, boolean shouldConvertContexts) {
if (!shouldConvertContexts) {
this.permission = permission;
} else {
if (!NODE_CONTEXTS_PATTERN.matcher(permission).matches()) {
this.permission = permission;
} else {
List<String> contextParts = Splitter.on(PatternCache.compileDelimitedMatcher(")", "\\")).limit(2).splitToList(permission.substring(1));
// 0 = context, 1 = node
protected NodeBuilder() {
this.permission = contextParts.get(1);
try {
Map<String, String> map = Splitter.on(PatternCache.compileDelimitedMatcher(",", "\\")).withKeyValueSeparator(Splitter.on(PatternCache.compileDelimitedMatcher("=", "\\"))).split(contextParts.get(0));
for (Map.Entry<String, String> e : map.entrySet()) {
this.withExtraContext(NodeFactory.unescapeDelimiters(e.getKey(), "=", "(", ")", ","), NodeFactory.unescapeDelimiters(e.getValue(), "=", "(", ")", ","));
}
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
}
NodeBuilder(String permission) {
this.permission = permission;
}
NodeBuilder(Node other) {

View File

@ -27,8 +27,6 @@ package me.lucko.luckperms.common.node;
import lombok.experimental.UtilityClass;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.google.common.base.Splitter;
import com.google.common.collect.Maps;
@ -40,107 +38,19 @@ import me.lucko.luckperms.common.utils.PatternCache;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
/**
* Utility class to make Node(Builder) instances from serialised strings or existing Nodes
*/
@SuppressWarnings("deprecation")
@UtilityClass
public class NodeFactory {
// used to split prefix/suffix/meta nodes
private static final Splitter META_SPLITTER = Splitter.on(PatternCache.compileDelimitedMatcher(".", "\\")).limit(2);
// legacy node format delimiters
private static final Pattern LEGACY_SERVER_DELIM = PatternCache.compileDelimitedMatcher("/", "\\");
private static final Splitter LEGACY_SERVER_SPLITTER = Splitter.on(LEGACY_SERVER_DELIM).limit(2);
private static final Pattern LEGACY_WORLD_DELIM = PatternCache.compileDelimitedMatcher("-", "\\");
private static final Splitter LEGACY_WORLD_SPLITTER = Splitter.on(LEGACY_WORLD_DELIM).limit(2);
private static final Pattern LEGACY_EXPIRY_DELIM = PatternCache.compileDelimitedMatcher("$", "\\");
private static final Splitter LEGACY_EXPIRY_SPLITTER = Splitter.on(LEGACY_EXPIRY_DELIM).limit(2);
private static final String[] DELIMS = new String[]{".", "/", "-", "$"};
// caches the conversion between legacy node strings --> node instances
private static final LoadingCache<String, Node> LEGACY_SERIALIZATION_CACHE = Caffeine.newBuilder()
.expireAfterAccess(10, TimeUnit.MINUTES)
.build(s -> builderFromLegacyString(s, true).build());
private static final LoadingCache<String, Node> LEGACY_SERIALIZATION_CACHE_NEGATED = Caffeine.newBuilder()
.expireAfterAccess(10, TimeUnit.MINUTES)
.build(s -> builderFromLegacyString(s, false).build());
public static Node fromSerializedNode(String s, Boolean b) {
try {
return b ? LEGACY_SERIALIZATION_CACHE.get(s) : LEGACY_SERIALIZATION_CACHE_NEGATED.get(s);
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
}
public static Node.Builder newBuilder(String s) {
return new NodeBuilder(s, false);
}
public static Node.Builder builderFromLegacyString(String s, Boolean b) {
// if contains /
if (LEGACY_SERVER_DELIM.matcher(s).find()) {
// 0=server(+world) 1=node
Iterator<String> parts = LEGACY_SERVER_SPLITTER.split(s).iterator();
String parts0 = parts.next();
String parts1 = parts.next();
// WORLD SPECIFIC
// if parts[0] contains -
if (LEGACY_WORLD_DELIM.matcher(parts0).find()) {
// 0=server 1=world
Iterator<String> serverParts = LEGACY_WORLD_SPLITTER.split(parts0).iterator();
String serverParts0 = serverParts.next();
String serverParts1 = serverParts.next();
// if parts[1] contains $
if (LEGACY_EXPIRY_DELIM.matcher(parts1).find()) {
// 0=node 1=expiry
Iterator<String> tempParts = LEGACY_EXPIRY_SPLITTER.split(parts1).iterator();
String tempParts0 = tempParts.next();
String tempParts1 = tempParts.next();
return new NodeBuilder(tempParts0, true).setServer(serverParts0).setWorld(serverParts1).setExpiry(Long.parseLong(tempParts1)).setValue(b);
} else {
return new NodeBuilder(parts1, true).setServer(serverParts0).setWorld(serverParts1).setValue(b);
}
} else {
// SERVER BUT NOT WORLD SPECIFIC
// if parts[1] contains $
if (LEGACY_EXPIRY_DELIM.matcher(parts1).find()) {
// 0=node 1=expiry
Iterator<String> tempParts = LEGACY_EXPIRY_SPLITTER.split(parts1).iterator();
String tempParts0 = tempParts.next();
String tempParts1 = tempParts.next();
return new NodeBuilder(tempParts0, true).setServer(parts0).setExpiry(Long.parseLong(tempParts1)).setValue(b);
} else {
return new NodeBuilder(parts1, true).setServer(parts0).setValue(b);
}
}
} else {
// NOT SERVER SPECIFIC
// if s contains $
if (LEGACY_EXPIRY_DELIM.matcher(s).find()) {
// 0=node 1=expiry
Iterator<String> tempParts = LEGACY_EXPIRY_SPLITTER.split(s).iterator();
String tempParts0 = tempParts.next();
String tempParts1 = tempParts.next();
return new NodeBuilder(tempParts0, true).setExpiry(Long.parseLong(tempParts1)).setValue(b);
} else {
return new NodeBuilder(s, true).setValue(b);
}
}
return new NodeBuilder(s);
}
public static Node.Builder builderFromExisting(Node other) {
@ -263,13 +173,6 @@ public class NodeFactory {
return sb;
}
/**
* Escapes special characters used within LuckPerms, so the string can be saved without issues
*
* @param s the string to escape
* @return an escaped string
* @throws NullPointerException if the string is null
*/
public static String escapeCharacters(String s) {
if (s == null) {
throw new NullPointerException();
@ -278,13 +181,6 @@ public class NodeFactory {
return escapeDelimiters(s, DELIMS);
}
/**
* Unescapes special characters used within LuckPerms, the inverse of {@link #escapeCharacters(String)}
*
* @param s the string to unescape
* @return an unescaped string
* @throws NullPointerException if the string is null
*/
public static String unescapeCharacters(String s) {
if (s == null) {
throw new NullPointerException();

View File

@ -35,7 +35,7 @@ import me.lucko.luckperms.common.calculators.CalculatorFactory;
import me.lucko.luckperms.common.commands.CommandManager;
import me.lucko.luckperms.common.commands.abstraction.Command;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
import me.lucko.luckperms.common.contexts.ContextManager;
import me.lucko.luckperms.common.locale.LocaleManager;
@ -382,13 +382,13 @@ public interface LuckPermsPlugin {
}
static void sendStartupBanner(Sender sender, LuckPermsPlugin plugin) {
sender.sendMessage(Util.color("&b __ &3 __ ___ __ __ "));
sender.sendMessage(Util.color("&b | | | / ` |__/ &3|__) |__ |__) |\\/| /__` "));
sender.sendMessage(Util.color("&b |___ \\__/ \\__, | \\ &3| |___ | \\ | | .__/ "));
sender.sendMessage(Util.color(" "));
sender.sendMessage(Util.color("&2 Loading version &bv" + plugin.getVersion() + "&2 on " + plugin.getServerType().getFriendlyName() + " - " + plugin.getServerName()));
sender.sendMessage(Util.color("&8 Running on server version " + plugin.getServerVersion()));
sender.sendMessage(Util.color(" "));
sender.sendMessage(CommandUtils.color("&b __ &3 __ ___ __ __ "));
sender.sendMessage(CommandUtils.color("&b | | | / ` |__/ &3|__) |__ |__) |\\/| /__` "));
sender.sendMessage(CommandUtils.color("&b |___ \\__/ \\__, | \\ &3| |___ | \\ | | .__/ "));
sender.sendMessage(CommandUtils.color(" "));
sender.sendMessage(CommandUtils.color("&2 Loading version &bv" + plugin.getVersion() + "&2 on " + plugin.getServerType().getFriendlyName() + " - " + plugin.getServerName()));
sender.sendMessage(CommandUtils.color("&8 Running on server version " + plugin.getServerVersion()));
sender.sendMessage(CommandUtils.color(" "));
}
}

View File

@ -37,7 +37,7 @@ import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.context.ImmutableContextSet;
import me.lucko.luckperms.common.actionlog.Log;
import me.lucko.luckperms.common.bulkupdate.BulkUpdate;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.contexts.ContextSetConfigurateSerializer;
import me.lucko.luckperms.common.managers.GenericUserManager;
@ -248,7 +248,7 @@ public abstract class ConfigurateDao extends AbstractDao {
}
String user = s.substring(0, s.length() - fileExtension.length());
UUID uuid = Util.parseUuid(user);
UUID uuid = CommandUtils.parseUuid(user);
if (uuid == null) {
return;
}

View File

@ -35,7 +35,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import me.lucko.luckperms.common.contexts.ContextSetJsonSerializer;
import me.lucko.luckperms.common.node.NodeFactory;
import me.lucko.luckperms.common.node.LegacyNodeFactory;
import me.lucko.luckperms.common.node.NodeModel;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.storage.dao.file.JsonDao;
@ -112,7 +112,7 @@ public class LegacyJsonMigration implements Runnable {
Set<NodeModel> nodes = perms.entrySet().stream()
.map(e -> NodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(e -> LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(NodeModel::fromNode)
.collect(Collectors.toCollection(LinkedHashSet::new));
@ -162,7 +162,7 @@ public class LegacyJsonMigration implements Runnable {
}
Set<NodeModel> nodes = perms.entrySet().stream()
.map(e -> NodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(e -> LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(NodeModel::fromNode)
.collect(Collectors.toCollection(LinkedHashSet::new));

View File

@ -31,7 +31,7 @@ import com.google.common.collect.Lists;
import com.google.gson.reflect.TypeToken;
import me.lucko.luckperms.common.contexts.ContextSetJsonSerializer;
import me.lucko.luckperms.common.node.NodeFactory;
import me.lucko.luckperms.common.node.LegacyNodeFactory;
import me.lucko.luckperms.common.node.NodeModel;
import me.lucko.luckperms.common.storage.dao.sql.SqlDao;
@ -154,7 +154,7 @@ public class LegacySqlMigration implements Runnable {
}
Set<NodeModel> nodes = convertedPerms.entrySet().stream()
.map(e -> NodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(e -> LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(NodeModel::fromNode)
.collect(Collectors.toSet());
@ -233,7 +233,7 @@ public class LegacySqlMigration implements Runnable {
}
Set<NodeModel> nodes = convertedPerms.entrySet().stream()
.map(ent -> NodeFactory.fromSerializedNode(ent.getKey(), ent.getValue()))
.map(ent -> LegacyNodeFactory.fromSerializedNode(ent.getKey(), ent.getValue()))
.map(NodeModel::fromNode)
.collect(Collectors.toSet());

View File

@ -27,7 +27,7 @@ package me.lucko.luckperms.common.storage.dao.legacy;
import lombok.RequiredArgsConstructor;
import me.lucko.luckperms.common.node.NodeFactory;
import me.lucko.luckperms.common.node.LegacyNodeFactory;
import me.lucko.luckperms.common.node.NodeModel;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.storage.dao.file.YamlDao;
@ -114,7 +114,7 @@ public class LegacyYamlMigration implements Runnable {
perms.putAll((Map<String, Boolean>) data.get("perms"));
Set<NodeModel> nodes = perms.entrySet().stream()
.map(e -> NodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(e -> LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(NodeModel::fromNode)
.collect(Collectors.toCollection(LinkedHashSet::new));
@ -161,7 +161,7 @@ public class LegacyYamlMigration implements Runnable {
perms.putAll((Map<String, Boolean>) data.get("perms"));
Set<NodeModel> nodes = perms.entrySet().stream()
.map(e -> NodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(e -> LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(NodeModel::fromNode)
.collect(Collectors.toCollection(LinkedHashSet::new));

View File

@ -48,6 +48,7 @@ import me.lucko.luckperms.common.managers.TrackManager;
import me.lucko.luckperms.common.model.Group;
import me.lucko.luckperms.common.model.Track;
import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.node.LegacyNodeFactory;
import me.lucko.luckperms.common.node.NodeFactory;
import me.lucko.luckperms.common.node.NodeHeldPermission;
import me.lucko.luckperms.common.node.NodeModel;
@ -231,7 +232,7 @@ public class MongoDao extends AbstractDao {
Set<NodeModel> nodes = new HashSet<>();
for (Map.Entry<String, Boolean> e : perms.entrySet()) {
Node node = NodeFactory.fromSerializedNode(e.getKey(), e.getValue());
Node node = LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue());
nodes.add(NodeModel.fromNode(node));
}
@ -265,7 +266,7 @@ public class MongoDao extends AbstractDao {
Set<NodeModel> nodes = new HashSet<>();
for (Map.Entry<String, Boolean> e : perms.entrySet()) {
Node node = NodeFactory.fromSerializedNode(e.getKey(), e.getValue());
Node node = LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue());
nodes.add(NodeModel.fromNode(node));
}
@ -305,7 +306,7 @@ public class MongoDao extends AbstractDao {
// User exists, let's load.
Document d = cursor.next();
user.setEnduringNodes(revert((Map<String, Boolean>) d.get("perms")).entrySet().stream()
.map(e -> NodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(e -> LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.collect(Collectors.toSet())
);
user.getPrimaryGroup().setStoredValue(d.getString("primaryGroup"));
@ -393,7 +394,7 @@ public class MongoDao extends AbstractDao {
Map<String, Boolean> perms = revert((Map<String, Boolean>) d.get("perms"));
for (Map.Entry<String, Boolean> e : perms.entrySet()) {
Node node = NodeFactory.fromSerializedNode(e.getKey(), e.getValue());
Node node = LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue());
if (!node.getPermission().equalsIgnoreCase(permission)) {
continue;
}
@ -421,7 +422,7 @@ public class MongoDao extends AbstractDao {
// Group exists, let's load.
Document d = cursor.next();
group.setEnduringNodes(revert((Map<String, Boolean>) d.get("perms")).entrySet().stream()
.map(e -> NodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(e -> LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.collect(Collectors.toSet())
);
} else {
@ -451,7 +452,7 @@ public class MongoDao extends AbstractDao {
Document d = cursor.next();
group.setEnduringNodes(revert((Map<String, Boolean>) d.get("perms")).entrySet().stream()
.map(e -> NodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.map(e -> LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue()))
.collect(Collectors.toSet())
);
}
@ -534,7 +535,7 @@ public class MongoDao extends AbstractDao {
Map<String, Boolean> perms = revert((Map<String, Boolean>) d.get("perms"));
for (Map.Entry<String, Boolean> e : perms.entrySet()) {
Node node = NodeFactory.fromSerializedNode(e.getKey(), e.getValue());
Node node = LegacyNodeFactory.fromSerializedNode(e.getKey(), e.getValue());
if (!node.getPermission().equalsIgnoreCase(permission)) {
continue;
}

View File

@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.common.caching.PermissionCache;
import me.lucko.luckperms.common.caching.type.PermissionCache;
import me.lucko.luckperms.common.utils.PasteUtils;
import me.lucko.luckperms.common.verbose.CheckOrigin;

Some files were not shown because too many files have changed in this diff Show More