General tidy up

This commit is contained in:
Luck committed 2017-11-18 23:20:48 +00:00
1 parent 987ea51264
commit 6ca9eb13dd
130 files changed
+850 -763

No files matched your search

@@ -35,7 +35,7 @@ import me.lucko.luckperms.api.platform.PlatformType;
import me.lucko.luckperms.common.actionlog.LogDispatcher;
import me.lucko.luckperms.common.api.ApiProvider;
import me.lucko.luckperms.common.api.ApiSingletonUtils;
import me.lucko.luckperms.common.backup.ImporterSender;
import me.lucko.luckperms.common.backup.DummySender;
import me.lucko.luckperms.common.buffers.BufferedRequest;
import me.lucko.luckperms.common.buffers.UpdateTaskBuffer;
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
@@ -456,7 +456,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
@Override
public Sender getConsoleSender() {
if (!game.isServerAvailable()) {
return new ImporterSender(this, Constants.CONSOLE_UUID, Constants.CONSOLE_NAME) {
return new DummySender(this, Constants.CONSOLE_UUID, Constants.CONSOLE_NAME) {
@Override
protected void consumeMessage(String s) {
logger.info(s);
@@ -29,7 +29,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.spongepowered.api.command.CommandCallable;
import org.spongepowered.api.command.CommandResult;
@@ -60,7 +59,7 @@ public class SpongeCommandExecutor extends CommandManager implements CommandCall
@Override
public CommandResult process(CommandSource source, String s) {
Sender lpSender = plugin.getSenderFactory().wrap(source);
List<String> arguments = processSelectors(source, Util.stripQuotes(ARGUMENT_SPLITTER.splitToList(s)));
List<String> arguments = processSelectors(source, CommandManager.stripQuotes(ARGUMENT_SPLITTER.splitToList(s)));
onCommand(lpSender, "lp", arguments);
return CommandResult.success();
@@ -69,7 +68,7 @@ public class SpongeCommandExecutor extends CommandManager implements CommandCall
@Override
public List<String> getSuggestions(CommandSource source, String s, @Nullable Location<World> location) {
Sender lpSender = plugin.getSenderFactory().wrap(source);
List<String> arguments = processSelectors(source, Util.stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(s)));
List<String> arguments = processSelectors(source, CommandManager.stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(s)));
return onTabComplete(lpSender, arguments);
}
@@ -31,7 +31,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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@@ -51,10 +51,10 @@ public class OptionClear extends SubCommand<LPSubjectData> {
ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args);
if (contextSet.isEmpty()) {
subjectData.clearOptions();
Util.sendPluginMessage(sender, "&aCleared options matching contexts &bANY&a.");
CommandUtils.sendPluginMessage(sender, "&aCleared options matching contexts &bANY&a.");
} else {
subjectData.clearOptions(contextSet);
Util.sendPluginMessage(sender, "&aCleared options matching contexts &b" + SpongeUtils.contextToString(contextSet));
CommandUtils.sendPluginMessage(sender, "&aCleared options matching contexts &b" + SpongeUtils.contextToString(contextSet));
}
return CommandResult.SUCCESS;
}
@@ -33,7 +33,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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@@ -53,25 +53,25 @@ public class OptionInfo extends SubCommand<LPSubjectData> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) throws CommandException {
ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args);
if (contextSet.isEmpty()) {
Util.sendPluginMessage(sender, "&aShowing options matching contexts &bANY&a.");
CommandUtils.sendPluginMessage(sender, "&aShowing options matching contexts &bANY&a.");
Map<ImmutableContextSet, ImmutableMap<String, String>> options = subjectData.getAllOptions();
if (options.isEmpty()) {
Util.sendPluginMessage(sender, "That subject does not have any options defined.");
CommandUtils.sendPluginMessage(sender, "That subject does not have any options defined.");
return CommandResult.SUCCESS;
}
for (Map.Entry<ImmutableContextSet, ImmutableMap<String, String>> e : options.entrySet()) {
Util.sendPluginMessage(sender, "&3>> &bContext: " + SpongeUtils.contextToString(e.getKey()) + "\n" + SpongeUtils.optionsToString(e.getValue()));
CommandUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeUtils.contextToString(e.getKey()) + "\n" + SpongeUtils.optionsToString(e.getValue()));
}
} else {
Map<String, String> options = subjectData.getOptions(contextSet);
if (options.isEmpty()) {
Util.sendPluginMessage(sender, "That subject does not have any options defined in those contexts.");
CommandUtils.sendPluginMessage(sender, "That subject does not have any options defined in those contexts.");
return CommandResult.SUCCESS;
}
Util.sendPluginMessage(sender, "&aShowing options matching contexts &b" +
CommandUtils.sendPluginMessage(sender, "&aShowing options matching contexts &b" +
SpongeUtils.contextToString(contextSet) + "&a.\n" + SpongeUtils.optionsToString(options));
}
@@ -31,7 +31,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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@@ -53,9 +53,9 @@ public class OptionSet extends SubCommand<LPSubjectData> {
ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(2, args);
if (subjectData.setOption(contextSet, key, value).join()) {
Util.sendPluginMessage(sender, "&aSet &f\"" + key + "&f\"&a to &f\"" + value + "&f\"&a in context " + SpongeUtils.contextToString(contextSet));
CommandUtils.sendPluginMessage(sender, "&aSet &f\"" + key + "&f\"&a to &f\"" + value + "&f\"&a in context " + SpongeUtils.contextToString(contextSet));
} else {
Util.sendPluginMessage(sender, "Unable to set option. Does the Subject already have it set?");
CommandUtils.sendPluginMessage(sender, "Unable to set option. Does the Subject already have it set?");
}
return CommandResult.SUCCESS;
@@ -31,7 +31,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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@@ -52,9 +52,9 @@ public class OptionUnset extends SubCommand<LPSubjectData> {
ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(1, args);
if (subjectData.unsetOption(contextSet, key).join()) {
Util.sendPluginMessage(sender, "&aUnset &f\"" + key + "&f\"&a in context " + SpongeUtils.contextToString(contextSet));
CommandUtils.sendPluginMessage(sender, "&aUnset &f\"" + key + "&f\"&a in context " + SpongeUtils.contextToString(contextSet));
} else {
Util.sendPluginMessage(sender, "Unable to unset option. Are you sure the Subject has it set?");
CommandUtils.sendPluginMessage(sender, "Unable to unset option. Are you sure the Subject has it set?");
}
return CommandResult.SUCCESS;
}
@@ -31,7 +31,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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@@ -59,21 +59,21 @@ public class ParentAdd extends SubCommand<LPSubjectData> {
LuckPermsService service = Sponge.getServiceManager().provideUnchecked(LuckPermsService.class);
if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(collection))) {
Util.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't already exist.");
CommandUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't already exist.");
}
LPSubjectCollection c = service.getCollection(collection);
if (!c.hasRegistered(name).join()) {
Util.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't already exist.");
CommandUtils.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't already exist.");
}
LPSubject subject = c.loadSubject(name).join();
if (subjectData.addParent(contextSet, subject.toReference()).join()) {
Util.sendPluginMessage(sender, "&aAdded parent &b" + subject.getParentCollection().getIdentifier() +
CommandUtils.sendPluginMessage(sender, "&aAdded parent &b" + subject.getParentCollection().getIdentifier() +
"&a/&b" + subject.getIdentifier() + "&a in context " + SpongeUtils.contextToString(contextSet));
} else {
Util.sendPluginMessage(sender, "Unable to add parent. Does the Subject already have it added?");
CommandUtils.sendPluginMessage(sender, "Unable to add parent. Does the Subject already have it added?");
}
return CommandResult.SUCCESS;
}
@@ -31,7 +31,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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@@ -51,10 +51,10 @@ public class ParentClear extends SubCommand<LPSubjectData> {
ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args);
if (contextSet.isEmpty()) {
subjectData.clearParents();
Util.sendPluginMessage(sender, "&aCleared parents matching contexts &bANY&a.");
CommandUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &bANY&a.");
} else {
subjectData.clearParents(contextSet);
Util.sendPluginMessage(sender, "&aCleared parents matching contexts &b" + SpongeUtils.contextToString(contextSet));
CommandUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &b" + SpongeUtils.contextToString(contextSet));
}
return CommandResult.SUCCESS;
}
@@ -33,7 +33,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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@@ -54,25 +54,25 @@ public class ParentInfo extends SubCommand<LPSubjectData> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) throws CommandException {
ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args);
if (contextSet.isEmpty()) {
Util.sendPluginMessage(sender, "&aShowing parents matching contexts &bANY&a.");
CommandUtils.sendPluginMessage(sender, "&aShowing parents matching contexts &bANY&a.");
Map<ImmutableContextSet, ImmutableList<SubjectReference>> parents = subjectData.getAllParents();
if (parents.isEmpty()) {
Util.sendPluginMessage(sender, "That subject does not have any parents defined.");
CommandUtils.sendPluginMessage(sender, "That subject does not have any parents defined.");
return CommandResult.SUCCESS;
}
for (Map.Entry<ImmutableContextSet, ImmutableList<SubjectReference>> e : parents.entrySet()) {
Util.sendPluginMessage(sender, "&3>> &bContext: " + SpongeUtils.contextToString(e.getKey()) + "\n" + SpongeUtils.parentsToString(e.getValue()));
CommandUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeUtils.contextToString(e.getKey()) + "\n" + SpongeUtils.parentsToString(e.getValue()));
}
} else {
List<SubjectReference> parents = subjectData.getParents(contextSet);
if (parents.isEmpty()) {
Util.sendPluginMessage(sender, "That subject does not have any parents defined in those contexts.");
CommandUtils.sendPluginMessage(sender, "That subject does not have any parents defined in those contexts.");
return CommandResult.SUCCESS;
}
Util.sendPluginMessage(sender, "&aShowing parents matching contexts &b" +
CommandUtils.sendPluginMessage(sender, "&aShowing parents matching contexts &b" +
SpongeUtils.contextToString(contextSet) + "&a.\n" + SpongeUtils.parentsToString(parents));
}
@@ -31,7 +31,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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@@ -59,21 +59,21 @@ public class ParentRemove extends SubCommand<LPSubjectData> {
LuckPermsService service = Sponge.getServiceManager().provideUnchecked(LuckPermsService.class);
if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(collection))) {
Util.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't exist.");
CommandUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't exist.");
}
LPSubjectCollection c = service.getCollection(collection);
if (!c.hasRegistered(name).join()) {
Util.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't exist.");
CommandUtils.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't exist.");
}
LPSubject subject = c.loadSubject(name).join();
if (subjectData.removeParent(contextSet, subject.toReference()).join()) {
Util.sendPluginMessage(sender, "&aRemoved parent &b" + subject.getParentCollection().getIdentifier() +
CommandUtils.sendPluginMessage(sender, "&aRemoved parent &b" + subject.getParentCollection().getIdentifier() +
"&a/&b" + subject.getIdentifier() + "&a in context " + SpongeUtils.contextToString(contextSet));
} else {
Util.sendPluginMessage(sender, "Unable to remove parent. Are you sure the Subject has it added?");
CommandUtils.sendPluginMessage(sender, "Unable to remove parent. Are you sure the Subject has it added?");
}
return CommandResult.SUCCESS;
}
@@ -31,7 +31,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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@@ -51,10 +51,10 @@ public class PermissionClear extends SubCommand<LPSubjectData> {
ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args);
if (contextSet.isEmpty()) {
subjectData.clearPermissions();
Util.sendPluginMessage(sender, "&aCleared permissions matching contexts &bANY&a.");
CommandUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &bANY&a.");
} else {
subjectData.clearPermissions(contextSet);
Util.sendPluginMessage(sender, "&aCleared permissions matching contexts &b" + SpongeUtils.contextToString(contextSet));
CommandUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &b" + SpongeUtils.contextToString(contextSet));
}
return CommandResult.SUCCESS;
}
@@ -33,7 +33,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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@@ -53,25 +53,25 @@ public class PermissionInfo extends SubCommand<LPSubjectData> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) throws CommandException {
ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args);
if (contextSet.isEmpty()) {
Util.sendPluginMessage(sender, "&aShowing permissions matching contexts &bANY&a.");
CommandUtils.sendPluginMessage(sender, "&aShowing permissions matching contexts &bANY&a.");
Map<ImmutableContextSet, ImmutableMap<String, Boolean>> permissions = subjectData.getAllPermissions();
if (permissions.isEmpty()) {
Util.sendPluginMessage(sender, "That subject does not have any permissions defined.");
CommandUtils.sendPluginMessage(sender, "That subject does not have any permissions defined.");
return CommandResult.SUCCESS;
}
for (Map.Entry<ImmutableContextSet, ImmutableMap<String, Boolean>> e : permissions.entrySet()) {
Util.sendPluginMessage(sender, "&3>> &bContext: " + SpongeUtils.contextToString(e.getKey()) + "\n" + SpongeUtils.nodesToString(e.getValue()));
CommandUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeUtils.contextToString(e.getKey()) + "\n" + SpongeUtils.nodesToString(e.getValue()));
}
} else {
Map<String, Boolean> permissions = subjectData.getPermissions(contextSet);
if (permissions.isEmpty()) {
Util.sendPluginMessage(sender, "That subject does not have any permissions defined in those contexts.");
CommandUtils.sendPluginMessage(sender, "That subject does not have any permissions defined in those contexts.");
return CommandResult.SUCCESS;
}
Util.sendPluginMessage(sender, "&aShowing permissions matching contexts &b" +
CommandUtils.sendPluginMessage(sender, "&aShowing permissions matching contexts &b" +
SpongeUtils.contextToString(contextSet) + "&a.\n" + SpongeUtils.nodesToString(permissions));
}
@@ -32,7 +32,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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
@@ -54,9 +54,9 @@ public class PermissionSet extends SubCommand<LPSubjectData> {
ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(2, args);
if (subjectData.setPermission(contextSet, node, tristate).join()) {
Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to &b" + tristate.toString().toLowerCase() + "&a in context " + SpongeUtils.contextToString(contextSet));
CommandUtils.sendPluginMessage(sender, "&aSet &b" + node + "&a to &b" + tristate.toString().toLowerCase() + "&a in context " + SpongeUtils.contextToString(contextSet));
} else {
Util.sendPluginMessage(sender, "Unable to set permission. Does the Subject already have it set?");
CommandUtils.sendPluginMessage(sender, "Unable to set permission. Does the Subject already have it set?");
}
return CommandResult.SUCCESS;
@@ -33,7 +33,7 @@ import me.lucko.luckperms.common.commands.CommandManager;
import me.lucko.luckperms.common.commands.CommandResult;
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.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
import me.lucko.luckperms.common.locale.Message;
@@ -94,8 +94,8 @@ public class SpongeMainCommand extends Command<Void, LPSubjectData> {
LuckPermsService service = this.plugin.getService();
if (args.size() < 1) {
Util.sendPluginMessage(sender, "&aCurrent Subject Collections:\n" +
Util.toCommaSep(service.getLoadedCollections().keySet().stream()
CommandUtils.sendPluginMessage(sender, "&aCurrent Subject Collections:\n" +
CommandUtils.toCommaSep(service.getLoadedCollections().keySet().stream()
.filter(s -> !s.equalsIgnoreCase("user") && !s.equalsIgnoreCase("group"))
.sorted()
.collect(Collectors.toList())
@@ -107,12 +107,12 @@ public class SpongeMainCommand extends Command<Void, LPSubjectData> {
String subjectCollection = args.get(0);
if (subjectCollection.equalsIgnoreCase("user") || subjectCollection.equalsIgnoreCase("group")) {
Util.sendPluginMessage(sender, "Please use the main LuckPerms commands to edit users and groups.");
CommandUtils.sendPluginMessage(sender, "Please use the main LuckPerms commands to edit users and groups.");
return CommandResult.STATE_ERROR;
}
if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(subjectCollection))) {
Util.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + subjectCollection + "&c' doesn't already exist. Creating it now.");
CommandUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + subjectCollection + "&c' doesn't already exist. Creating it now.");
}
LPSubjectCollection collection = service.getCollection(subjectCollection);
@@ -126,9 +126,9 @@ public class SpongeMainCommand extends Command<Void, LPSubjectData> {
List<String> extra = subjects.subList(50, subjects.size());
int overflow = extra.size();
extra.clear();
Util.sendPluginMessage(sender, "&aCurrent Subjects:\n" + Util.toCommaSep(subjects) + "&b ... and &a" + overflow + " &bmore.");
CommandUtils.sendPluginMessage(sender, "&aCurrent Subjects:\n" + CommandUtils.toCommaSep(subjects) + "&b ... and &a" + overflow + " &bmore.");
} else {
Util.sendPluginMessage(sender, "&aCurrent Subjects:\n" + Util.toCommaSep(subjects));
CommandUtils.sendPluginMessage(sender, "&aCurrent Subjects:\n" + CommandUtils.toCommaSep(subjects));
}
return CommandResult.SUCCESS;
@@ -179,7 +179,7 @@ public class SpongeMainCommand extends Command<Void, LPSubjectData> {
String subjectId = args.get(1);
if (!collection.hasRegistered(subjectId).join()) {
Util.sendPluginMessage(sender, "Warning: Subject '&4" + subjectId + "&c' doesn't already exist. Creating it now.");
CommandUtils.sendPluginMessage(sender, "Warning: Subject '&4" + subjectId + "&c' doesn't already exist. Creating it now.");
}
LPSubject subject = collection.loadSubject(subjectId).join();
@@ -196,19 +196,19 @@ public class SpongeMainCommand extends Command<Void, LPSubjectData> {
@Override
public void sendUsage(Sender sender, String label) {
Util.sendPluginMessage(sender, "&3> &a" + String.format(getUsage(), label));
CommandUtils.sendPluginMessage(sender, "&3> &a" + String.format(getUsage(), label));
}
@Override
public void sendDetailedUsage(Sender sender, String label) {
Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s sponge <collection> <subject> [-transient]", label) + " ...)");
CommandUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s sponge <collection> <subject> [-transient]", label) + " ...)");
for (String s : Arrays.asList("Permission", "Parent", "Option")) {
List<Command> subs = subCommands.get(s.toLowerCase()).stream()
.filter(sub -> sub.isAuthorized(sender))
.collect(Collectors.toList());
if (!subs.isEmpty()) {
Util.sendPluginMessage(sender, "&3>> &b" + s);
CommandUtils.sendPluginMessage(sender, "&3>> &b" + s);
for (Command sub : subs) {
sub.sendUsage(sender, label);
}
@@ -30,7 +30,7 @@ import lombok.experimental.UtilityClass;
import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.api.context.ContextSet;
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.sponge.service.model.SubjectReference;
import java.util.List;
@@ -89,7 +89,7 @@ public class SpongeUtils {
}
public static String contextToString(ContextSet set) {
return Util.contextSetToString(set);
return CommandUtils.contextSetToString(set);
}
}
@@ -38,24 +38,12 @@ import java.util.HashSet;
import java.util.Set;
@AllArgsConstructor
public class SpongeCalculatorLink implements ContextCalculator<Subject> {
public class ProxiedContextCalculator implements ContextCalculator<Subject> {
private final org.spongepowered.api.service.context.ContextCalculator<Subject> delegate;
@Override
public MutableContextSet giveApplicableContext(Subject subject, MutableContextSet accumulator) {
Set<Context> contexts = new HashSet<Context>() {
// don't allow null elements
@Override
public boolean add(Context context) {
if (context == null) {
throw new NullPointerException("context");
}
return super.add(context);
}
};
Set<Context> contexts = new NonNullContextHashSet();
try {
delegate.accumulateContexts(subject, contexts);
accumulator.addAll(CompatibilityUtil.convertContexts(contexts));
@@ -65,4 +53,16 @@ public class SpongeCalculatorLink implements ContextCalculator<Subject> {
return accumulator;
}
private final class NonNullContextHashSet extends HashSet<Context> {
@Override
public boolean add(Context context) {
if (context == null) {
throw new NullPointerException("context");
}
return super.add(context);
}
}
}
@@ -284,11 +284,6 @@ public class SpongeGroupManager implements GroupManager, LPSubjectCollection {
return getService().getDefaultSubjects().loadSubject(getIdentifier()).join();
}
@Override
public void suggestUnload(String identifier) {
// noop
}
@Override
public Group getByDisplayName(String name) {
// try to get an exact match first
@@ -381,9 +381,4 @@ public class SpongeUserManager implements UserManager, LPSubjectCollection {
return getService().getDefaultSubjects().loadSubject(getIdentifier()).join();
}
@Override
public void suggestUnload(String identifier) {
// noop
}
}
@@ -31,7 +31,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils;
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;
@@ -121,7 +121,7 @@ public class MigrationPermissionManager extends SubCommand<Object> {
log.log("Starting user migration.");
AtomicInteger userCount = new AtomicInteger(0);
for (Subject pmUser : pmService.getUserSubjects().getAllSubjects()) {
UUID uuid = Util.parseUuid(pmUser.getIdentifier());
UUID uuid = CommandUtils.parseUuid(pmUser.getIdentifier());
if (uuid == null) {
log.logErr("Could not parse UUID for user: " + pmUser.getIdentifier());
continue;
@@ -31,7 +31,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils;
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;
@@ -174,7 +174,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
maxWeight += 5;
for (Subject pexUser : pexService.getUserSubjects().getAllSubjects()) {
UUID uuid = Util.parseUuid(pexUser.getIdentifier());
UUID uuid = CommandUtils.parseUuid(pexUser.getIdentifier());
if (uuid == null) {
log.logErr("Could not parse UUID for user: " + pexUser.getIdentifier());
continue;
@@ -38,7 +38,7 @@ import com.google.common.collect.ImmutableSet;
import me.lucko.luckperms.common.model.Group;
import me.lucko.luckperms.common.utils.Predicates;
import me.lucko.luckperms.sponge.LPSpongePlugin;
import me.lucko.luckperms.sponge.contexts.SpongeCalculatorLink;
import me.lucko.luckperms.sponge.contexts.ProxiedContextCalculator;
import me.lucko.luckperms.sponge.managers.SpongeGroupManager;
import me.lucko.luckperms.sponge.managers.SpongeUserManager;
import me.lucko.luckperms.sponge.service.legacy.LegacyDataMigrator;
@@ -185,7 +185,7 @@ public class LuckPermsService implements LPPermissionService {
@Override
public void registerContextCalculator(org.spongepowered.api.service.context.ContextCalculator<Subject> calculator) {
plugin.getContextManager().registerCalculator(new SpongeCalculatorLink(calculator));
plugin.getContextManager().registerCalculator(new ProxiedContextCalculator(calculator));
}
@Override
@@ -37,7 +37,7 @@ import me.lucko.luckperms.api.DataMutateResult;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.api.context.ImmutableContextSet;
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;
@@ -36,7 +36,7 @@ import me.lucko.luckperms.api.context.ImmutableContextSet;
@ToString
@EqualsAndHashCode
@AllArgsConstructor(staticName = "of")
public final class OptionLookup {
public final class OptionLookupKey {
private final String key;
private final ImmutableContextSet contexts;
@@ -36,7 +36,7 @@ import me.lucko.luckperms.api.context.ImmutableContextSet;
@ToString
@EqualsAndHashCode
@AllArgsConstructor(staticName = "of")
public final class PermissionLookup {
public final class PermissionLookupKey {
private final String node;
private final ImmutableContextSet contexts;
@@ -170,8 +170,4 @@ public class PersistedCollection implements LPSubjectCollection {
return service.getDefaultSubjects().loadSubject(getIdentifier()).join();
}
@Override
public void suggestUnload(String identifier) {
// ignore
}
}
@@ -39,8 +39,8 @@ import me.lucko.luckperms.common.verbose.CheckOrigin;
import me.lucko.luckperms.sponge.service.LuckPermsService;
import me.lucko.luckperms.sponge.service.ProxyFactory;
import me.lucko.luckperms.sponge.service.calculated.CalculatedSubjectData;
import me.lucko.luckperms.sponge.service.calculated.OptionLookup;
import me.lucko.luckperms.sponge.service.calculated.PermissionLookup;
import me.lucko.luckperms.sponge.service.calculated.OptionLookupKey;
import me.lucko.luckperms.sponge.service.calculated.PermissionLookupKey;
import me.lucko.luckperms.sponge.service.model.LPSubject;
import me.lucko.luckperms.sponge.service.model.SubjectReference;
import me.lucko.luckperms.sponge.service.storage.SubjectStorageModel;
@@ -67,7 +67,7 @@ public class PersistedSubject implements LPSubject {
private final PersistedSubjectData subjectData;
private final CalculatedSubjectData transientSubjectData;
private final LoadingCache<PermissionLookup, Tristate> permissionLookupCache = Caffeine.newBuilder()
private final LoadingCache<PermissionLookupKey, Tristate> permissionLookupCache = Caffeine.newBuilder()
.expireAfterAccess(20, TimeUnit.MINUTES)
.build(lookup -> lookupPermissionValue(lookup.getContexts(), lookup.getNode()));
@@ -75,7 +75,7 @@ public class PersistedSubject implements LPSubject {
.expireAfterAccess(20, TimeUnit.MINUTES)
.build(this::lookupParents);
private final LoadingCache<OptionLookup, Optional<String>> optionLookupCache = Caffeine.newBuilder()
private final LoadingCache<OptionLookupKey, Optional<String>> optionLookupCache = Caffeine.newBuilder()
.expireAfterAccess(20, TimeUnit.MINUTES)
.build(lookup -> lookupOptionValue(lookup.getContexts(), lookup.getKey()));
@@ -254,7 +254,7 @@ public class PersistedSubject implements LPSubject {
@Override
public Tristate getPermissionValue(@NonNull ImmutableContextSet contexts, @NonNull String node) {
Tristate t = permissionLookupCache.get(PermissionLookup.of(node, contexts));
Tristate t = permissionLookupCache.get(PermissionLookupKey.of(node, contexts));
service.getPlugin().getVerboseHandler().offerCheckData(CheckOrigin.INTERNAL, getParentCollection().getIdentifier() + "/" + identifier, contexts, node, t);
return t;
}
@@ -279,7 +279,7 @@ public class PersistedSubject implements LPSubject {
@Override
public Optional<String> getOption(ImmutableContextSet contexts, String key) {
return optionLookupCache.get(OptionLookup.of(key, contexts));
return optionLookupCache.get(OptionLookupKey.of(key, contexts));
}
@Override