diff --git a/api/src/main/java/net/luckperms/api/model/PermissionHolder.java b/api/src/main/java/net/luckperms/api/model/PermissionHolder.java index 3dec53c4b..08efb1b11 100644 --- a/api/src/main/java/net/luckperms/api/model/PermissionHolder.java +++ b/api/src/main/java/net/luckperms/api/model/PermissionHolder.java @@ -35,9 +35,6 @@ import net.luckperms.api.model.user.UserManager; import net.luckperms.api.node.Node; import net.luckperms.api.node.NodeEqualityPredicate; import net.luckperms.api.node.Tristate; -import net.luckperms.api.node.types.MetaNode; -import net.luckperms.api.node.types.PrefixNode; -import net.luckperms.api.node.types.SuffixNode; import net.luckperms.api.query.QueryOptions; import org.checkerframework.checker.nullness.qual.NonNull; @@ -159,232 +156,105 @@ public interface PermissionHolder { */ @NonNull Data transientData(); + /** + * Encapsulates a store of data ({@link Node}s) within a {@link PermissionHolder}. + * + *

The effect of any mutate operation will not persist in storage unless changes are + * explicitly saved. If changes are not saved, the effect will only be observed until the next + * time the holders permission data is (re)loaded. Changes to {@link User}s should be saved + * using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved + * using {@link GroupManager#saveGroup(Group)}.

+ * + *

Before making changes to a user or group, it may be a good idea to load a fresh copy of + * the backing data from the storage if you haven't done so already, to avoid overwriting changes + * made already. This can be done via {@link UserManager#loadUser(UUID)} or + * {@link GroupManager#loadGroup(String)} respectively.

+ */ interface Data { /** - * Gets the backing map containing every permission this holder has. + * Gets a map of the {@link Node}s contained within this instance, + * mapped to their defined {@link Node#getContexts() context}. * - *

This method does not resolve inheritance rules, and returns a - * view of what's 'in the file'.

- * - * @return the holders own nodes + * @return a map of nodes */ - @NonNull Map> getNodes(); + @NonNull Map> toMap(); /** - * Gets a flattened set of {@link Node}s the holder has. + * Gets a flattened set of {@link Node}s contained within this instance. * *

Effectively combines the value collections of the map returned by - * {@link #getNodes()}.

+ * {@link #toMap()}.

* * @return a flattened set of the holders own nodes */ - @NonNull Set getFlattenedNodes(); + @NonNull Set toSet(); /** - * Checks to see if the object has a certain permission. + * Gets if this instance contains a given {@link Node}. + * + *

Returns {@link Tristate#UNDEFINED} if the instance does not contain the node, + * and the {@link Node#getValue() assigned value} of the node as a {@link Tristate} + * if it is present.

* * @param node the node to check for * @param equalityPredicate how to determine if a node matches - * @return a Tristate for the holders permission status for the node + * @return a Tristate relating to the assigned state of the node * @throws NullPointerException if the node is null */ - @NonNull Tristate containsNode(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate); + @NonNull Tristate contains(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate); /** - * Sets a permission node for the permission holder. + * Adds a node. * - *

Although this method is named setPermission, it can be used for all node types.

- * - *

The effect of this mutate operation will not persist in storage unless changes are - * explicitly saved. If changes are not saved, the effect will only be observed until the next - * time the holders permission data is (re)loaded. Changes to {@link User}s should be saved - * using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved - * using {@link GroupManager#saveGroup(Group)}.

- * - *

Before making changes to a user or group, it may be a good idea to load a fresh copy of - * the backing data from the storage if you haven't done so already, to avoid overwriting changes - * made already. This can be done via {@link UserManager#loadUser(UUID)} or - * {@link GroupManager#loadGroup(String)} respectively.

- * - * @param node The node to be set + * @param node the node to be add * @return the result of the operation - * @throws NullPointerException if the node is null */ - @NonNull DataMutateResult addNode(@NonNull Node node); + @NonNull DataMutateResult add(@NonNull Node node); /** - * Sets a permission node for the permission holder. + * Adds a node. * - *

Although this method is named setPermission, it can be used for all node types.

- * - *

The effect of this mutate operation will not persist in storage unless changes are - * explicitly saved. If changes are not saved, the effect will only be observed until the next - * time the holders permission data is (re)loaded. Changes to {@link User}s should be saved - * using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved - * using {@link GroupManager#saveGroup(Group)}.

- * - *

Before making changes to a user or group, it may be a good idea to load a fresh copy of - * the backing data from the storage if you haven't done so already, to avoid overwriting changes - * made already. This can be done via {@link UserManager#loadUser(UUID)} or - * {@link GroupManager#loadGroup(String)} respectively.

- * - * @param node The node to be set - * @param temporaryMergeBehaviour The behaviour used to merge temporary permission entries + * @param node the node to add + * @param temporaryMergeBehaviour the behaviour used to merge temporary permission entries * @return the result of the operation - * @throws NullPointerException if the node is null */ - @NonNull TemporaryDataMutateResult addNode(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour); + @NonNull TemporaryDataMutateResult add(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour); /** - * Unsets a permission for the permission holder. + * Removes a node. * - *

Although this method is named unsetPermission, it can be used for all node types.

- * - *

The effect of this mutate operation will not persist in storage unless changes are - * explicitly saved. If changes are not saved, the effect will only be observed until the next - * time the holders permission data is (re)loaded. Changes to {@link User}s should be saved - * using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved - * using {@link GroupManager#saveGroup(Group)}.

- * - *

Before making changes to a user or group, it may be a good idea to load a fresh copy of - * the backing data from the storage if you haven't done so already, to avoid overwriting changes - * made already. This can be done via {@link UserManager#loadUser(UUID)} or - * {@link GroupManager#loadGroup(String)} respectively.

- * - * @param node The node to be unset + * @param node the node to remove * @return the result of the operation - * @throws NullPointerException if the node is null */ - @NonNull DataMutateResult removeNode(@NonNull Node node); + @NonNull DataMutateResult remove(@NonNull Node node); /** - * Clears any nodes from the holder which pass the predicate. - * - *

This method only targets enduring data.

- * - *

The effect of this mutate operation will not persist in storage unless changes are - * explicitly saved. If changes are not saved, the effect will only be observed until the next - * time the holders permission data is (re)loaded. Changes to {@link User}s should be saved - * using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved - * using {@link GroupManager#saveGroup(Group)}.

- * - *

Before making changes to a user or group, it may be a good idea to load a fresh copy of - * the backing data from the storage if you haven't done so already, to avoid overwriting changes - * made already. This can be done via {@link UserManager#loadUser(UUID)} or - * {@link GroupManager#loadGroup(String)} respectively.

+ * Clears all nodes. + */ + void clear(); + + /** + * Clears any nodes which pass the predicate. * * @param test the predicate to test for nodes which should be removed */ - void clearMatching(@NonNull Predicate test); + void clear(@NonNull Predicate test); /** - * Clears all nodes held by the permission holder. - * - *

The effect of this mutate operation will not persist in storage unless changes are - * explicitly saved. If changes are not saved, the effect will only be observed until the next - * time the holders permission data is (re)loaded. Changes to {@link User}s should be saved - * using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved - * using {@link GroupManager#saveGroup(Group)}.

- * - *

Before making changes to a user or group, it may be a good idea to load a fresh copy of - * the backing data from the storage if you haven't done so already, to avoid overwriting changes - * made already. This can be done via {@link UserManager#loadUser(UUID)} or - * {@link GroupManager#loadGroup(String)} respectively.

- */ - void clearNodes(); - - /** - * Clears all nodes held by the permission holder in a specific context. - * - *

The effect of this mutate operation will not persist in storage unless changes are - * explicitly saved. If changes are not saved, the effect will only be observed until the next - * time the holders permission data is (re)loaded. Changes to {@link User}s should be saved - * using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved - * using {@link GroupManager#saveGroup(Group)}.

- * - *

Before making changes to a user or group, it may be a good idea to load a fresh copy of - * the backing data from the storage if you haven't done so already, to avoid overwriting changes - * made already. This can be done via {@link UserManager#loadUser(UUID)} or - * {@link GroupManager#loadGroup(String)} respectively.

+ * Clears all nodes in a specific context. * * @param contextSet the contexts to filter by */ - void clearNodes(@NonNull ContextSet contextSet); + void clear(@NonNull ContextSet contextSet); /** - * Clears all parent groups. - * - *

The effect of this mutate operation will not persist in storage unless changes are - * explicitly saved. If changes are not saved, the effect will only be observed until the next - * time the holders permission data is (re)loaded. Changes to {@link User}s should be saved - * using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved - * using {@link GroupManager#saveGroup(Group)}.

- * - *

Before making changes to a user or group, it may be a good idea to load a fresh copy of - * the backing data from the storage if you haven't done so already, to avoid overwriting changes - * made already. This can be done via {@link UserManager#loadUser(UUID)} or - * {@link GroupManager#loadGroup(String)} respectively.

- */ - void clearParents(); - - /** - * Clears all parent groups in a specific context. - * - *

The effect of this mutate operation will not persist in storage unless changes are - * explicitly saved. If changes are not saved, the effect will only be observed until the next - * time the holders permission data is (re)loaded. Changes to {@link User}s should be saved - * using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved - * using {@link GroupManager#saveGroup(Group)}.

- * - *

Before making changes to a user or group, it may be a good idea to load a fresh copy of - * the backing data from the storage if you haven't done so already, to avoid overwriting changes - * made already. This can be done via {@link UserManager#loadUser(UUID)} or - * {@link GroupManager#loadGroup(String)} respectively.

+ * Clears all nodes in a specific context which pass the predicate. * * @param contextSet the contexts to filter by + * @param test the predicate to test for nodes which should be removed */ - void clearParents(@NonNull ContextSet contextSet); - - /** - * Clears all meta held by the permission holder. - * - *

Meta nodes in this case, are any nodes which have a {@link MetaNode}, {@link PrefixNode} - * or {@link SuffixNode} type.

- * - *

The effect of this mutate operation will not persist in storage unless changes are - * explicitly saved. If changes are not saved, the effect will only be observed until the next - * time the holders permission data is (re)loaded. Changes to {@link User}s should be saved - * using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved - * using {@link GroupManager#saveGroup(Group)}.

- * - *

Before making changes to a user or group, it may be a good idea to load a fresh copy of - * the backing data from the storage if you haven't done so already, to avoid overwriting changes - * made already. This can be done via {@link UserManager#loadUser(UUID)} or - * {@link GroupManager#loadGroup(String)} respectively.

- */ - void clearMeta(); - - /** - * Clears all meta held by the permission holder in a specific context. - * - *

Meta nodes in this case, are any nodes which have a {@link MetaNode}, {@link PrefixNode} - * or {@link SuffixNode} type.

- * - *

The effect of this mutate operation will not persist in storage unless changes are - * explicitly saved. If changes are not saved, the effect will only be observed until the next - * time the holders permission data is (re)loaded. Changes to {@link User}s should be saved - * using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved - * using {@link GroupManager#saveGroup(Group)}.

- * - *

Before making changes to a user or group, it may be a good idea to load a fresh copy of - * the backing data from the storage if you haven't done so already, to avoid overwriting changes - * made already. This can be done via {@link UserManager#loadUser(UUID)} or - * {@link GroupManager#loadGroup(String)} respectively.

- * - * @param contextSet the contexts to filter by - */ - void clearMeta(@NonNull ContextSet contextSet); + void clear(@NonNull ContextSet contextSet, @NonNull Predicate test); } diff --git a/api/src/main/java/net/luckperms/api/model/TemporaryMergeBehaviour.java b/api/src/main/java/net/luckperms/api/model/TemporaryMergeBehaviour.java index bba8eb7a0..944aba550 100644 --- a/api/src/main/java/net/luckperms/api/model/TemporaryMergeBehaviour.java +++ b/api/src/main/java/net/luckperms/api/model/TemporaryMergeBehaviour.java @@ -31,11 +31,11 @@ import net.luckperms.api.node.Node; * Controls how the implementation should behave when new temporary nodes are set * that would otherwise conflict with existing entries. * - *

The default behaviour of {@link PermissionHolder.Data#addNode(Node)} is + *

The default behaviour of {@link PermissionHolder.Data#add(Node)} is * to return a result of {@link DataMutateResult#ALREADY_HAS} when an equivalent * node is found. This can be replicated using {@link #FAIL_WITH_ALREADY_HAS}.

* - *

However, the {@link PermissionHolder.Data#addNode(Node, TemporaryMergeBehaviour)} + *

However, the {@link PermissionHolder.Data#add(Node, TemporaryMergeBehaviour)} * method allows this behaviour to be customized for temporary permissions.

*/ public enum TemporaryMergeBehaviour { diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LPPermissionAttachment.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LPPermissionAttachment.java index 8d1051b09..30edb3842 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LPPermissionAttachment.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LPPermissionAttachment.java @@ -201,13 +201,13 @@ public class LPPermissionAttachment extends PermissionAttachment { // remove transient permissions from the holder which were added by this attachment & equal the permission User user = this.permissible.getUser(); - user.removeIf(DataType.TRANSIENT, null, n -> n.getMetadata(TRANSIENT_SOURCE_KEY).orElse(null) == this && n.getKey().equals(name), null); + user.removeIf(DataType.TRANSIENT, null, n -> n.getMetadata(TRANSIENT_SOURCE_KEY).orElse(null) == this && n.getKey().equals(name)); } private void clearInternal() { // remove all transient permissions added by this attachment User user = this.permissible.getUser(); - user.removeIf(DataType.TRANSIENT, null, n -> n.getMetadata(TRANSIENT_SOURCE_KEY).orElse(null) == this, null); + user.removeIf(DataType.TRANSIENT, null, n -> n.getMetadata(TRANSIENT_SOURCE_KEY).orElse(null) == this); } @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultChat.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultChat.java index e895ccd87..2292f4dd8 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultChat.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultChat.java @@ -266,7 +266,7 @@ public class LuckPermsVaultChat extends AbstractVaultChat { } // remove all prefixes/suffixes directly set on the user/group - holder.removeIf(DataType.NORMAL, null, node -> type.nodeType().matches(node), null); + holder.removeIf(DataType.NORMAL, null, node -> type.nodeType().matches(node)); if (value == null) { this.vaultPermission.holderSave(holder); @@ -292,7 +292,7 @@ public class LuckPermsVaultChat extends AbstractVaultChat { logMsg("#setMeta: %s - %s - %s - %s", holder.getPlainDisplayName(), key, value, world); } - holder.removeIf(DataType.NORMAL, null, n -> n instanceof MetaNode && ((MetaNode) n).getMetaKey().equals(key), null); + holder.removeIf(DataType.NORMAL, null, n -> n instanceof MetaNode && ((MetaNode) n).getMetaKey().equals(key)); if (value == null) { this.vaultPermission.holderSave(holder); diff --git a/common/build.gradle b/common/build.gradle index a26d25f47..53f880168 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -18,9 +18,9 @@ dependencies { } compile 'com.google.code.gson:gson:2.7' compile 'com.google.guava:guava:19.0' - compile 'com.github.ben-manes.caffeine:caffeine:2.7.0' - compile 'com.squareup.okhttp3:okhttp:3.14.1' - compile 'com.squareup.okio:okio:1.17.3' + compile 'com.github.ben-manes.caffeine:caffeine:2.8.0' + compile 'com.squareup.okhttp3:okhttp:4.2.2' + compile 'com.squareup.okio:okio:2.2.2' compile('me.lucko.configurate:configurate-core:3.5') { exclude(module: 'guava') } @@ -34,8 +34,8 @@ dependencies { compile('me.lucko.configurate:configurate-toml:3.5') { exclude(module: 'toml4j') } - compile 'com.zaxxer:HikariCP:3.3.1' + compile 'com.zaxxer:HikariCP:3.4.1' compile 'redis.clients:jedis:2.10.2' - compile 'org.mongodb:mongo-java-driver:3.10.1' + compile 'org.mongodb:mongo-java-driver:3.11.1' compile 'org.yaml:snakeyaml:1.23' } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java index 54d65fe09..952f717f2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java @@ -36,7 +36,6 @@ import net.luckperms.api.model.TemporaryDataMutateResult; import net.luckperms.api.model.TemporaryMergeBehaviour; import net.luckperms.api.node.Node; import net.luckperms.api.node.NodeEqualityPredicate; -import net.luckperms.api.node.NodeType; import net.luckperms.api.node.Tristate; import net.luckperms.api.query.QueryOptions; @@ -53,13 +52,13 @@ import java.util.function.Predicate; public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHolder { private final PermissionHolder handle; - private final Normal normalData; - private final Transient transientData; + private final DataImpl normalData; + private final DataImpl transientData; ApiPermissionHolder(PermissionHolder handle) { this.handle = Objects.requireNonNull(handle, "handle"); - this.normalData = new Normal(); - this.transientData = new Transient(); + this.normalData = new DataImpl(DataType.NORMAL); + this.transientData = new DataImpl(DataType.TRANSIENT); } PermissionHolder getHandle() { @@ -128,99 +127,62 @@ public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHo this.handle.auditTemporaryNodes(); } - private abstract class AbstractData implements Data { + private class DataImpl implements Data { private final DataType dataType; - private AbstractData(DataType dataType) { + DataImpl(DataType dataType) { this.dataType = dataType; } @Override - public @NonNull Map> getNodes() { + public @NonNull Map> toMap() { return ApiPermissionHolder.this.handle.getData(this.dataType).immutable().asMap(); } @Override - public @NonNull Set getFlattenedNodes() { + public @NonNull Set toSet() { return ApiPermissionHolder.this.handle.getData(this.dataType).asSet(); } @Override - public @NonNull Tristate containsNode(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate) { + public @NonNull Tristate contains(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate) { return ApiPermissionHolder.this.handle.hasNode(this.dataType, node, equalityPredicate); } @Override - public @NonNull DataMutateResult addNode(@NonNull Node node) { + public @NonNull DataMutateResult add(@NonNull Node node) { return ApiPermissionHolder.this.handle.setNode(this.dataType, node, true); } @Override - public @NonNull TemporaryDataMutateResult addNode(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour) { + public @NonNull TemporaryDataMutateResult add(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour) { return ApiPermissionHolder.this.handle.setNode(this.dataType, node, temporaryMergeBehaviour); } @Override - public @NonNull DataMutateResult removeNode(@NonNull Node node) { + public @NonNull DataMutateResult remove(@NonNull Node node) { return ApiPermissionHolder.this.handle.unsetNode(this.dataType, node); } @Override - public void clearMatching(@NonNull Predicate test) { - ApiPermissionHolder.this.handle.removeIf(this.dataType, null, test, null); + public void clear() { + ApiPermissionHolder.this.handle.clearNodes(this.dataType, null, true); } @Override - public void clearNodes() { - ApiPermissionHolder.this.handle.clearNodes(this.dataType, null, false); + public void clear(@NonNull Predicate test) { + ApiPermissionHolder.this.handle.removeIf(this.dataType, null, test, true); + } + + + @Override + public void clear(@NonNull ContextSet contextSet) { + ApiPermissionHolder.this.handle.clearNodes(this.dataType, contextSet, true); } @Override - public void clearNodes(@NonNull ContextSet contextSet) { - ApiPermissionHolder.this.handle.clearNodes(this.dataType, contextSet, false); - } - - @Override - public void clearMeta() { - ApiPermissionHolder.this.handle.removeIf(this.dataType, null, NodeType.META_OR_CHAT_META::matches, null); - } - - @Override - public void clearMeta(@NonNull ContextSet contextSet) { - ApiPermissionHolder.this.handle.removeIf(this.dataType, contextSet, NodeType.META_OR_CHAT_META::matches, null); - } - } - - private final class Normal extends AbstractData implements Data { - private Normal() { - super(DataType.NORMAL); - } - - @Override - public void clearParents() { - ApiPermissionHolder.this.handle.clearNormalParents(null, true); - } - - @Override - public void clearParents(@NonNull ContextSet contextSet) { - ApiPermissionHolder.this.handle.clearNormalParents(contextSet, true); - } - - } - - private final class Transient extends AbstractData implements Data { - private Transient() { - super(DataType.TRANSIENT); - } - - @Override - public void clearParents() { - ApiPermissionHolder.this.handle.removeIf(DataType.TRANSIENT, null, NodeType.INHERITANCE::matches, null); - } - - @Override - public void clearParents(@NonNull ContextSet contextSet) { - ApiPermissionHolder.this.handle.removeIf(DataType.TRANSIENT, contextSet, NodeType.INHERITANCE::matches, null); + public void clear(@NonNull ContextSet contextSet, @NonNull Predicate test) { + ApiPermissionHolder.this.handle.removeIf(this.dataType, contextSet, test, true); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java index ee6dcd8b4..85537315f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java @@ -101,9 +101,9 @@ public class MetaClear extends SharedSubCommand { } if (context.isEmpty()) { - holder.removeIf(DataType.NORMAL, null, type::matches, null); + holder.removeIf(DataType.NORMAL, null, type::matches); } else { - holder.removeIf(DataType.NORMAL, context, type::matches, null); + holder.removeIf(DataType.NORMAL, context, type::matches); } int changed = before - holder.normalData().immutable().size(); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java index 51341b928..609191a76 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java @@ -92,7 +92,7 @@ public class MetaRemoveChatMeta extends SharedSubCommand { holder.removeIf(DataType.NORMAL, null, n -> this.type.nodeType().matches(n) && this.type.nodeType().cast(n).getPriority() == priority && !n.hasExpiry() && - n.getContexts().equals(context), null); + n.getContexts().equals(context)); Message.BULK_REMOVE_CHATMETA_SUCCESS.send(sender, holder.getFormattedDisplayName(), this.type.name().toLowerCase(), priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); LoggedAction.build().source(sender).target(holder) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java index 592bc2c66..a7fb182f6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java @@ -92,7 +92,7 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand { holder.removeIf(DataType.NORMAL, null, n -> this.type.nodeType().matches(n) && this.type.nodeType().cast(n).getPriority() == priority && n.hasExpiry() && - n.getContexts().equals(context), null); + n.getContexts().equals(context)); Message.BULK_REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, holder.getFormattedDisplayName(), this.type.name().toLowerCase(), priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); LoggedAction.build().source(sender).target(holder) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java index 663006e21..b1053b75a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java @@ -86,7 +86,7 @@ public class MetaSet extends SharedSubCommand { return CommandResult.STATE_ERROR; } - holder.removeIf(DataType.NORMAL, context, n -> n instanceof MetaNode && !n.hasExpiry() && ((MetaNode) n).getMetaKey().equalsIgnoreCase(key), null); + holder.removeIf(DataType.NORMAL, context, n -> n instanceof MetaNode && !n.hasExpiry() && ((MetaNode) n).getMetaKey().equalsIgnoreCase(key)); holder.setNode(DataType.NORMAL, node, true); TextComponent.Builder builder = Message.SET_META_SUCCESS.asComponent(plugin.getLocaleManager(), key, value, holder.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder(); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java index 8aaac2781..d79dc718d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java @@ -107,7 +107,7 @@ public class MetaSetChatMeta extends SharedSubCommand { } // remove all other prefixes/suffixes set in these contexts - holder.removeIf(DataType.NORMAL, context, node -> this.type.nodeType().matches(node), null); + holder.removeIf(DataType.NORMAL, context, node -> this.type.nodeType().matches(node)); // determine the priority to set at if (priority == Integer.MIN_VALUE) { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java index 720e3f238..ab7522970 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java @@ -91,7 +91,7 @@ public class MetaSetTemp extends SharedSubCommand { return CommandResult.STATE_ERROR; } - holder.removeIf(DataType.NORMAL, context, n -> n instanceof MetaNode && n.hasExpiry() && ((MetaNode) n).getMetaKey().equalsIgnoreCase(key), null); + holder.removeIf(DataType.NORMAL, context, n -> n instanceof MetaNode && n.hasExpiry() && ((MetaNode) n).getMetaKey().equalsIgnoreCase(key)); duration = holder.setNode(DataType.NORMAL, node, modifier).getMergedNode().getExpiry().getEpochSecond(); TextComponent.Builder builder = Message.SET_META_TEMP_SUCCESS.asComponent(plugin.getLocaleManager(), key, value, holder.getFormattedDisplayName(), DurationFormatter.LONG.formatDateDiff(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder(); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java index e6ff0d15f..bd9c9d52a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java @@ -117,7 +117,7 @@ public class MetaSetTempChatMeta extends SharedSubCommand { } // remove all other prefixes/suffixes set in these contexts - holder.removeIf(DataType.NORMAL, context, node -> this.type.nodeType().matches(node), null); + holder.removeIf(DataType.NORMAL, context, node -> this.type.nodeType().matches(node)); // determine the priority to set at if (priority == Integer.MIN_VALUE) { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java index e2bbc4abb..be8cb8a31 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java @@ -72,7 +72,7 @@ public class MetaUnset extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - if (holder.removeIf(DataType.NORMAL, context, n -> n instanceof MetaNode && !n.hasExpiry() && ((MetaNode) n).getMetaKey().equalsIgnoreCase(key), null)) { + if (holder.removeIf(DataType.NORMAL, context, n -> n instanceof MetaNode && !n.hasExpiry() && ((MetaNode) n).getMetaKey().equalsIgnoreCase(key))) { Message.UNSET_META_SUCCESS.send(sender, key, holder.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); LoggedAction.build().source(sender).target(holder) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java index c884a097a..a37ba6a7d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java @@ -72,7 +72,7 @@ public class MetaUnsetTemp extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - if (holder.removeIf(DataType.NORMAL, context, n -> n instanceof MetaNode && n.hasExpiry() && ((MetaNode) n).getMetaKey().equalsIgnoreCase(key), null)) { + if (holder.removeIf(DataType.NORMAL, context, n -> n instanceof MetaNode && n.hasExpiry() && ((MetaNode) n).getMetaKey().equalsIgnoreCase(key))) { Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); LoggedAction.build().source(sender).target(holder) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java index 05532e42a..c5f221541 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java @@ -45,6 +45,8 @@ import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; import net.luckperms.api.context.MutableContextSet; +import net.luckperms.api.model.DataType; +import net.luckperms.api.node.NodeType; import java.util.List; @@ -70,9 +72,9 @@ public class ParentClear extends SharedSubCommand { } if (context.isEmpty()) { - holder.clearNormalParents(null, true); + holder.removeIf(DataType.NORMAL, null, NodeType.INHERITANCE::matches, true); } else { - holder.clearNormalParents(context, true); + holder.removeIf(DataType.NORMAL, context, NodeType.INHERITANCE::matches, true); } int changed = before - holder.normalData().immutable().size(); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java index 908b026ea..437646c5e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java @@ -94,9 +94,9 @@ public class ParentClearTrack extends SharedSubCommand { } if (context.isEmpty()) { - holder.removeIf(DataType.NORMAL, null, NodeType.INHERITANCE.predicate(n -> track.containsGroup(n.getGroupName())), null); + holder.removeIf(DataType.NORMAL, null, NodeType.INHERITANCE.predicate(n -> track.containsGroup(n.getGroupName()))); } else { - holder.removeIf(DataType.NORMAL, null, NodeType.INHERITANCE.predicate(n -> n.getContexts().equals(context) && track.containsGroup(n.getGroupName())), null); + holder.removeIf(DataType.NORMAL, null, NodeType.INHERITANCE.predicate(n -> n.getContexts().equals(context) && track.containsGroup(n.getGroupName()))); } if (holder.getType() == HolderType.USER) { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java index bcfe40912..02443784f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java @@ -50,6 +50,7 @@ import me.lucko.luckperms.common.util.Predicates; import net.luckperms.api.context.MutableContextSet; import net.luckperms.api.model.DataType; +import net.luckperms.api.node.NodeType; import java.util.List; @@ -81,7 +82,7 @@ public class ParentSet extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - holder.clearNormalParents(context, false); + holder.removeIf(DataType.NORMAL, context, NodeType.INHERITANCE::matches, false); holder.setNode(DataType.NORMAL, Inheritance.builder(group.getName()).withContext(context).build(), true); if (holder.getType() == HolderType.USER) { ((User) holder).getPrimaryGroup().setStoredValue(group.getName()); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java index b8b0dc398..2b417b00b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java @@ -114,7 +114,7 @@ public class ParentSetTrack extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - holder.removeIf(DataType.NORMAL, null, NodeType.INHERITANCE.predicate(n -> n.getContexts().equals(context) && track.containsGroup(n.getGroupName())), null); + holder.removeIf(DataType.NORMAL, null, NodeType.INHERITANCE.predicate(n -> n.getContexts().equals(context) && track.containsGroup(n.getGroupName()))); holder.setNode(DataType.NORMAL, Inheritance.builder(group.getName()).withContext(context).build(), true); Message.SET_TRACK_PARENT_SUCCESS.send(sender, holder.getFormattedDisplayName(), track.getName(), group.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java index 8459ea68d..c719c37e5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java @@ -73,9 +73,9 @@ public class PermissionClear extends SharedSubCommand { } if (context.isEmpty()) { - holder.removeIf(DataType.NORMAL, null, node -> node instanceof PermissionNode, null); + holder.removeIf(DataType.NORMAL, null, node -> node instanceof PermissionNode); } else { - holder.removeIf(DataType.NORMAL, context, node -> node instanceof PermissionNode, null); + holder.removeIf(DataType.NORMAL, context, node -> node instanceof PermissionNode); } int changed = before - holder.normalData().immutable().size(); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java index 7450f3359..3a1fc9939 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java @@ -90,7 +90,7 @@ public class GroupSetDisplayName extends SubCommand { return CommandResult.STATE_ERROR; } - group.removeIf(DataType.NORMAL, context, n -> n instanceof DisplayNameNode, null); + group.removeIf(DataType.NORMAL, context, n -> n instanceof DisplayNameNode); if (name.equals(group.getName())) { Message.GROUP_SET_DISPLAY_NAME_REMOVED.send(sender, group.getName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java index c20ae5e46..3078bcac9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java @@ -43,7 +43,7 @@ import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; import net.luckperms.api.model.DataType; -import net.luckperms.api.node.types.WeightNode; +import net.luckperms.api.node.NodeType; import java.util.List; @@ -61,7 +61,7 @@ public class GroupSetWeight extends SubCommand { int weight = ArgumentParser.parsePriority(0, args); - group.removeIf(DataType.NORMAL, null, n -> n instanceof WeightNode, null); + group.removeIf(DataType.NORMAL, null, NodeType.WEIGHT::matches); group.setNode(DataType.NORMAL, Weight.builder(weight).build(), true); Message.GROUP_SET_WEIGHT.send(sender, weight, group.getFormattedDisplayName()); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java index 518b65924..c6ea49f1b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java @@ -79,7 +79,7 @@ public class LogNotify extends SubCommand { user.setNode(DataType.NORMAL, NodeBuilders.determineMostApplicable(IGNORE_NODE).build(), true); } else { // remove the perm - user.removeIf(DataType.NORMAL, ImmutableContextSetImpl.EMPTY, n -> n.getKey().equalsIgnoreCase(IGNORE_NODE), null); + user.removeIf(DataType.NORMAL, ImmutableContextSetImpl.EMPTY, n -> n.getKey().equalsIgnoreCase(IGNORE_NODE)); } plugin.getStorage().saveUser(user).join(); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationUtils.java b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationUtils.java index 51ec2a78b..eb13c05d2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationUtils.java @@ -57,7 +57,7 @@ public final class MigrationUtils { } public static void setGroupWeight(Group group, int weight) { - group.removeIf(DataType.NORMAL, null, NodeType.WEIGHT::matches, null); + group.removeIf(DataType.NORMAL, null, NodeType.WEIGHT::matches); group.setNode(DataType.NORMAL, Weight.builder(weight).build(), true); } diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java index a2b1090c6..adfe8cb14 100644 --- a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java +++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java @@ -46,20 +46,20 @@ public enum Dependency { ASM( "org.ow2.asm", "asm", - "6.2.1", - "FGDbbDPMmchOXLMORrAX5NHMmn+8F0EB1vhIKbtkwIU=" + "7.1", + "SrL6K20sycyx6qBeoynEB7R7E+0pFfYvjEuMyWJY1N4=" ), ASM_COMMONS( "org.ow2.asm", "asm-commons", - "6.2.1", - "P1eNMe8w+UttH0SBL0H+T5inzUKvNTNfXUhmqzuQGGU=" + "7.1", + "5VkEidjxmE2Fv+q9Oxc3TFnCiuCdSOxKDrvQGVns01g=" ), JAR_RELOCATOR( "me.lucko", "jar-relocator", - "1.3", - "mmz3ltQbS8xXGA2scM0ZH6raISlt4nukjCiU2l9Jxfs=" + "1.4", + "1RsiF3BiVztjlfTA+svDCuoDSGFuSpTZYHvUK8yBx8I=" ), TEXT( @@ -114,22 +114,22 @@ public enum Dependency { CAFFEINE( "com{}github{}ben-manes{}caffeine", "caffeine", - "2.7.0", - "Fw8phtcHwN+UIo9X1SV7fxH4hv1CtTthMWp0mKx+B/8=", + "2.8.0", + "sRB6QJe+RRWpI6Vbxj2gTkEeaWSqBFvs4bx6y4SHLtc=", Relocation.of("caffeine", "com{}github{}benmanes{}caffeine") ), OKIO( "com{}squareup{}" + RelocationHelper.OKIO_STRING, RelocationHelper.OKIO_STRING, - "1.17.3", - "yxja86IIrjirnYJUP/uT4fGF6GPIoOUsw3L/46WPVUk=", + "2.2.2", + "5YyXQGprsROIk3UCmaxjxqoEs4trSerhv8rRpj75uhs=", Relocation.of(RelocationHelper.OKIO_STRING, RelocationHelper.OKIO_STRING) ), OKHTTP( "com{}squareup{}" + RelocationHelper.OKHTTP3_STRING, "okhttp", - "3.14.1", - "WmvmkWUwdqpk3NNh0uRF5AYLS13IgrH2uknnnd/D5WM=", + "4.2.2", + "UGQYLP9AsQDOV/vzzpheEuOM9EM3JOgbF1wYQ+rsu3U=", Relocation.of(RelocationHelper.OKHTTP3_STRING, RelocationHelper.OKHTTP3_STRING), Relocation.of(RelocationHelper.OKIO_STRING, RelocationHelper.OKIO_STRING) ), @@ -143,15 +143,15 @@ public enum Dependency { MARIADB_DRIVER( "org{}mariadb{}jdbc", "mariadb-java-client", - "2.4.0", - "G346tblA35aJS8q1a3dQVZdU7Q7isGMzhwftoz6MZqU=", + "2.5.1", + "/AxG0o0JnIme7hnDTO2WEUxgF1yXPiWPhMKermXAzZE=", Relocation.of("mariadb", "org{}mariadb{}jdbc") ), MYSQL_DRIVER( "mysql", "mysql-connector-java", - "5.1.47", - "5PhASPOSsrN7r0ao1QjkuN2uKG0gnvmVueEYhSAcGSM=", + "5.1.48", + "VuJsqqOCH1rkr0T5x09mz4uE6gFRatOAPLsOkEm27Kg=", Relocation.of("mysql", "com{}mysql") ), POSTGRESQL_DRIVER( @@ -164,43 +164,43 @@ public enum Dependency { H2_DRIVER( "com.h2database", "h2", - "1.4.198", - "Mt1rFJy3IqpMLdTUCnSpzUHjKsWaTnVaZuV1NmDWHUY=" + "1.4.200", + "OtmsS2qunNnTrBxEdGXh7QYBm4UbiT3WqNdt222FvKY=" // we don't apply relocations to h2 - it gets loaded via // an isolated classloader ), SQLITE_DRIVER( "org.xerial", "sqlite-jdbc", - "3.25.2", - "pF2mGr7WFWilM/3s4SUJMYCCjt6w1Lb21XLgz0V0ZfY=" + "3.28.0", + "k3hOVtv1RiXgbJks+D9w6cG93Vxq0dPwEwjIex2WG2A=" // we don't apply relocations to sqlite - it gets loaded via // an isolated classloader ), HIKARI( "com{}zaxxer", "HikariCP", - "3.3.1", - "SIaA1yzGHOZNpZNoIt903f5ScJrIB3u8CT2cNkaLcy0=", + "3.4.1", + "uCbLTp8iz699ZJS3TxSAf4j9UfrikmgxvTHT0+N/Bck=", Relocation.of("hikari", "com{}zaxxer{}hikari") ), SLF4J_SIMPLE( "org.slf4j", "slf4j-simple", - "1.7.25", - "CWbob/+lvlLT2ee4ndZ02YoD7tCkVPuvfBvZSTvZ2HQ=" + "1.7.28", + "YO863GwYR8RuGr16gGIlWqPizh2ywI37H9Q/GkYgdzY=" ), SLF4J_API( "org.slf4j", "slf4j-api", - "1.7.25", - "GMSgCV1cHaa4F1kudnuyPSndL1YK1033X/OWHb3iW3k=" + "1.7.28", + "+25PZ6KkaJ4+cTWE2xel0QkMHr5u7DDp4DSabuEYFB4=" ), MONGODB_DRIVER( "org.mongodb", "mongo-java-driver", - "3.10.1", - "IGjdjTH4VjqnqGUdVe8u+dKfzKkpCG1NR11TE8ieCdU=", + "3.11.1", + "tIWEOrQegZK3TT7mNV4ZnjkpW4ViwPiFEpD6yYPyFmE=", Relocation.of("mongodb", "com{}mongodb"), Relocation.of("bson", "org{}bson") ), @@ -216,8 +216,8 @@ public enum Dependency { COMMONS_POOL_2( "org.apache.commons", "commons-pool2", - "2.6.1", - "4tb0CE+KGA3mbHcAND/orToKqE8ssFYe20F/4f1BqhU=", + "2.7.0", + "a1TGdcc4fhV9KMcJiHPy53LCI8ejW8mxNxc2fJdToeQ=", Relocation.of("commonspool2", "org{}apache{}commons{}pool2") ), CONFIGURATE_CORE( diff --git a/common/src/main/java/me/lucko/luckperms/common/extension/SimpleExtensionManager.java b/common/src/main/java/me/lucko/luckperms/common/extension/SimpleExtensionManager.java index 1c509b27b..bfcf18a89 100644 --- a/common/src/main/java/me/lucko/luckperms/common/extension/SimpleExtensionManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/extension/SimpleExtensionManager.java @@ -42,8 +42,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.net.URL; -import java.net.URLClassLoader; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.NoSuchFileException; @@ -51,6 +49,8 @@ import java.nio.file.Path; import java.util.Collection; import java.util.HashSet; import java.util.Set; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -67,13 +67,11 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable { for (LoadedExtension extension : this.extensions) { try { extension.instance.unload(); - if (extension.classLoader != null) { - extension.classLoader.close(); - } } catch (Exception e) { e.printStackTrace(); } } + this.extensions.clear(); } @Override @@ -82,7 +80,7 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable { return; } this.plugin.getLogger().info("Loading extension: " + extension.getClass().getName()); - this.extensions.add(new LoadedExtension(extension, null, null)); + this.extensions.add(new LoadedExtension(extension, null)); extension.load(); this.plugin.getEventFactory().handleExtensionLoad(extension); } @@ -117,16 +115,20 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable { throw new NoSuchFileException("No file at " + path); } - URLClassLoader classLoader = new URLClassLoader(new URL[]{path.toUri().toURL()}, getClass().getClassLoader()); String className; - - try (InputStream in = classLoader.getResourceAsStream("extension.json")) { - if (in == null) { + try (JarFile jar = new JarFile(path.toFile())) { + JarEntry extensionJarEntry = jar.getJarEntry("extension.json"); + if (extensionJarEntry == null) { throw new IllegalStateException("extension.json not present"); } - try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) { - JsonElement parsed = GsonProvider.parser().parse(reader); - className = parsed.getAsJsonObject().get("class").getAsString(); + try (InputStream in = jar.getInputStream(extensionJarEntry)) { + if (in == null) { + throw new IllegalStateException("extension.json not present"); + } + try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) { + JsonElement parsed = GsonProvider.parser().parse(reader); + className = parsed.getAsJsonObject().get("class").getAsString(); + } } } @@ -134,9 +136,11 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable { throw new IllegalArgumentException("class is null"); } + this.plugin.getBootstrap().getPluginClassLoader().loadJar(path); + Class extensionClass; try { - extensionClass = classLoader.loadClass(className).asSubclass(Extension.class); + extensionClass = Class.forName(className).asSubclass(Extension.class); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } @@ -165,7 +169,7 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable { } } - this.extensions.add(new LoadedExtension(extension, classLoader, path)); + this.extensions.add(new LoadedExtension(extension, path)); extension.load(); this.plugin.getEventFactory().handleExtensionLoad(extension); return extension; @@ -178,12 +182,10 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable { private static final class LoadedExtension { private final Extension instance; - private final URLClassLoader classLoader; private final Path path; - private LoadedExtension(Extension instance, URLClassLoader classLoader, Path path) { + private LoadedExtension(Extension instance, Path path) { this.instance = instance; - this.classLoader = classLoader; this.path = path; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java index c6c3c204b..8be3b53b5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java @@ -478,7 +478,11 @@ public abstract class PermissionHolder { return DataMutateResult.SUCCESS; } - public boolean removeIf(DataType dataType, @Nullable ContextSet contextSet, Predicate predicate, @Nullable Runnable taskIfSuccess) { + public boolean removeIf(DataType dataType, @Nullable ContextSet contextSet, Predicate predicate) { + return removeIf(dataType, contextSet, predicate, false); + } + + public boolean removeIf(DataType dataType, @Nullable ContextSet contextSet, Predicate predicate, boolean giveDefault) { NodeMap data = getData(dataType); ImmutableCollection before = data.immutable().values(); @@ -492,8 +496,8 @@ public abstract class PermissionHolder { } } - if (taskIfSuccess != null) { - taskIfSuccess.run(); + if (getType() == HolderType.USER && giveDefault) { + getPlugin().getUserManager().giveDefaultIfNeeded((User) this, false); } invalidateCache(); @@ -530,14 +534,6 @@ public abstract class PermissionHolder { return true; } - public boolean clearNormalParents(ContextSet contextSet, boolean giveDefault) { - return removeIf(DataType.NORMAL, contextSet, n -> n instanceof InheritanceNode, () -> { - if (this.getType() == HolderType.USER && giveDefault) { - this.plugin.getUserManager().giveDefaultIfNeeded((User) this, false); - } - }); - } - public OptionalInt getWeight() { return OptionalInt.empty(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/web/BytebinClient.java b/common/src/main/java/me/lucko/luckperms/common/web/BytebinClient.java index e95327048..acf52514b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/web/BytebinClient.java +++ b/common/src/main/java/me/lucko/luckperms/common/web/BytebinClient.java @@ -79,7 +79,7 @@ public class BytebinClient extends AbstractHttpClient { * @throws IOException if an error occurs */ public Content postContent(byte[] buf, MediaType contentType, boolean allowModification) throws IOException { - RequestBody body = RequestBody.create(contentType, buf); + RequestBody body = RequestBody.create(buf, contentType); Request.Builder requestBuilder = new Request.Builder() .url(this.url + "post") @@ -122,7 +122,7 @@ public class BytebinClient extends AbstractHttpClient { throw new IllegalArgumentException("Existing content is not modifiable"); } - RequestBody body = RequestBody.create(contentType, buf); + RequestBody body = RequestBody.create(buf, contentType); Request.Builder requestBuilder = new Request.Builder() .url(this.url + existingContent.key()) diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LPPermissionAttachment.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LPPermissionAttachment.java index 1e5af83fe..eb8e0bb90 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LPPermissionAttachment.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LPPermissionAttachment.java @@ -202,13 +202,13 @@ public class LPPermissionAttachment extends PermissionAttachment { // remove transient permissions from the holder which were added by this attachment & equal the permission User user = this.permissible.getUser(); - user.removeIf(DataType.TRANSIENT, null, n -> n.getMetadata(TRANSIENT_SOURCE_KEY).orElse(null) == this && n.getKey().equals(name), null); + user.removeIf(DataType.TRANSIENT, null, n -> n.getMetadata(TRANSIENT_SOURCE_KEY).orElse(null) == this && n.getKey().equals(name)); } private void clearInternal() { // remove all transient permissions added by this attachment User user = this.permissible.getUser(); - user.removeIf(DataType.TRANSIENT, null, n -> n.getMetadata(TRANSIENT_SOURCE_KEY).orElse(null) == this, null); + user.removeIf(DataType.TRANSIENT, null, n -> n.getMetadata(TRANSIENT_SOURCE_KEY).orElse(null) == this); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/permissionholder/PermissionHolderSubjectData.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/permissionholder/PermissionHolderSubjectData.java index 0740ab4dc..ac0c9ef95 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/permissionholder/PermissionHolderSubjectData.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/permissionholder/PermissionHolderSubjectData.java @@ -65,6 +65,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.concurrent.CompletableFuture; +import java.util.function.Predicate; import java.util.stream.Stream; public class PermissionHolderSubjectData implements LPSubjectData { @@ -144,28 +145,20 @@ public class PermissionHolderSubjectData implements LPSubjectData { @Override public CompletableFuture clearPermissions() { - if (!this.holder.clearNodes(this.type, null, false)) { + if (!this.holder.clearNodes(this.type, null, true)) { return CompletableFuture.completedFuture(false); } - if (this.holder.getType() == HolderType.USER) { - this.service.getPlugin().getUserManager().giveDefaultIfNeeded(((User) this.holder), false); - } - return save(this.holder).thenApply(v -> true); } @Override public CompletableFuture clearPermissions(ImmutableContextSet contexts) { Objects.requireNonNull(contexts, "contexts"); - if (!this.holder.clearNodes(this.type, contexts, false)) { + if (!this.holder.clearNodes(this.type, contexts, true)) { return CompletableFuture.completedFuture(false); } - if (this.holder.getType() == HolderType.USER) { - this.service.getPlugin().getUserManager().giveDefaultIfNeeded(((User) this.holder), false); - } - return save(this.holder).thenApply(v -> true); } @@ -233,22 +226,7 @@ public class PermissionHolderSubjectData implements LPSubjectData { @Override public CompletableFuture clearParents() { - boolean ret; - switch (this.type) { - case NORMAL: - ret = this.holder.clearNormalParents(null, true); - break; - case TRANSIENT: - ret = streamNodes() - .filter(n -> n instanceof InheritanceNode) - .peek(n -> this.holder.unsetNode(DataType.TRANSIENT, n)) - .findAny().isPresent(); - break; - default: - throw new AssertionError(); - } - - if (!ret) { + if (!this.holder.removeIf(this.type, null, NodeType.INHERITANCE::matches, true)) { return CompletableFuture.completedFuture(false); } @@ -258,23 +236,8 @@ public class PermissionHolderSubjectData implements LPSubjectData { @Override public CompletableFuture clearParents(ImmutableContextSet contexts) { Objects.requireNonNull(contexts, "contexts"); - boolean ret; - switch (this.type) { - case NORMAL: - ret = this.holder.clearNormalParents(contexts, true); - break; - case TRANSIENT: - ret = streamNodes() - .filter(n -> n instanceof InheritanceNode) - .filter(n -> n.getContexts().equals(contexts)) - .peek(n -> this.holder.unsetNode(DataType.TRANSIENT, n)) - .findAny().isPresent(); - break; - default: - throw new AssertionError(); - } - if (!ret) { + if (!this.holder.removeIf(this.type, contexts, NodeType.INHERITANCE::matches, true)) { return CompletableFuture.completedFuture(false); } @@ -343,10 +306,7 @@ public class PermissionHolderSubjectData implements LPSubjectData { ChatMetaType type = ChatMetaType.valueOf(key.toUpperCase()); // remove all prefixes/suffixes from the user - streamNodes() - .filter(n -> type.nodeType().matches(n)) - .filter(n -> n.getContexts().equals(contexts)) - .forEach(n -> this.holder.unsetNode(this.type, n)); + this.holder.removeIf(this.type, contexts, type.nodeType()::matches, false); MetaAccumulator metaAccumulator = this.holder.accumulateMeta(null, QueryOptions.defaultContextualOptions().toBuilder().context(contexts).build()); metaAccumulator.complete(); @@ -357,11 +317,7 @@ public class PermissionHolderSubjectData implements LPSubjectData { node = builder.withContext(contexts).build(); } else { // standard remove - streamNodes() - .filter(n -> n instanceof MetaNode && ((MetaNode) n).getMetaKey().equals(key)) - .filter(n -> n.getContexts().equals(contexts)) - .forEach(n -> this.holder.unsetNode(this.type, n)); - + this.holder.removeIf(this.type, contexts, NodeType.META.predicate(n -> n.getMetaKey().equals(key)), false); node = Meta.builder(key, value).withContext(contexts).build(); } @@ -374,18 +330,18 @@ public class PermissionHolderSubjectData implements LPSubjectData { Objects.requireNonNull(contexts, "contexts"); Objects.requireNonNull(key, "key"); - streamNodes() - .filter(n -> { - if (key.equalsIgnoreCase(Prefix.NODE_KEY)) { - return n instanceof PrefixNode; - } else if (key.equalsIgnoreCase(Suffix.NODE_KEY)) { - return n instanceof SuffixNode; - } else { - return n instanceof MetaNode && ((MetaNode) n).getMetaKey().equals(key); - } - }) - .filter(n -> n.getContexts().equals(contexts)) - .forEach(n -> this.holder.unsetNode(this.type, n)); + Predicate test; + if (key.equalsIgnoreCase(Prefix.NODE_KEY)) { + test = NodeType.PREFIX::matches; + } else if (key.equalsIgnoreCase(Suffix.NODE_KEY)) { + test = NodeType.SUFFIX::matches; + } else { + test = NodeType.META.predicate(mn -> mn.getMetaKey().equals(key)); + } + + if (!this.holder.removeIf(this.type, contexts, test, false)) { + return CompletableFuture.completedFuture(false); + } return save(this.holder).thenApply(v -> true); } @@ -394,13 +350,7 @@ public class PermissionHolderSubjectData implements LPSubjectData { public CompletableFuture clearOptions(ImmutableContextSet contexts) { Objects.requireNonNull(contexts, "contexts"); - boolean success = streamNodes() - .filter(NodeType.META_OR_CHAT_META::matches) - .filter(n -> n.getContexts().equals(contexts)) - .peek(n -> this.holder.unsetNode(this.type, n)) - .findAny().isPresent(); - - if (!success) { + if (!this.holder.removeIf(this.type, contexts, NodeType.META_OR_CHAT_META::matches, false)) { return CompletableFuture.completedFuture(false); } @@ -409,12 +359,7 @@ public class PermissionHolderSubjectData implements LPSubjectData { @Override public CompletableFuture clearOptions() { - boolean success = streamNodes() - .filter(NodeType.META_OR_CHAT_META::matches) - .peek(n -> this.holder.unsetNode(this.type, n)) - .findAny().isPresent(); - - if (!success) { + if (!this.holder.removeIf(this.type, null, NodeType.META_OR_CHAT_META::matches, false)) { return CompletableFuture.completedFuture(false); }