mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 03:25:19 +01:00
Refactor blank message sending
This commit is contained in:
parent
420ec2bf1a
commit
98ea255667
@ -32,7 +32,6 @@ import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompletions;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.commands.group.CreateGroup;
|
||||
import me.lucko.luckperms.common.commands.group.DeleteGroup;
|
||||
import me.lucko.luckperms.common.commands.group.GroupMainCommand;
|
||||
@ -167,7 +166,7 @@ public class CommandManager {
|
||||
|
||||
// Handle no arguments
|
||||
if (arguments.isEmpty() || (arguments.size() == 1 && arguments.get(0).trim().isEmpty())) {
|
||||
MessageUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2.");
|
||||
Message.BLANK.send(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2.");
|
||||
if (hasPermissionForAny(sender)) {
|
||||
Message.VIEW_AVAILABLE_COMMANDS_PROMPT.send(sender, label);
|
||||
return CommandResult.SUCCESS;
|
||||
@ -271,7 +270,7 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
private void sendCommandUsage(Sender sender, String label) {
|
||||
MessageUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2.");
|
||||
Message.BLANK.send(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2.");
|
||||
this.mainCommands.stream()
|
||||
.filter(Command::shouldDisplay)
|
||||
.filter(c -> c.isAuthorized(sender))
|
||||
|
@ -40,17 +40,6 @@ import java.util.Map;
|
||||
public final class MessageUtils {
|
||||
private MessageUtils() {}
|
||||
|
||||
/**
|
||||
* Sends a message to the sender, formatted with the plugin prefix and color scheme
|
||||
*
|
||||
* @param sender the sender to send the message to
|
||||
* @param message the message content
|
||||
*/
|
||||
public static void sendPluginMessage(Sender sender, String message) {
|
||||
String prefix = Message.PREFIX.asString(sender.getPlugin().getLocaleManager());
|
||||
sender.sendMessage(Message.colorize(prefix + message));
|
||||
}
|
||||
|
||||
public static String toCommaSep(Collection<String> strings) {
|
||||
if (strings.isEmpty()) {
|
||||
return "&bNone";
|
||||
|
@ -69,7 +69,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, MessageUtils.listToArrowSep(track.getGroups(), group.getName()));
|
||||
Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups(), group.getName()));
|
||||
}
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(track)
|
||||
|
@ -78,7 +78,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, MessageUtils.listToArrowSep(track.getGroups(), group.getName()));
|
||||
Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups(), group.getName()));
|
||||
}
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(track)
|
||||
|
@ -63,7 +63,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, MessageUtils.listToArrowSep(track.getGroups()));
|
||||
Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups()));
|
||||
}
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(track)
|
||||
|
@ -130,7 +130,7 @@ public class UserDemote extends SubCommand<User> {
|
||||
|
||||
Message.USER_DEMOTE_SUCCESS.send(sender, user.getFormattedDisplayName(), track.getName(), groupFrom, groupTo, MessageUtils.contextSetToString(plugin.getLocaleManager(), context));
|
||||
if (!silent) {
|
||||
Message.EMPTY.send(sender, MessageUtils.listToArrowSep(track.getGroups(), groupTo, groupFrom, true));
|
||||
Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups(), groupTo, groupFrom, true));
|
||||
}
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(user)
|
||||
|
@ -130,7 +130,7 @@ public class UserPromote extends SubCommand<User> {
|
||||
|
||||
Message.USER_PROMOTE_SUCCESS.send(sender, user.getFormattedDisplayName(), track.getName(), groupFrom, groupTo, MessageUtils.contextSetToString(plugin.getLocaleManager(), context));
|
||||
if (!silent) {
|
||||
Message.EMPTY.send(sender, MessageUtils.listToArrowSep(track.getGroups(), groupFrom, groupTo, false));
|
||||
Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups(), groupFrom, groupTo, false));
|
||||
}
|
||||
|
||||
ExtendedLogEntry.build().actor(sender).acted(user)
|
||||
|
@ -60,7 +60,7 @@ public enum Message {
|
||||
false
|
||||
),
|
||||
|
||||
EMPTY("{}", true),
|
||||
BLANK("{}", true),
|
||||
PLAYER_ONLINE("&aOnline", false),
|
||||
PLAYER_OFFLINE("&cOffline", false),
|
||||
LOADING_DATABASE_ERROR("&cA database error occurred whilst loading permissions data. Please try again later.", true),
|
||||
|
@ -30,9 +30,9 @@ import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
@ -50,10 +50,10 @@ public class OptionClear extends SubCommand<LPSubjectData> {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args);
|
||||
if (contextSet.isEmpty()) {
|
||||
subjectData.clearOptions();
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared options matching contexts &bANY&a.");
|
||||
Message.BLANK.send(sender, "&aCleared options matching contexts &bANY&a.");
|
||||
} else {
|
||||
subjectData.clearOptions(contextSet);
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared options matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
Message.BLANK.send(sender, "&aCleared options matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
@ -52,26 +52,26 @@ public class OptionInfo extends SubCommand<LPSubjectData> {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args);
|
||||
if (contextSet.isEmpty()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aShowing options matching contexts &bANY&a.");
|
||||
Message.BLANK.send(sender, "&aShowing options matching contexts &bANY&a.");
|
||||
Map<ImmutableContextSet, ImmutableMap<String, String>> options = subjectData.getAllOptions();
|
||||
if (options.isEmpty()) {
|
||||
MessageUtils.sendPluginMessage(sender, "That subject does not have any options defined.");
|
||||
Message.BLANK.send(sender, "That subject does not have any options defined.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
for (Map.Entry<ImmutableContextSet, ImmutableMap<String, String>> e : options.entrySet()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.optionsToString(e.getValue()));
|
||||
Message.BLANK.send(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.optionsToString(e.getValue()));
|
||||
}
|
||||
|
||||
} else {
|
||||
Map<String, String> options = subjectData.getOptions(contextSet);
|
||||
if (options.isEmpty()) {
|
||||
MessageUtils.sendPluginMessage(sender, "That subject does not have any options defined in those contexts.");
|
||||
Message.BLANK.send(sender, "That subject does not have any options defined in those contexts.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
MessageUtils.sendPluginMessage(sender, "&aShowing options matching contexts &b" +
|
||||
SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.optionsToString(options));
|
||||
Message.BLANK.send(sender, "&aShowing options matching contexts &b" +
|
||||
SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.optionsToString(options));
|
||||
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
|
@ -30,9 +30,9 @@ import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
@ -52,9 +52,9 @@ public class OptionSet extends SubCommand<LPSubjectData> {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args);
|
||||
|
||||
if (subjectData.setOption(contextSet, key, value).join()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aSet &f\"" + key + "&f\"&a to &f\"" + value + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
Message.BLANK.send(sender, "&aSet &f\"" + key + "&f\"&a to &f\"" + value + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
} else {
|
||||
MessageUtils.sendPluginMessage(sender, "Unable to set option. Does the Subject already have it set?");
|
||||
Message.BLANK.send(sender, "Unable to set option. Does the Subject already have it set?");
|
||||
}
|
||||
|
||||
return CommandResult.SUCCESS;
|
||||
|
@ -30,9 +30,9 @@ import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
@ -51,9 +51,9 @@ public class OptionUnset extends SubCommand<LPSubjectData> {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(1, args);
|
||||
|
||||
if (subjectData.unsetOption(contextSet, key).join()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aUnset &f\"" + key + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
Message.BLANK.send(sender, "&aUnset &f\"" + key + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
} else {
|
||||
MessageUtils.sendPluginMessage(sender, "Unable to unset option. Are you sure the Subject has it set?");
|
||||
Message.BLANK.send(sender, "Unable to unset option. Are you sure the Subject has it set?");
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
@ -50,10 +50,10 @@ public class ParentClear extends SubCommand<LPSubjectData> {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args);
|
||||
if (contextSet.isEmpty()) {
|
||||
subjectData.clearParents();
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &bANY&a.");
|
||||
Message.BLANK.send(sender, "&aCleared parents matching contexts &bANY&a.");
|
||||
} else {
|
||||
subjectData.clearParents(contextSet);
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
Message.BLANK.send(sender, "&aCleared parents matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
@ -53,26 +53,26 @@ public class ParentInfo extends SubCommand<LPSubjectData> {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args);
|
||||
if (contextSet.isEmpty()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aShowing parents matching contexts &bANY&a.");
|
||||
Message.BLANK.send(sender, "&aShowing parents matching contexts &bANY&a.");
|
||||
Map<ImmutableContextSet, ImmutableList<LPSubjectReference>> parents = subjectData.getAllParents();
|
||||
if (parents.isEmpty()) {
|
||||
MessageUtils.sendPluginMessage(sender, "That subject does not have any parents defined.");
|
||||
Message.BLANK.send(sender, "That subject does not have any parents defined.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
for (Map.Entry<ImmutableContextSet, ImmutableList<LPSubjectReference>> e : parents.entrySet()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.parentsToString(e.getValue()));
|
||||
Message.BLANK.send(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.parentsToString(e.getValue()));
|
||||
}
|
||||
|
||||
} else {
|
||||
List<LPSubjectReference> parents = subjectData.getParents(contextSet);
|
||||
if (parents.isEmpty()) {
|
||||
MessageUtils.sendPluginMessage(sender, "That subject does not have any parents defined in those contexts.");
|
||||
Message.BLANK.send(sender, "That subject does not have any parents defined in those contexts.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
MessageUtils.sendPluginMessage(sender, "&aShowing parents matching contexts &b" +
|
||||
SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.parentsToString(parents));
|
||||
Message.BLANK.send(sender, "&aShowing parents matching contexts &b" +
|
||||
SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.parentsToString(parents));
|
||||
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
|
@ -30,9 +30,9 @@ import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
@ -58,21 +58,21 @@ public class ParentRemove extends SubCommand<LPSubjectData> {
|
||||
|
||||
LPPermissionService service = Sponge.getServiceManager().provideUnchecked(LPPermissionService.class);
|
||||
if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(collection))) {
|
||||
MessageUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't exist.");
|
||||
Message.BLANK.send(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't exist.");
|
||||
}
|
||||
|
||||
LPSubjectCollection c = service.getCollection(collection);
|
||||
if (!c.hasRegistered(name).join()) {
|
||||
MessageUtils.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't exist.");
|
||||
Message.BLANK.send(sender, "Warning: Subject '&4" + name + "&c' doesn't exist.");
|
||||
}
|
||||
|
||||
LPSubject subject = c.loadSubject(name).join();
|
||||
|
||||
if (subjectData.removeParent(contextSet, subject.toReference()).join()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aRemoved parent &b" + subject.getParentCollection().getIdentifier() +
|
||||
"&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
Message.BLANK.send(sender, "&aRemoved parent &b" + subject.getParentCollection().getIdentifier() +
|
||||
"&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
} else {
|
||||
MessageUtils.sendPluginMessage(sender, "Unable to remove parent. Are you sure the Subject has it added?");
|
||||
Message.BLANK.send(sender, "Unable to remove parent. Are you sure the Subject has it added?");
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
@ -50,10 +50,10 @@ public class PermissionClear extends SubCommand<LPSubjectData> {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args);
|
||||
if (contextSet.isEmpty()) {
|
||||
subjectData.clearPermissions();
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &bANY&a.");
|
||||
Message.BLANK.send(sender, "&aCleared permissions matching contexts &bANY&a.");
|
||||
} else {
|
||||
subjectData.clearPermissions(contextSet);
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
Message.BLANK.send(sender, "&aCleared permissions matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
@ -52,26 +52,26 @@ public class PermissionInfo extends SubCommand<LPSubjectData> {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args);
|
||||
if (contextSet.isEmpty()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aShowing permissions matching contexts &bANY&a.");
|
||||
Message.BLANK.send(sender, "&aShowing permissions matching contexts &bANY&a.");
|
||||
Map<ImmutableContextSet, ImmutableMap<String, Boolean>> permissions = subjectData.getAllPermissions();
|
||||
if (permissions.isEmpty()) {
|
||||
MessageUtils.sendPluginMessage(sender, "That subject does not have any permissions defined.");
|
||||
Message.BLANK.send(sender, "That subject does not have any permissions defined.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
for (Map.Entry<ImmutableContextSet, ImmutableMap<String, Boolean>> e : permissions.entrySet()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.nodesToString(e.getValue()));
|
||||
Message.BLANK.send(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.nodesToString(e.getValue()));
|
||||
}
|
||||
|
||||
} else {
|
||||
Map<String, Boolean> permissions = subjectData.getPermissions(contextSet);
|
||||
if (permissions.isEmpty()) {
|
||||
MessageUtils.sendPluginMessage(sender, "That subject does not have any permissions defined in those contexts.");
|
||||
Message.BLANK.send(sender, "That subject does not have any permissions defined in those contexts.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
MessageUtils.sendPluginMessage(sender, "&aShowing permissions matching contexts &b" +
|
||||
SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.nodesToString(permissions));
|
||||
Message.BLANK.send(sender, "&aShowing permissions matching contexts &b" +
|
||||
SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.nodesToString(permissions));
|
||||
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
|
@ -32,9 +32,9 @@ import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
@ -54,9 +54,9 @@ public class PermissionSet extends SubCommand<LPSubjectData> {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args);
|
||||
|
||||
if (subjectData.setPermission(contextSet, node, tristate).join()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aSet &b" + node + "&a to &b" + tristate.toString().toLowerCase() + "&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
Message.BLANK.send(sender, "&aSet &b" + node + "&a to &b" + tristate.toString().toLowerCase() + "&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
} else {
|
||||
MessageUtils.sendPluginMessage(sender, "Unable to set permission. Does the Subject already have it set?");
|
||||
Message.BLANK.send(sender, "Unable to set permission. Does the Subject already have it set?");
|
||||
}
|
||||
|
||||
return CommandResult.SUCCESS;
|
||||
|
@ -96,25 +96,24 @@ public class SpongeMainCommand extends Command<Void, LPSubjectData> {
|
||||
LuckPermsService service = this.plugin.getService();
|
||||
|
||||
if (args.size() < 1) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aCurrent Subject Collections:\n" +
|
||||
MessageUtils.toCommaSep(service.getLoadedCollections().keySet().stream()
|
||||
.filter(s -> !s.equalsIgnoreCase("user") && !s.equalsIgnoreCase("group"))
|
||||
.sorted()
|
||||
.collect(Collectors.toList())
|
||||
)
|
||||
);
|
||||
Message.BLANK.send(sender, "&aCurrent Subject Collections:\n" +
|
||||
MessageUtils.toCommaSep(service.getLoadedCollections().keySet().stream()
|
||||
.filter(s -> !s.equalsIgnoreCase("user") && !s.equalsIgnoreCase("group"))
|
||||
.sorted()
|
||||
.collect(Collectors.toList())
|
||||
));
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
String subjectCollection = args.get(0);
|
||||
|
||||
if (subjectCollection.equalsIgnoreCase("user") || subjectCollection.equalsIgnoreCase("group")) {
|
||||
MessageUtils.sendPluginMessage(sender, "Please use the main LuckPerms commands to edit users and groups.");
|
||||
Message.BLANK.send(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))) {
|
||||
MessageUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + subjectCollection + "&c' doesn't already exist. Creating it now.");
|
||||
Message.BLANK.send(sender, "Warning: SubjectCollection '&4" + subjectCollection + "&c' doesn't already exist. Creating it now.");
|
||||
}
|
||||
|
||||
LPSubjectCollection collection = service.getCollection(subjectCollection);
|
||||
@ -128,9 +127,9 @@ public class SpongeMainCommand extends Command<Void, LPSubjectData> {
|
||||
List<String> extra = subjects.subList(50, subjects.size());
|
||||
int overflow = extra.size();
|
||||
extra.clear();
|
||||
MessageUtils.sendPluginMessage(sender, "&aCurrent Subjects:\n" + MessageUtils.toCommaSep(subjects) + "&b ... and &a" + overflow + " &bmore.");
|
||||
Message.BLANK.send(sender, "&aCurrent Subjects:\n" + MessageUtils.toCommaSep(subjects) + "&b ... and &a" + overflow + " &bmore.");
|
||||
} else {
|
||||
MessageUtils.sendPluginMessage(sender, "&aCurrent Subjects:\n" + MessageUtils.toCommaSep(subjects));
|
||||
Message.BLANK.send(sender, "&aCurrent Subjects:\n" + MessageUtils.toCommaSep(subjects));
|
||||
}
|
||||
|
||||
return CommandResult.SUCCESS;
|
||||
@ -181,7 +180,7 @@ public class SpongeMainCommand extends Command<Void, LPSubjectData> {
|
||||
|
||||
String subjectId = args.get(1);
|
||||
if (!collection.hasRegistered(subjectId).join()) {
|
||||
MessageUtils.sendPluginMessage(sender, "Warning: Subject '&4" + subjectId + "&c' doesn't already exist. Creating it now.");
|
||||
Message.BLANK.send(sender, "Warning: Subject '&4" + subjectId + "&c' doesn't already exist. Creating it now.");
|
||||
}
|
||||
|
||||
LPSubject subject = collection.loadSubject(subjectId).join();
|
||||
@ -198,19 +197,19 @@ public class SpongeMainCommand extends Command<Void, LPSubjectData> {
|
||||
|
||||
@Override
|
||||
public void sendUsage(Sender sender, String label) {
|
||||
MessageUtils.sendPluginMessage(sender, "&3> &a" + String.format(getUsage(), label));
|
||||
Message.BLANK.send(sender, "&3> &a" + String.format(getUsage(), label));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDetailedUsage(Sender sender, String label) {
|
||||
MessageUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s sponge <collection> <subject> [-transient]", label) + " ...)");
|
||||
Message.BLANK.send(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 = this.subCommands.get(s.toLowerCase()).stream()
|
||||
.filter(sub -> sub.isAuthorized(sender))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!subs.isEmpty()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&3>> &b" + s);
|
||||
Message.BLANK.send(sender, "&3>> &b" + s);
|
||||
for (Command sub : subs) {
|
||||
sub.sendUsage(sender, label);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user