mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-08-31 08:29:33 +02:00
Add type argument to 'meta clear' command (#457)
This commit is contained in:
parent
754c7d8e3b
commit
b6e1fd179e
|
@ -26,13 +26,10 @@ already-has-temp-permission: "{0} already has this permission set temporarily!"
|
||||||
does-not-have-temp-permission: "{0} does not have this permission set temporarily."
|
does-not-have-temp-permission: "{0} does not have this permission set temporarily."
|
||||||
user-not-found: "&bUser could not be found."
|
user-not-found: "&bUser could not be found."
|
||||||
user-not-online: "&bUser &a{0}&b is not online."
|
user-not-online: "&bUser &a{0}&b is not online."
|
||||||
user-save-success: "&7(User data was saved to storage)"
|
|
||||||
user-save-error: "There was an error whilst saving the user."
|
user-save-error: "There was an error whilst saving the user."
|
||||||
group-not-found: "&bGroup could not be found."
|
group-not-found: "&bGroup could not be found."
|
||||||
group-save-success: "&7(Group data was saved to storage)"
|
|
||||||
group-save-error: "There was an error whilst saving the group."
|
group-save-error: "There was an error whilst saving the group."
|
||||||
track-not-found: "&bTrack could not be found."
|
track-not-found: "&bTrack could not be found."
|
||||||
track-save-success: "&7(Track data was saved to storage)"
|
|
||||||
track-save-error: "There was an error whilst saving the track."
|
track-save-error: "There was an error whilst saving the track."
|
||||||
user-invalid-entry: "&d{0}&c is not a valid username/uuid."
|
user-invalid-entry: "&d{0}&c is not a valid username/uuid."
|
||||||
group-invalid-entry: "Group names can only contain alphanumeric characters."
|
group-invalid-entry: "Group names can only contain alphanumeric characters."
|
||||||
|
@ -95,34 +92,22 @@ update-task-push-success: "&aOther servers were notified via &b{0} Messaging &as
|
||||||
update-task-push-failure: "&cError whilst pushing changes to other servers."
|
update-task-push-failure: "&cError whilst pushing changes to other servers."
|
||||||
update-task-push-failure-not-setup: "&cError whilst pushing changes to other servers. A messaging service has not been configured."
|
update-task-push-failure-not-setup: "&cError whilst pushing changes to other servers. A messaging service has not been configured."
|
||||||
reload-config-success: "&aThe configuration file was reloaded. &7(some options will only apply after the server has restarted.)"
|
reload-config-success: "&aThe configuration file was reloaded. &7(some options will only apply after the server has restarted.)"
|
||||||
info: >
|
info-top: >
|
||||||
{PREFIX}&2Running &bLuckPerms v{0}&2 by &bLuck&2.\n
|
{PREFIX}&2Running &bLuckPerms v{0}&2 by &bLuck&2.\n
|
||||||
{PREFIX}&f- &3Platform: &f{1}\n
|
{PREFIX}&f- &3Platform: &f{1}\n
|
||||||
{PREFIX}&f- &3Storage Method: &f{2}\n
|
{PREFIX}&f- &3Server Brand: &f{2}\n
|
||||||
{PREFIX}&f- &3Server Name: &f{3}\n
|
{PREFIX}&f- &3Server Version: &f{3}
|
||||||
{PREFIX}&f- &3Sync Interval: &a{4} &fminutes\n
|
info-middle: >
|
||||||
{PREFIX}&f- &3Messaging Service: &f{5}\n
|
{PREFIX}&f- &bMessaging Type: &f{0}\n
|
||||||
{PREFIX}&f- &bCounts:\n
|
{PREFIX}&f- &bInstance:\n
|
||||||
{PREFIX}&f- &3Online Players: &a{6}\n
|
{PREFIX}&f- &3Server Name: &f{1}\n
|
||||||
{PREFIX}&f- &3Loaded Users: &a{7}\n
|
{PREFIX}&f- &3Online Players: &a{2}\n
|
||||||
{PREFIX}&f- &3Loaded Groups: &a{8}\n
|
{PREFIX}&f- &3Unique Connections: &a{3}\n
|
||||||
{PREFIX}&f- &3Loaded Tracks: &a{9}\n
|
{PREFIX}&f- &3Uptime: &7{4}\n
|
||||||
{PREFIX}&f- &3Log size: &a{10}\n
|
{PREFIX}&f- &3Local Data: &a{5} &7users, &a{6} &7groups, &a{7} &7tracks\n
|
||||||
{PREFIX}&f- &3UUID Cache size: &a{11}\n
|
{PREFIX}&f- &3Context Calculators: &a{8}\n
|
||||||
{PREFIX}&f- &3Translations loaded: &a{12}\n
|
{PREFIX}&f- &3Known permissions: &a{9}\n
|
||||||
{PREFIX}&f- &3Pre-process contexts: &a{13}\n
|
{PREFIX}&f- &3Active processors: &7{10}
|
||||||
{PREFIX}&f- &3Context Calculators: &a{14}\n
|
|
||||||
{PREFIX}&f- &3Unique permissions: &a{15}\n
|
|
||||||
{PREFIX}&f- &bConfiguration:\n
|
|
||||||
{PREFIX}&f- &3Use Server UUIDs: {16}\n
|
|
||||||
{PREFIX}&f- &bPermission Calculation:\n
|
|
||||||
{PREFIX}&f- &3Including Global: {17}\n
|
|
||||||
{PREFIX}&f- &3Including Global World: {18}\n
|
|
||||||
{PREFIX}&f- &3Applying Global Groups: {19}\n
|
|
||||||
{PREFIX}&f- &3Applying Global World Groups: {20}\n
|
|
||||||
{PREFIX}&f- &3Applying Wildcards: {21}\n
|
|
||||||
{PREFIX}&f- &3Applying Regex: {22}\n
|
|
||||||
{PREFIX}&f- &3Applying Shorthand: {23}
|
|
||||||
create-group-error: "There was an error whilst creating the group."
|
create-group-error: "There was an error whilst creating the group."
|
||||||
delete-group-error: "There was an error whilst deleting the group."
|
delete-group-error: "There was an error whilst deleting the group."
|
||||||
delete-group-error-default: "You cannot delete the default group."
|
delete-group-error-default: "You cannot delete the default group."
|
||||||
|
@ -147,6 +132,7 @@ context-pair--global-inline: "&eglobal"
|
||||||
context-pair-sep: "&a, "
|
context-pair-sep: "&a, "
|
||||||
context-pair: "&8(&7{0}=&f{1}&8)"
|
context-pair: "&8(&7{0}=&f{1}&8)"
|
||||||
check-permission: "&b{0}&a has permission &b{1}&a set to {2}&a in context {3}&a."
|
check-permission: "&b{0}&a has permission &b{1}&a set to {2}&a in context {3}&a."
|
||||||
|
check-inherits-permission: "&b{0}&a has permission &b{1}&a set to {2}&a in context {3}&a. &7(inherited from &a{4}&7)"
|
||||||
setpermission-success: "&aSet &b{0}&a to &b{1}&a for &b{2}&a in context {3}&a."
|
setpermission-success: "&aSet &b{0}&a to &b{1}&a for &b{2}&a in context {3}&a."
|
||||||
setpermission-temp-success: "&aSet &b{0}&a to &b{1}&a for &b{2}&a for a duration of &b{3}&a in context {4}&a."
|
setpermission-temp-success: "&aSet &b{0}&a to &b{1}&a for &b{2}&a for a duration of &b{3}&a in context {4}&a."
|
||||||
unsetpermission-success: "&aUnset &b{0}&a for &b{1}&a in context {2}&a."
|
unsetpermission-success: "&aUnset &b{0}&a for &b{1}&a in context {2}&a."
|
||||||
|
@ -159,12 +145,12 @@ unset-inherit-success: "&b{0}&a no longer inherits permissions from &b{1}&a in c
|
||||||
unset-temp-inherit-success: "&b{0}&a no longer temporarily inherits permissions from &b{1}&a in context {2}&a."
|
unset-temp-inherit-success: "&b{0}&a no longer temporarily inherits permissions from &b{1}&a in context {2}&a."
|
||||||
clear-success: "&b{0}&a's permissions were cleared in context {1}&a. (&b{2}&a nodes were removed.)"
|
clear-success: "&b{0}&a's permissions were cleared in context {1}&a. (&b{2}&a nodes were removed.)"
|
||||||
clear-success-singular: "&b{0}&a's permissions were cleared in context {1}&a. (&b{2}&a node was removed.)"
|
clear-success-singular: "&b{0}&a's permissions were cleared in context {1}&a. (&b{2}&a node was removed.)"
|
||||||
parent-clear-success: "&b{0}&a's parents were cleared in context {1}&a. &b{2}&a nodes were removed.)"
|
parent-clear-success: "&b{0}&a's parents were cleared in context {1}&a. (&b{2}&a nodes were removed.)"
|
||||||
parent-clear-success-singular: "&b{0}&a's parents were cleared in context {1}&a. &b{2}&a node was removed.)"
|
parent-clear-success-singular: "&b{0}&a's parents were cleared in context {1}&a. (&b{2}&a node was removed.)"
|
||||||
parent-clear-track-success: "&b{0}&a's parents on track &b{1}&a were cleared in context {2}&a. &b{3}&a nodes were removed.)"
|
parent-clear-track-success: "&b{0}&a's parents on track &b{1}&a were cleared in context {2}&a. (&b{3}&a nodes were removed.)"
|
||||||
parent-clear-track-success-singular: "&b{0}&a's parents on track &b{1}&a were cleared in context {2}&a. &b{3}&a node was removed.)"
|
parent-clear-track-success-singular: "&b{0}&a's parents on track &b{1}&a were cleared in context {2}&a. (&b{3}&a node was removed.)"
|
||||||
meta-clear-success: "&b{0}&a's meta was cleared in context {1}&a. &b{2}&a nodes were removed.)"
|
meta-clear-success: "&b{0}&a's meta matching type &b{1}&a was cleared in context {2}&a. (&b{3}&a nodes were removed.)"
|
||||||
meta-clear-success-singular: "&b{0}&a's meta was cleared in context {1}&a. &b{2}&a node was removed.)"
|
meta-clear-success-singular: "&b{0}&a's meta matching type &b{1}&a was cleared in context {2}&a. (&b{3}&a node was removed.)"
|
||||||
illegal-date-error: "Could not parse date '{0}'."
|
illegal-date-error: "Could not parse date '{0}'."
|
||||||
past-date-error: "You cannot set a date in the past!"
|
past-date-error: "You cannot set a date in the past!"
|
||||||
chat-meta-prefix-header: "&b{0}'s Prefixes"
|
chat-meta-prefix-header: "&b{0}'s Prefixes"
|
||||||
|
@ -261,6 +247,7 @@ log-invalid-page: "Invalid page number."
|
||||||
log-invalid-page-range: "Invalid page number. Please enter a value between 1 and {0}."
|
log-invalid-page-range: "Invalid page number. Please enter a value between 1 and {0}."
|
||||||
log-no-entries: "&bNo log entries to show."
|
log-no-entries: "&bNo log entries to show."
|
||||||
log-entry: "&b#{0} -> &8(&7{1} ago&8) {2}"
|
log-entry: "&b#{0} -> &8(&7{1} ago&8) {2}"
|
||||||
|
log-notify-console: "&cCannot toggle notifications for console."
|
||||||
log-notify-toggle-on: "&aEnabled&b logging output."
|
log-notify-toggle-on: "&aEnabled&b logging output."
|
||||||
log-notify-toggle-off: "&cDisabled&b logging output."
|
log-notify-toggle-off: "&cDisabled&b logging output."
|
||||||
log-notify-already-on: "You are already receiving notifications."
|
log-notify-already-on: "You are already receiving notifications."
|
||||||
|
@ -606,8 +593,9 @@ command-specs:
|
||||||
"suffix": "the suffix string"
|
"suffix": "the suffix string"
|
||||||
"context...": "the contexts to remove the suffix in"
|
"context...": "the contexts to remove the suffix in"
|
||||||
meta-clear:
|
meta-clear:
|
||||||
description: "Clears all chat meta"
|
description: "Clears all meta"
|
||||||
args:
|
args:
|
||||||
|
"type": "the type of meta to remove"
|
||||||
"context...": "the contexts to filter by"
|
"context...": "the contexts to filter by"
|
||||||
track-info:
|
track-info:
|
||||||
description: "Gives info about the track"
|
description: "Gives info about the track"
|
||||||
|
|
|
@ -43,6 +43,7 @@ import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||||
import me.lucko.luckperms.common.contexts.ExtractedContexts;
|
import me.lucko.luckperms.common.contexts.ExtractedContexts;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
|
import me.lucko.luckperms.common.node.MetaType;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.NodeFactory;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||||
|
@ -381,12 +382,12 @@ public class PermissionHolderDelegate implements PermissionHolder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearMeta() {
|
public void clearMeta() {
|
||||||
handle.clearMeta();
|
handle.clearMeta(MetaType.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearMeta(@NonNull ContextSet contextSet) {
|
public void clearMeta(@NonNull ContextSet contextSet) {
|
||||||
handle.clearMeta(contextSet);
|
handle.clearMeta(MetaType.ANY, contextSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -396,7 +397,7 @@ public class PermissionHolderDelegate implements PermissionHolder {
|
||||||
set.add("server", server);
|
set.add("server", server);
|
||||||
}
|
}
|
||||||
|
|
||||||
handle.clearMeta(set);
|
handle.clearMeta(MetaType.ANY, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -409,7 +410,7 @@ public class PermissionHolderDelegate implements PermissionHolder {
|
||||||
set.add("world", world);
|
set.add("world", world);
|
||||||
}
|
}
|
||||||
|
|
||||||
handle.clearMeta(set);
|
handle.clearMeta(MetaType.ANY, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,6 +39,7 @@ import me.lucko.luckperms.common.locale.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.Message;
|
import me.lucko.luckperms.common.locale.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
|
import me.lucko.luckperms.common.node.MetaType;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
|
@ -57,6 +58,34 @@ public class MetaClear extends SharedSubCommand {
|
||||||
return CommandResult.NO_PERMISSION;
|
return CommandResult.NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaType type = null;
|
||||||
|
if (args.size() > 0) {
|
||||||
|
String typeId = args.get(0).toLowerCase();
|
||||||
|
if (typeId.equals("any") || typeId.equals("all") || typeId.equals("*")) {
|
||||||
|
type = MetaType.ANY;
|
||||||
|
}
|
||||||
|
if (typeId.equals("chat") || typeId.equals("chatmeta")) {
|
||||||
|
type = MetaType.CHAT;
|
||||||
|
}
|
||||||
|
if (typeId.equals("meta")) {
|
||||||
|
type = MetaType.META;
|
||||||
|
}
|
||||||
|
if (typeId.equals("prefix") || typeId.equals("prefixes")) {
|
||||||
|
type = MetaType.PREFIX;
|
||||||
|
}
|
||||||
|
if (typeId.equals("suffix") || typeId.equals("suffixes")) {
|
||||||
|
type = MetaType.SUFFIX;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type != null) {
|
||||||
|
args.remove(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == null) {
|
||||||
|
type = MetaType.ANY;
|
||||||
|
}
|
||||||
|
|
||||||
int before = holder.getEnduringNodes().size();
|
int before = holder.getEnduringNodes().size();
|
||||||
|
|
||||||
MutableContextSet context = ArgumentUtils.handleContext(0, args, plugin);
|
MutableContextSet context = ArgumentUtils.handleContext(0, args, plugin);
|
||||||
|
@ -67,16 +96,16 @@ public class MetaClear extends SharedSubCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.isEmpty()) {
|
if (context.isEmpty()) {
|
||||||
holder.clearMeta();
|
holder.clearMeta(type);
|
||||||
} else {
|
} else {
|
||||||
holder.clearMeta(context);
|
holder.clearMeta(type, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
int changed = before - holder.getEnduringNodes().size();
|
int changed = before - holder.getEnduringNodes().size();
|
||||||
if (changed == 1) {
|
if (changed == 1) {
|
||||||
Message.META_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), Util.contextSetToString(context), changed);
|
Message.META_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), Util.contextSetToString(context), changed);
|
||||||
} else {
|
} else {
|
||||||
Message.META_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), Util.contextSetToString(context), changed);
|
Message.META_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), Util.contextSetToString(context), changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||||
|
|
|
@ -368,8 +368,9 @@ public enum CommandSpec {
|
||||||
Arg.create("context...", false, "the contexts to remove the suffix in")
|
Arg.create("context...", false, "the contexts to remove the suffix in")
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
META_CLEAR("Clears all chat meta",
|
META_CLEAR("Clears all meta",
|
||||||
Arg.list(
|
Arg.list(
|
||||||
|
Arg.create("type", false, "the type of meta to remove"),
|
||||||
Arg.create("context...", false, "the contexts to filter by")
|
Arg.create("context...", false, "the contexts to filter by")
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
|
@ -230,14 +230,14 @@ public enum Message {
|
||||||
|
|
||||||
CLEAR_SUCCESS("&b{0}&a's permissions were cleared in context {1}&a. (&b{2}&a nodes were removed.)", true),
|
CLEAR_SUCCESS("&b{0}&a's permissions were cleared in context {1}&a. (&b{2}&a nodes were removed.)", true),
|
||||||
CLEAR_SUCCESS_SINGULAR("&b{0}&a's permissions were cleared in context {1}&a. (&b{2}&a node was removed.)", true),
|
CLEAR_SUCCESS_SINGULAR("&b{0}&a's permissions were cleared in context {1}&a. (&b{2}&a node was removed.)", true),
|
||||||
PARENT_CLEAR_SUCCESS("&b{0}&a's parents were cleared in context {1}&a. &b{2}&a nodes were removed.)", true),
|
PARENT_CLEAR_SUCCESS("&b{0}&a's parents were cleared in context {1}&a. (&b{2}&a nodes were removed.)", true),
|
||||||
PARENT_CLEAR_SUCCESS_SINGULAR("&b{0}&a's parents were cleared in context {1}&a. &b{2}&a node was removed.)", true),
|
PARENT_CLEAR_SUCCESS_SINGULAR("&b{0}&a's parents were cleared in context {1}&a. (&b{2}&a node was removed.)", true),
|
||||||
|
|
||||||
PARENT_CLEAR_TRACK_SUCCESS("&b{0}&a's parents on track &b{1}&a were cleared in context {2}&a. &b{3}&a nodes were removed.)", true),
|
PARENT_CLEAR_TRACK_SUCCESS("&b{0}&a's parents on track &b{1}&a were cleared in context {2}&a. (&b{3}&a nodes were removed.)", true),
|
||||||
PARENT_CLEAR_TRACK_SUCCESS_SINGULAR("&b{0}&a's parents on track &b{1}&a were cleared in context {2}&a. &b{3}&a node was removed.)", true),
|
PARENT_CLEAR_TRACK_SUCCESS_SINGULAR("&b{0}&a's parents on track &b{1}&a were cleared in context {2}&a. (&b{3}&a node was removed.)", true),
|
||||||
|
|
||||||
META_CLEAR_SUCCESS("&b{0}&a's meta was cleared in context {1}&a. &b{2}&a nodes were removed.)", true),
|
META_CLEAR_SUCCESS("&b{0}&a's meta matching type &b{1}&a was cleared in context {2}&a. (&b{3}&a nodes were removed.)", true),
|
||||||
META_CLEAR_SUCCESS_SINGULAR("&b{0}&a's meta was cleared in context {1}&a. &b{2}&a node was removed.)", true),
|
META_CLEAR_SUCCESS_SINGULAR("&b{0}&a's meta matching type &b{1}&a was cleared in context {2}&a. (&b{3}&a node was removed.)", true),
|
||||||
|
|
||||||
ILLEGAL_DATE_ERROR("Could not parse date '{0}'.", true),
|
ILLEGAL_DATE_ERROR("Could not parse date '{0}'.", true),
|
||||||
PAST_DATE_ERROR("You cannot set a date in the past!", true),
|
PAST_DATE_ERROR("You cannot set a date in the past!", true),
|
||||||
|
|
|
@ -53,6 +53,7 @@ import me.lucko.luckperms.common.contexts.ContextSetComparator;
|
||||||
import me.lucko.luckperms.common.contexts.ExtractedContexts;
|
import me.lucko.luckperms.common.contexts.ExtractedContexts;
|
||||||
import me.lucko.luckperms.common.node.ImmutableLocalizedNode;
|
import me.lucko.luckperms.common.node.ImmutableLocalizedNode;
|
||||||
import me.lucko.luckperms.common.node.InheritanceInfo;
|
import me.lucko.luckperms.common.node.InheritanceInfo;
|
||||||
|
import me.lucko.luckperms.common.node.MetaType;
|
||||||
import me.lucko.luckperms.common.node.NodeComparator;
|
import me.lucko.luckperms.common.node.NodeComparator;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.NodeFactory;
|
||||||
import me.lucko.luckperms.common.node.NodeTools;
|
import me.lucko.luckperms.common.node.NodeTools;
|
||||||
|
@ -1361,12 +1362,12 @@ public abstract class PermissionHolder {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean clearMeta() {
|
public boolean clearMeta(MetaType type) {
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = getEnduringNodes().values();
|
||||||
|
|
||||||
nodesLock.lock();
|
nodesLock.lock();
|
||||||
try {
|
try {
|
||||||
if (!nodes.values().removeIf(n -> n.isMeta() || n.isPrefix() || n.isSuffix())) {
|
if (!nodes.values().removeIf(type::matches)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -1379,7 +1380,7 @@ public abstract class PermissionHolder {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean clearMeta(ContextSet contextSet) {
|
public boolean clearMeta(MetaType type, ContextSet contextSet) {
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = getEnduringNodes().values();
|
||||||
|
|
||||||
nodesLock.lock();
|
nodesLock.lock();
|
||||||
|
@ -1389,7 +1390,7 @@ public abstract class PermissionHolder {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean b = nodes.removeIf(n -> n.isMeta() || n.isPrefix() || n.isSuffix());
|
boolean b = nodes.removeIf(type::matches);
|
||||||
if (!b) {
|
if (!b) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
* 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 me.lucko.luckperms.api.Node;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a type of meta
|
||||||
|
*/
|
||||||
|
public enum MetaType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents any meta type
|
||||||
|
*/
|
||||||
|
ANY {
|
||||||
|
@Override
|
||||||
|
public boolean matches(Node node) {
|
||||||
|
return META.matches(node) || PREFIX.matches(node) || SUFFIX.matches(node);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents any chat meta type
|
||||||
|
*/
|
||||||
|
CHAT {
|
||||||
|
@Override
|
||||||
|
public boolean matches(Node node) {
|
||||||
|
return PREFIX.matches(node) || SUFFIX.matches(node);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a meta key-value pair
|
||||||
|
*/
|
||||||
|
META {
|
||||||
|
@Override
|
||||||
|
public boolean matches(Node node) {
|
||||||
|
return node.isMeta();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a prefix
|
||||||
|
*/
|
||||||
|
PREFIX {
|
||||||
|
@Override
|
||||||
|
public boolean matches(Node node) {
|
||||||
|
return node.isPrefix();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a suffix
|
||||||
|
*/
|
||||||
|
SUFFIX {
|
||||||
|
@Override
|
||||||
|
public boolean matches(Node node) {
|
||||||
|
return node.isSuffix();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the passed node matches the type
|
||||||
|
*
|
||||||
|
* @param node the node to test
|
||||||
|
* @return true if the node has the same type
|
||||||
|
*/
|
||||||
|
public abstract boolean matches(Node node);
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user