mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Fix issue with bulk removing suffixes
This commit is contained in:
parent
7c398d2c67
commit
152ca99276
@ -68,14 +68,14 @@ public class MetaRemoveChatMeta extends SharedSubCommand {
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||
int priority = ArgumentUtils.handlePriority(0, args);
|
||||
String prefix = ArgumentUtils.handleStringOrElse(1, args, "null");
|
||||
String meta = ArgumentUtils.handleStringOrElse(1, args, "null");
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args);
|
||||
|
||||
// Handle bulk removal
|
||||
if (prefix.equalsIgnoreCase("null")) {
|
||||
if (meta.equalsIgnoreCase("null") || meta.equals("*")) {
|
||||
holder.removeIf(n ->
|
||||
n.isPrefix() &&
|
||||
n.getPrefix().getKey() == priority &&
|
||||
(isPrefix ? n.isPrefix() : n.isSuffix()) &&
|
||||
(isPrefix ? n.getPrefix() : n.getSuffix()).getKey() == priority &&
|
||||
!n.isTemporary() &&
|
||||
n.getFullContexts().makeImmutable().equals(context.makeImmutable())
|
||||
);
|
||||
@ -84,10 +84,10 @@ public class MetaRemoveChatMeta extends SharedSubCommand {
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(isPrefix, priority, prefix).withExtraContext(context).build());
|
||||
DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(isPrefix, priority, meta).withExtraContext(context).build());
|
||||
|
||||
if (result.asBoolean()) {
|
||||
Message.REMOVE_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), DESCRIPTOR.apply(isPrefix), prefix, priority, Util.contextSetToString(context));
|
||||
Message.REMOVE_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), DESCRIPTOR.apply(isPrefix), meta, priority, Util.contextSetToString(context));
|
||||
|
||||
LogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta remove" + DESCRIPTOR.apply(isPrefix) + " " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||
|
@ -68,14 +68,14 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand {
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label) throws CommandException {
|
||||
int priority = ArgumentUtils.handlePriority(0, args);
|
||||
String prefix = ArgumentUtils.handleStringOrElse(1, args, "null");
|
||||
String meta = ArgumentUtils.handleStringOrElse(1, args, "null");
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args);
|
||||
|
||||
// Handle bulk removal
|
||||
if (prefix.equalsIgnoreCase("null")) {
|
||||
if (meta.equalsIgnoreCase("null") || meta.equals("*")) {
|
||||
holder.removeIf(n ->
|
||||
n.isPrefix() &&
|
||||
n.getPrefix().getKey() == priority &&
|
||||
(isPrefix ? n.isPrefix() : n.isSuffix()) &&
|
||||
(isPrefix ? n.getPrefix() : n.getSuffix()).getKey() == priority &&
|
||||
!n.isPermanent() &&
|
||||
n.getFullContexts().makeImmutable().equals(context.makeImmutable())
|
||||
);
|
||||
@ -84,10 +84,10 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand {
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(isPrefix, priority, prefix).setExpiry(10L).withExtraContext(context).build());
|
||||
DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(isPrefix, priority, meta).setExpiry(10L).withExtraContext(context).build());
|
||||
|
||||
if (result.asBoolean()) {
|
||||
Message.REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), DESCRIPTOR.apply(isPrefix), prefix, priority, Util.contextSetToString(context));
|
||||
Message.REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), DESCRIPTOR.apply(isPrefix), meta, priority, Util.contextSetToString(context));
|
||||
|
||||
LogEntry.build().actor(sender).acted(holder)
|
||||
.action("meta removetemp" + DESCRIPTOR.apply(isPrefix) + " " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
|
||||
|
@ -253,9 +253,9 @@ public enum Message {
|
||||
ADD_CHATMETA_SUCCESS("&b{0}&a had {1} &f\"{2}&f\"&a set at a priority of &b{3}&a in context {4}&a.", true),
|
||||
ADD_TEMP_CHATMETA_SUCCESS("&b{0}&a had {1} &f\"{2}&f\"&a set at a priority of &b{3}&a for a duration of &b{4}&a in context {5}&a.", true),
|
||||
REMOVE_CHATMETA_SUCCESS("&b{0}&a had {1} &f\"{2}&f\"&a at priority &b{3}&a removed in context {4}&a.", true),
|
||||
BULK_REMOVE_CHATMETA_SUCCESS("&b{0}&a had all {1}es at priority &b{3}&a removed in context {4}&a.", true),
|
||||
BULK_REMOVE_CHATMETA_SUCCESS("&b{0}&a had all {1}es at priority &b{2}&a removed in context {3}&a.", true),
|
||||
REMOVE_TEMP_CHATMETA_SUCCESS("&b{0}&a had temporary {1} &f\"{2}&f\"&a at priority &b{3}&a removed in context {4}&a.", true),
|
||||
BULK_REMOVE_TEMP_CHATMETA_SUCCESS("&b{0}&a had all temporary {1}es at priority &b{3}&a removed in context {4}&a.", true),
|
||||
BULK_REMOVE_TEMP_CHATMETA_SUCCESS("&b{0}&a had all temporary {1}es at priority &b{2}&a removed in context {3}&a.", true),
|
||||
|
||||
ALREADY_HAS_META("{0} already has that meta key value pair set.", true),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user