mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-01-06 08:27:37 +01:00
Make prefix/suffix string optional in the meta remove commands - related to #83
This commit is contained in:
parent
32fd484b58
commit
148fe4c729
@ -57,7 +57,7 @@ public class MetaAddPrefix extends SharedSubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
int priority = ArgumentUtils.handlePriority(0, args);
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
String prefix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
String prefix = ArgumentUtils.handleString(1, args);
|
||||||
String server = ArgumentUtils.handleServer(2, args);
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
String world = ArgumentUtils.handleWorld(3, args);
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class MetaAddSuffix extends SharedSubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
int priority = ArgumentUtils.handlePriority(0, args);
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
String suffix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
String suffix = ArgumentUtils.handleString(1, args);
|
||||||
String server = ArgumentUtils.handleServer(2, args);
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
String world = ArgumentUtils.handleWorld(3, args);
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class MetaAddTempPrefix extends SharedSubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
int priority = ArgumentUtils.handlePriority(0, args);
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
String prefix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
String prefix = ArgumentUtils.handleString(1, args);
|
||||||
long duration = ArgumentUtils.handleDuration(2, args);
|
long duration = ArgumentUtils.handleDuration(2, args);
|
||||||
String server = ArgumentUtils.handleServer(3, args);
|
String server = ArgumentUtils.handleServer(3, args);
|
||||||
String world = ArgumentUtils.handleWorld(4, args);
|
String world = ArgumentUtils.handleWorld(4, args);
|
||||||
|
@ -59,7 +59,7 @@ public class MetaAddTempSuffix extends SharedSubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
int priority = ArgumentUtils.handlePriority(0, args);
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
String suffix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
String suffix = ArgumentUtils.handleString(1, args);
|
||||||
long duration = ArgumentUtils.handleDuration(2, args);
|
long duration = ArgumentUtils.handleDuration(2, args);
|
||||||
String server = ArgumentUtils.handleServer(3, args);
|
String server = ArgumentUtils.handleServer(3, args);
|
||||||
String world = ArgumentUtils.handleWorld(4, args);
|
String world = ArgumentUtils.handleWorld(4, args);
|
||||||
|
@ -46,10 +46,10 @@ import java.util.stream.Collectors;
|
|||||||
public class MetaRemovePrefix extends SharedSubCommand {
|
public class MetaRemovePrefix extends SharedSubCommand {
|
||||||
public MetaRemovePrefix() {
|
public MetaRemovePrefix() {
|
||||||
super("removeprefix", "Removes a prefix", Permission.USER_META_REMOVEPREFIX, Permission.GROUP_META_REMOVEPREFIX,
|
super("removeprefix", "Removes a prefix", Permission.USER_META_REMOVEPREFIX, Permission.GROUP_META_REMOVEPREFIX,
|
||||||
Predicates.notInRange(2, 4),
|
Predicates.notInRange(1, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("priority", true, "the priority to add the prefix at"),
|
Arg.create("priority", true, "the priority to add the prefix at"),
|
||||||
Arg.create("prefix", true, "the prefix string"),
|
Arg.create("prefix", false, "the prefix string"),
|
||||||
Arg.create("server", false, "the server to add the prefix on"),
|
Arg.create("server", false, "the server to add the prefix on"),
|
||||||
Arg.create("world", false, "the world to add the prefix on")
|
Arg.create("world", false, "the world to add the prefix on")
|
||||||
)
|
)
|
||||||
@ -59,7 +59,7 @@ public class MetaRemovePrefix extends SharedSubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
int priority = ArgumentUtils.handlePriority(0, args);
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
String prefix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
String prefix = ArgumentUtils.handleStringOrElse(1, args, "null");
|
||||||
String server = ArgumentUtils.handleServer(2, args);
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
String world = ArgumentUtils.handleWorld(3, args);
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
|
|
||||||
|
@ -46,10 +46,10 @@ import java.util.stream.Collectors;
|
|||||||
public class MetaRemoveSuffix extends SharedSubCommand {
|
public class MetaRemoveSuffix extends SharedSubCommand {
|
||||||
public MetaRemoveSuffix() {
|
public MetaRemoveSuffix() {
|
||||||
super("removesuffix", "Removes a suffix", Permission.USER_META_REMOVESUFFIX, Permission.GROUP_META_REMOVESUFFIX,
|
super("removesuffix", "Removes a suffix", Permission.USER_META_REMOVESUFFIX, Permission.GROUP_META_REMOVESUFFIX,
|
||||||
Predicates.notInRange(2, 4),
|
Predicates.notInRange(1, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("priority", true, "the priority to add the suffix at"),
|
Arg.create("priority", true, "the priority to add the suffix at"),
|
||||||
Arg.create("suffix", true, "the suffix string"),
|
Arg.create("suffix", false, "the suffix string"),
|
||||||
Arg.create("server", false, "the server to add the suffix on"),
|
Arg.create("server", false, "the server to add the suffix on"),
|
||||||
Arg.create("world", false, "the world to add the suffix on")
|
Arg.create("world", false, "the world to add the suffix on")
|
||||||
)
|
)
|
||||||
@ -59,7 +59,7 @@ public class MetaRemoveSuffix extends SharedSubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
int priority = ArgumentUtils.handlePriority(0, args);
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
String suffix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
String suffix = ArgumentUtils.handleStringOrElse(1, args, "null");
|
||||||
String server = ArgumentUtils.handleServer(2, args);
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
String world = ArgumentUtils.handleWorld(3, args);
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
|
|
||||||
|
@ -45,10 +45,11 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class MetaRemoveTempPrefix extends SharedSubCommand {
|
public class MetaRemoveTempPrefix extends SharedSubCommand {
|
||||||
public MetaRemoveTempPrefix() {
|
public MetaRemoveTempPrefix() {
|
||||||
super("removetempprefix", "Removes a temporary prefix", Permission.USER_META_REMOVETEMP_PREFIX, Permission.GROUP_META_REMOVETEMP_PREFIX, Predicates.notInRange(2, 4),
|
super("removetempprefix", "Removes a temporary prefix", Permission.USER_META_REMOVETEMP_PREFIX, Permission.GROUP_META_REMOVETEMP_PREFIX,
|
||||||
|
Predicates.notInRange(1, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("priority", true, "the priority to add the prefix at"),
|
Arg.create("priority", true, "the priority to add the prefix at"),
|
||||||
Arg.create("prefix", true, "the prefix string"),
|
Arg.create("prefix", false, "the prefix string"),
|
||||||
Arg.create("server", false, "the server to add the prefix on"),
|
Arg.create("server", false, "the server to add the prefix on"),
|
||||||
Arg.create("world", false, "the world to add the prefix on")
|
Arg.create("world", false, "the world to add the prefix on")
|
||||||
)
|
)
|
||||||
@ -58,7 +59,7 @@ public class MetaRemoveTempPrefix extends SharedSubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
int priority = ArgumentUtils.handlePriority(0, args);
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
String prefix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
String prefix = ArgumentUtils.handleStringOrElse(1, args, "null");
|
||||||
String server = ArgumentUtils.handleServer(2, args);
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
String world = ArgumentUtils.handleWorld(3, args);
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
|
|
||||||
@ -90,8 +91,7 @@ public class MetaRemoveTempPrefix extends SharedSubCommand {
|
|||||||
toRemove.forEach(n -> {
|
toRemove.forEach(n -> {
|
||||||
try {
|
try {
|
||||||
holder.unsetPermission(n);
|
holder.unsetPermission(n);
|
||||||
} catch (ObjectLacksException ignored) {
|
} catch (ObjectLacksException ignored) {}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Message.BULK_CHANGE_SUCCESS.send(sender, toRemove.size());
|
Message.BULK_CHANGE_SUCCESS.send(sender, toRemove.size());
|
||||||
|
@ -45,10 +45,11 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class MetaRemoveTempSuffix extends SharedSubCommand {
|
public class MetaRemoveTempSuffix extends SharedSubCommand {
|
||||||
public MetaRemoveTempSuffix() {
|
public MetaRemoveTempSuffix() {
|
||||||
super("removetempsuffix", "Removes a temporary suffix", Permission.USER_META_REMOVETEMP_SUFFIX, Permission.GROUP_META_REMOVETEMP_SUFFIX, Predicates.notInRange(2, 4),
|
super("removetempsuffix", "Removes a temporary suffix", Permission.USER_META_REMOVETEMP_SUFFIX, Permission.GROUP_META_REMOVETEMP_SUFFIX,
|
||||||
|
Predicates.notInRange(1, 4),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("priority", true, "the priority to add the suffix at"),
|
Arg.create("priority", true, "the priority to add the suffix at"),
|
||||||
Arg.create("suffix", true, "the suffix string"),
|
Arg.create("suffix", false, "the suffix string"),
|
||||||
Arg.create("server", false, "the server to add the suffix on"),
|
Arg.create("server", false, "the server to add the suffix on"),
|
||||||
Arg.create("world", false, "the world to add the suffix on")
|
Arg.create("world", false, "the world to add the suffix on")
|
||||||
)
|
)
|
||||||
@ -58,7 +59,7 @@ public class MetaRemoveTempSuffix extends SharedSubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
int priority = ArgumentUtils.handlePriority(0, args);
|
int priority = ArgumentUtils.handlePriority(0, args);
|
||||||
String suffix = ArgumentUtils.handleNodeWithoutCheck(1, args);
|
String suffix = ArgumentUtils.handleStringOrElse(1, args, "null");
|
||||||
String server = ArgumentUtils.handleServer(2, args);
|
String server = ArgumentUtils.handleServer(2, args);
|
||||||
String world = ArgumentUtils.handleWorld(3, args);
|
String world = ArgumentUtils.handleWorld(3, args);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class PermissionCheck extends SharedSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
String node = ArgumentUtils.handleNodeWithoutCheck(0, args);
|
String node = ArgumentUtils.handleString(0, args);
|
||||||
String server = ArgumentUtils.handleServer(1, args);
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
String world = ArgumentUtils.handleWorld(2, args);
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class PermissionCheckInherits extends SharedSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||||
String node = ArgumentUtils.handleNodeWithoutCheck(0, args);
|
String node = ArgumentUtils.handleString(0, args);
|
||||||
String server = ArgumentUtils.handleServer(1, args);
|
String server = ArgumentUtils.handleServer(1, args);
|
||||||
String world = ArgumentUtils.handleWorld(2, args);
|
String world = ArgumentUtils.handleWorld(2, args);
|
||||||
|
|
||||||
|
@ -40,7 +40,15 @@ import java.util.function.Function;
|
|||||||
public class ArgumentUtils {
|
public class ArgumentUtils {
|
||||||
public static final Function<String, String> WRAPPER = s -> s.contains(" ") ? "\"" + s + "\"" : s;
|
public static final Function<String, String> WRAPPER = s -> s.contains(" ") ? "\"" + s + "\"" : s;
|
||||||
|
|
||||||
public static String handleNodeWithoutCheck(int index, List<String> args) {
|
public static String handleString(int index, List<String> args) {
|
||||||
|
return args.get(index).replace("{SPACE}", " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String handleStringOrElse(int index, List<String> args, String other) {
|
||||||
|
if (index < 0 || index >= args.size()) {
|
||||||
|
return other;
|
||||||
|
}
|
||||||
|
|
||||||
return args.get(index).replace("{SPACE}", " ");
|
return args.get(index).replace("{SPACE}", " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user