Refactor extended node types, general cleanup
This commit is contained in:
parent
b9acb84119
commit
4547b52748
@ -28,6 +28,13 @@ package me.lucko.luckperms.api;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
|
import me.lucko.luckperms.api.nodetype.NodeType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.NodeTypeKey;
|
||||||
|
import me.lucko.luckperms.api.nodetype.types.InheritanceType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.types.MetaType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.types.PrefixType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.types.SuffixType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.types.WeightType;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -64,7 +71,7 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
* <p></p>
|
* <p></p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link #getPermission() permission} - the actual permission string</li>
|
* <li>{@link #getPermission() permission} - the actual permission string</li>
|
||||||
* <li>{@link #getValuePrimitive() value} - the value of the node (false for negated)</li>
|
* <li>{@link #getValue() value} - the value of the node (false for negated)</li>
|
||||||
* <li>{@link #isOverride() override} - if the node is marked as having special priority over other nodes</li>
|
* <li>{@link #isOverride() override} - if the node is marked as having special priority over other nodes</li>
|
||||||
* <li>{@link #getServer() server} - the specific server where this node should apply</li>
|
* <li>{@link #getServer() server} - the specific server where this node should apply</li>
|
||||||
* <li>{@link #getWorld() world} - the specific world where this node should apply</li>
|
* <li>{@link #getWorld() world} - the specific world where this node should apply</li>
|
||||||
@ -72,14 +79,22 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
* <li>{@link #getExpiry() expiry} - the time when this node should expire</li>
|
* <li>{@link #getExpiry() expiry} - the time when this node should expire</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <p>Nodes can also fall into the following sub categories.</p>
|
* <p>The 'permission' property of a {@link Node} is also used in some cases to represent state
|
||||||
|
* beyond a granted permission. This state is encapsulated by extra {@link NodeType} data which
|
||||||
|
* can be obtained from this instance using {@link #getTypeData(NodeTypeKey)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Type data is mapped by {@link NodeTypeKey}s, which are usually stored as static members of the
|
||||||
|
* corresponding {@link NodeType} class under the <code>KEY</code> field.</p>
|
||||||
|
*
|
||||||
|
* <p>The current types are:</p>
|
||||||
* <p></p>
|
* <p></p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>normal - just a regular permission</li>
|
* <li>normal - just a regular permission</li>
|
||||||
* <li>{@link #isGroupNode() group node} - a "group node" marks that the holder should inherit data from another group</li>
|
* <li>{@link InheritanceType} - an "inheritance node" marks that the holder should inherit data from another group</li>
|
||||||
* <li>{@link #isPrefix() prefix} - represents an assigned prefix</li>
|
* <li>{@link PrefixType} - represents an assigned prefix</li>
|
||||||
* <li>{@link #isSuffix() suffix} - represents an assigned suffix</li>
|
* <li>{@link SuffixType} - represents an assigned suffix</li>
|
||||||
* <li>{@link #isMeta() meta} - represents an assigned meta option</li>
|
* <li>{@link MetaType} - represents an assigned meta option</li>
|
||||||
|
* <li>{@link WeightType} - marks the weight of the object holding this node</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <p>The core node state must be immutable in all implementations.</p>
|
* <p>The core node state must be immutable in all implementations.</p>
|
||||||
@ -108,19 +123,7 @@ public interface Node {
|
|||||||
*
|
*
|
||||||
* @return the nodes value
|
* @return the nodes value
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
boolean getValue();
|
||||||
default Boolean getValue() {
|
|
||||||
return getValuePrimitive();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value of the node.
|
|
||||||
*
|
|
||||||
* <p>A negated setting would result in a value of <code>false</code>.</p>
|
|
||||||
*
|
|
||||||
* @return the nodes value
|
|
||||||
*/
|
|
||||||
boolean getValuePrimitive();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of this node as a {@link Tristate}.
|
* Gets the value of this node as a {@link Tristate}.
|
||||||
@ -129,18 +132,18 @@ public interface Node {
|
|||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
default Tristate getTristate() {
|
default Tristate getTristate() {
|
||||||
return Tristate.fromBoolean(getValuePrimitive());
|
return Tristate.fromBoolean(getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if the node is negated.
|
* Gets if the node is negated.
|
||||||
*
|
*
|
||||||
* <p>This is the inverse of the {@link #getValuePrimitive() value}.</p>
|
* <p>This is the inverse of the {@link #getValue() value}.</p>
|
||||||
*
|
*
|
||||||
* @return true if the node is negated
|
* @return true if the node is negated
|
||||||
*/
|
*/
|
||||||
default boolean isNegated() {
|
default boolean isNegated() {
|
||||||
return !getValuePrimitive();
|
return !getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -209,7 +212,8 @@ public interface Node {
|
|||||||
boolean shouldApplyWithContext(@Nonnull ContextSet contextSet);
|
boolean shouldApplyWithContext(@Nonnull ContextSet contextSet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves any shorthand parts of this node and returns the full list.
|
* Resolves any shorthand parts of this node and returns the full list of
|
||||||
|
* resolved nodes.
|
||||||
*
|
*
|
||||||
* <p>The list will not contain the exact permission itself.</p>
|
* <p>The list will not contain the exact permission itself.</p>
|
||||||
*
|
*
|
||||||
@ -219,7 +223,7 @@ public interface Node {
|
|||||||
List<String> resolveShorthand();
|
List<String> resolveShorthand();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this node is temporary (will automatically expire).
|
* Gets if this node is assigned temporarily.
|
||||||
*
|
*
|
||||||
* @return true if this node will expire in the future
|
* @return true if this node will expire in the future
|
||||||
*/
|
*/
|
||||||
@ -291,30 +295,6 @@ public interface Node {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
ContextSet getFullContexts();
|
ContextSet getFullContexts();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if the node is a "standard" permission node.
|
|
||||||
*
|
|
||||||
* @return true if this is a regular permission node
|
|
||||||
* @since 4.2
|
|
||||||
*/
|
|
||||||
boolean isRegularPermissionNode();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if this is a group node.
|
|
||||||
*
|
|
||||||
* @return true if this is a group node
|
|
||||||
*/
|
|
||||||
boolean isGroupNode();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the name of the group, if this is a group node.
|
|
||||||
*
|
|
||||||
* @return the name of the group
|
|
||||||
* @throws IllegalStateException if this is not a group node. See {@link #isGroupNode()}
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
String getGroupName() throws IllegalStateException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this node is a wildcard permission.
|
* Gets if this node is a wildcard permission.
|
||||||
*
|
*
|
||||||
@ -325,58 +305,135 @@ public interface Node {
|
|||||||
/**
|
/**
|
||||||
* Gets the level of this wildcard.
|
* Gets the level of this wildcard.
|
||||||
*
|
*
|
||||||
|
* <p>The node <code>luckperms.*</code> has a wildcard level of 1.</p>
|
||||||
|
* <p>The node <code>luckperms.user.permission.*</code> has a wildcard level of 3.</p>
|
||||||
|
*
|
||||||
|
* <p>Nodes with a higher wildcard level are more specific and have priority over
|
||||||
|
* less specific nodes (nodes with a lower wildcard level).</p>
|
||||||
|
*
|
||||||
* @return the wildcard level
|
* @return the wildcard level
|
||||||
* @throws IllegalStateException if this is not a wildcard
|
* @throws IllegalStateException if this is not a wildcard
|
||||||
*/
|
*/
|
||||||
int getWildcardLevel() throws IllegalStateException;
|
int getWildcardLevel() throws IllegalStateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this node is a meta node.
|
* Gets if this node has any extra {@link NodeType} data attached to it.
|
||||||
*
|
*
|
||||||
* @return true if this node is a meta node
|
* @return if this node has any type data
|
||||||
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
boolean isMeta();
|
boolean hasTypeData();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the meta value from this node.
|
* Gets the type data corresponding to the given <code>key</code>, if present.
|
||||||
*
|
*
|
||||||
* @return the meta value
|
* @param key the key
|
||||||
* @throws IllegalStateException if this node is not a meta node
|
* @param <T> the {@link NodeType} type
|
||||||
|
* @return the data, if present
|
||||||
|
* @since 4.2
|
||||||
|
*/
|
||||||
|
<T extends NodeType> Optional<T> getTypeData(NodeTypeKey<T> key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type data corresponding to the given <code>key</code>, throwing an exception
|
||||||
|
* if no data is present.
|
||||||
|
*
|
||||||
|
* @param key the key
|
||||||
|
* @param <T> the {@link NodeType} type
|
||||||
|
* @return the data
|
||||||
|
* @throws IllegalStateException if data isn't present
|
||||||
|
* @since 4.2
|
||||||
|
*/
|
||||||
|
default <T extends NodeType> T typeData(NodeTypeKey<T> key) throws IllegalStateException {
|
||||||
|
return getTypeData(key)
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new IllegalStateException("Node '" + getPermission() + "' does not have the '" + key.getTypeName() + "' type.")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets if this node has {@link InheritanceType} type data.
|
||||||
|
*
|
||||||
|
* @return true if this is a inheritance (group) node.
|
||||||
|
*/
|
||||||
|
default boolean isGroupNode() {
|
||||||
|
return getTypeData(InheritanceType.KEY).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the inherited group if this node has {@link InheritanceType} type data,
|
||||||
|
* throwing an exception if the data is not present.
|
||||||
|
*
|
||||||
|
* @return the name of the group
|
||||||
|
* @throws IllegalStateException if this node doesn't have {@link InheritanceType} data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
Map.Entry<String, String> getMeta() throws IllegalStateException;
|
default String getGroupName() throws IllegalStateException {
|
||||||
|
return typeData(InheritanceType.KEY).getGroupName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this node is a prefix node.
|
* Gets if this node has {@link MetaType} type data.
|
||||||
|
*
|
||||||
|
* @return true if this is a meta node.
|
||||||
|
*/
|
||||||
|
default boolean isMeta() {
|
||||||
|
return getTypeData(MetaType.KEY).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the meta entry if this node has {@link MetaType} type data,
|
||||||
|
* throwing an exception if the data is not present.
|
||||||
|
*
|
||||||
|
* @return the meta entry
|
||||||
|
* @throws IllegalStateException if this node doesn't have {@link MetaType} data
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
default Map.Entry<String, String> getMeta() throws IllegalStateException {
|
||||||
|
return typeData(MetaType.KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets if this node has {@link PrefixType} type data.
|
||||||
*
|
*
|
||||||
* @return true if this node is a prefix node
|
* @return true if this node is a prefix node
|
||||||
*/
|
*/
|
||||||
boolean isPrefix();
|
default boolean isPrefix() {
|
||||||
|
return getTypeData(PrefixType.KEY).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the prefix value from this node.
|
* Gets the prefix entry if this node has {@link PrefixType} type data,
|
||||||
|
* throwing an exception if the data is not present.
|
||||||
*
|
*
|
||||||
* @return the prefix value
|
* @return the meta entry
|
||||||
* @throws IllegalStateException if this node is a not a prefix node
|
* @throws IllegalStateException if this node doesn't have {@link PrefixType} data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
Map.Entry<Integer, String> getPrefix() throws IllegalStateException;
|
default Map.Entry<Integer, String> getPrefix() throws IllegalStateException {
|
||||||
|
return typeData(PrefixType.KEY).getAsEntry();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this node is a suffix node.
|
* Gets if this node has {@link SuffixType} type data.
|
||||||
*
|
*
|
||||||
* @return true if this node is a suffix node
|
* @return true if this node is a suffix node
|
||||||
*/
|
*/
|
||||||
boolean isSuffix();
|
default boolean isSuffix() {
|
||||||
|
return getTypeData(SuffixType.KEY).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the suffix value from this node.
|
* Gets the suffix entry if this node has {@link SuffixType} type data,
|
||||||
|
* throwing an exception if the data is not present.
|
||||||
*
|
*
|
||||||
* @return the suffix value
|
* @return the meta entry
|
||||||
* @throws IllegalStateException if this node is a not a suffix node
|
* @throws IllegalStateException if this node doesn't have {@link SuffixType} data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
Map.Entry<Integer, String> getSuffix() throws IllegalStateException;
|
default Map.Entry<Integer, String> getSuffix() throws IllegalStateException {
|
||||||
|
return typeData(SuffixType.KEY).getAsEntry();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this Node is equal to another node.
|
* Gets if this Node is equal to another node.
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* 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.api.nodetype;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Node;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Superinterface for extended {@link Node} types.
|
||||||
|
*
|
||||||
|
* <p>The 'permission' property of a {@link Node} is also used in some cases to represent state
|
||||||
|
* beyond a granted permission. This state is encapsulated by extra {@link NodeType} data which
|
||||||
|
* can be obtained from this instance using {@link Node#getTypeData(NodeTypeKey)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Type data is mapped by {@link NodeTypeKey}s, which are usually stored as static members of the
|
||||||
|
* corresponding {@link NodeType} class under the <code>KEY</code> field.</p>
|
||||||
|
*
|
||||||
|
* @since 4.2
|
||||||
|
*/
|
||||||
|
public interface NodeType {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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.api.nodetype;
|
||||||
|
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks an instance used as a key for a {@link NodeType}.
|
||||||
|
*
|
||||||
|
* <p>A single instance of this interface is created and stored statically for
|
||||||
|
* each sub-interface of {@link NodeType}.</p>
|
||||||
|
*
|
||||||
|
* @param <N> the type of the {@link NodeType} being indexed by this key
|
||||||
|
* @since 4.2
|
||||||
|
*/
|
||||||
|
public interface NodeTypeKey<N extends NodeType> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Class#getSimpleName() class name} of the represented type.
|
||||||
|
*
|
||||||
|
* @return the name of the represented type
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
default String getTypeName() {
|
||||||
|
ParameterizedType thisType = (ParameterizedType) getClass().getGenericSuperclass();
|
||||||
|
Type nodeType = thisType.getActualTypeArguments()[0];
|
||||||
|
return ((Class) nodeType).getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.api.nodetype.types;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Node;
|
||||||
|
import me.lucko.luckperms.api.nodetype.NodeType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.NodeTypeKey;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A sub-type of {@link Node} used to mark that the holder of the node should inherit
|
||||||
|
* from another group.
|
||||||
|
*
|
||||||
|
* @since 4.2
|
||||||
|
*/
|
||||||
|
public interface InheritanceType extends NodeType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key for this type.
|
||||||
|
*/
|
||||||
|
NodeTypeKey<InheritanceType> KEY = new NodeTypeKey<InheritanceType>(){};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the group to be inherited.
|
||||||
|
*
|
||||||
|
* <p>This is no guarantee that this group exists.</p>
|
||||||
|
*
|
||||||
|
* @return the name of the group
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
String getGroupName();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* 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.api.nodetype.types;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Node;
|
||||||
|
import me.lucko.luckperms.api.nodetype.NodeType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.NodeTypeKey;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A sub-type of {@link Node} used to store meta assignments.
|
||||||
|
*
|
||||||
|
* @since 4.2
|
||||||
|
*/
|
||||||
|
public interface MetaType extends NodeType, Map.Entry<String, String> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key for this type.
|
||||||
|
*/
|
||||||
|
NodeTypeKey<MetaType> KEY = new NodeTypeKey<MetaType>(){};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the meta key.
|
||||||
|
*
|
||||||
|
* @return the meta key
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
String getKey();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the meta value.
|
||||||
|
*
|
||||||
|
* @return the meta value
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
String getValue();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default String setValue(String value) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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.api.nodetype.types;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Node;
|
||||||
|
import me.lucko.luckperms.api.nodetype.NodeType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.NodeTypeKey;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A sub-type of {@link Node} used to store prefix assignments.
|
||||||
|
*
|
||||||
|
* @since 4.2
|
||||||
|
*/
|
||||||
|
public interface PrefixType extends NodeType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key for this type.
|
||||||
|
*/
|
||||||
|
NodeTypeKey<PrefixType> KEY = new NodeTypeKey<PrefixType>(){};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the priority of the prefix assignment.
|
||||||
|
*
|
||||||
|
* @return the priority
|
||||||
|
*/
|
||||||
|
int getPriority();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the actual prefix string.
|
||||||
|
*
|
||||||
|
* @return the prefix
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
String getPrefix();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a representation of this instance as a {@link Map.Entry}.
|
||||||
|
*
|
||||||
|
* @return a map entry representation of the priority and prefix string
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
Map.Entry<Integer, String> getAsEntry();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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.api.nodetype.types;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Node;
|
||||||
|
import me.lucko.luckperms.api.nodetype.NodeType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.NodeTypeKey;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A sub-type of {@link Node} used to store suffix assignments.
|
||||||
|
*
|
||||||
|
* @since 4.2
|
||||||
|
*/
|
||||||
|
public interface SuffixType extends NodeType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key for this type.
|
||||||
|
*/
|
||||||
|
NodeTypeKey<SuffixType> KEY = new NodeTypeKey<SuffixType>(){};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the priority of the suffix assignment.
|
||||||
|
*
|
||||||
|
* @return the priority
|
||||||
|
*/
|
||||||
|
int getPriority();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the actual suffix string.
|
||||||
|
*
|
||||||
|
* @return the suffix
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
String getSuffix();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a representation of this instance as a {@link Map.Entry}.
|
||||||
|
*
|
||||||
|
* @return a map entry representation of the priority and suffix string
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
Map.Entry<Integer, String> getAsEntry();
|
||||||
|
|
||||||
|
}
|
@ -23,34 +23,29 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.references;
|
package me.lucko.luckperms.api.nodetype.types;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.api.nodetype.NodeType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.NodeTypeKey;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reference to a specific {@link PermissionHolder}.
|
* A sub-type of {@link Node} used to mark the weight of the node's holder.
|
||||||
*
|
*
|
||||||
* @param <S> the holder type
|
* @since 4.2
|
||||||
* @param <I> the holder identifier type
|
|
||||||
*/
|
*/
|
||||||
public interface HolderReference<S, I> extends Identifiable<I> {
|
public interface WeightType extends NodeType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the holder type
|
* The key for this type.
|
||||||
*
|
|
||||||
* @return the holder type
|
|
||||||
*/
|
*/
|
||||||
HolderType getType();
|
NodeTypeKey<WeightType> KEY = new NodeTypeKey<WeightType>(){};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies an action to this reference, if it is present and exists.
|
* Gets the weight value.
|
||||||
*
|
*
|
||||||
* @param plugin the plugin
|
* @return the weight
|
||||||
* @param consumer the action
|
|
||||||
*/
|
*/
|
||||||
void apply(LuckPermsPlugin plugin, Consumer<S> consumer);
|
int getWeight();
|
||||||
|
|
||||||
}
|
}
|
@ -36,11 +36,11 @@ import me.lucko.luckperms.common.calculators.AbstractCalculatorFactory;
|
|||||||
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.processors.MapProcessor;
|
import me.lucko.luckperms.common.processors.MapProcessor;
|
||||||
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
||||||
import me.lucko.luckperms.common.processors.RegexProcessor;
|
import me.lucko.luckperms.common.processors.RegexProcessor;
|
||||||
import me.lucko.luckperms.common.processors.WildcardProcessor;
|
import me.lucko.luckperms.common.processors.WildcardProcessor;
|
||||||
import me.lucko.luckperms.common.references.HolderType;
|
|
||||||
|
|
||||||
public class BukkitCalculatorFactory extends AbstractCalculatorFactory {
|
public class BukkitCalculatorFactory extends AbstractCalculatorFactory {
|
||||||
private final LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
|
@ -42,7 +42,8 @@ import me.lucko.luckperms.common.logging.ProgressLogger;
|
|||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.utils.Iterators;
|
||||||
@ -212,7 +213,7 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meta.getKey().equalsIgnoreCase(NodeFactory.PREFIX_KEY) || meta.getKey().equalsIgnoreCase(NodeFactory.SUFFIX_KEY)) {
|
if (meta.getKey().equalsIgnoreCase(NodeTypes.PREFIX_KEY) || meta.getKey().equalsIgnoreCase(NodeTypes.SUFFIX_KEY)) {
|
||||||
ChatMetaType type = ChatMetaType.valueOf(meta.getKey().toUpperCase());
|
ChatMetaType type = ChatMetaType.valueOf(meta.getKey().toUpperCase());
|
||||||
holder.setPermission(NodeFactory.buildChatMetaNode(type, c.getPriority(), meta.getValue()).setWorld(world.getName()).build());
|
holder.setPermission(NodeFactory.buildChatMetaNode(type, c.getPriority(), meta.getValue()).setWorld(world.getName()).build());
|
||||||
continue;
|
continue;
|
||||||
|
@ -37,9 +37,10 @@ import me.lucko.luckperms.common.locale.command.CommandSpec;
|
|||||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.model.UserIdentifier;
|
||||||
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.UserIdentifier;
|
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.utils.Iterators;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
@ -149,7 +150,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
|||||||
if (key.isEmpty() || value.isEmpty()) continue;
|
if (key.isEmpty() || value.isEmpty()) continue;
|
||||||
if (key.equals("build")) continue;
|
if (key.equals("build")) continue;
|
||||||
|
|
||||||
if (key.equals(NodeFactory.PREFIX_KEY) || key.equals(NodeFactory.SUFFIX_KEY)) {
|
if (key.equals(NodeTypes.PREFIX_KEY) || key.equals(NodeTypes.SUFFIX_KEY)) {
|
||||||
ChatMetaType type = ChatMetaType.valueOf(key.toUpperCase());
|
ChatMetaType type = ChatMetaType.valueOf(key.toUpperCase());
|
||||||
groups.get(groupName).add(NodeFactory.buildChatMetaNode(type, 50, value).setWorld(worldMappingFunc.apply(world)).build());
|
groups.get(groupName).add(NodeFactory.buildChatMetaNode(type, 50, value).setWorld(worldMappingFunc.apply(world)).build());
|
||||||
} else {
|
} else {
|
||||||
@ -201,7 +202,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
|||||||
if (key.isEmpty() || value.isEmpty()) continue;
|
if (key.isEmpty() || value.isEmpty()) continue;
|
||||||
if (key.equals("build")) continue;
|
if (key.equals("build")) continue;
|
||||||
|
|
||||||
if (key.equals(NodeFactory.PREFIX_KEY) || key.equals(NodeFactory.SUFFIX_KEY)) {
|
if (key.equals(NodeTypes.PREFIX_KEY) || key.equals(NodeTypes.SUFFIX_KEY)) {
|
||||||
ChatMetaType type = ChatMetaType.valueOf(key.toUpperCase());
|
ChatMetaType type = ChatMetaType.valueOf(key.toUpperCase());
|
||||||
users.get(id).add(NodeFactory.buildChatMetaNode(type, 100, value).setWorld(worldMappingFunc.apply(world)).build());
|
users.get(id).add(NodeFactory.buildChatMetaNode(type, 100, value).setWorld(worldMappingFunc.apply(world)).build());
|
||||||
} else {
|
} else {
|
||||||
|
@ -38,7 +38,7 @@ import me.lucko.luckperms.common.logging.ProgressLogger;
|
|||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.utils.Iterators;
|
||||||
|
@ -39,7 +39,8 @@ import me.lucko.luckperms.common.model.Group;
|
|||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.utils.Iterators;
|
||||||
@ -288,9 +289,9 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String key = opt.getKey().toLowerCase();
|
String key = opt.getKey().toLowerCase();
|
||||||
boolean ignore = key.equals(NodeFactory.PREFIX_KEY) ||
|
boolean ignore = key.equals(NodeTypes.PREFIX_KEY) ||
|
||||||
key.equals(NodeFactory.SUFFIX_KEY) ||
|
key.equals(NodeTypes.SUFFIX_KEY) ||
|
||||||
key.equals(NodeFactory.WEIGHT_KEY) ||
|
key.equals(NodeTypes.WEIGHT_KEY) ||
|
||||||
key.equals("rank") ||
|
key.equals("rank") ||
|
||||||
key.equals("rank-ladder") ||
|
key.equals("rank-ladder") ||
|
||||||
key.equals("name") ||
|
key.equals("name") ||
|
||||||
|
@ -44,7 +44,7 @@ import me.lucko.luckperms.common.locale.command.CommandSpec;
|
|||||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.storage.StorageType;
|
import me.lucko.luckperms.common.storage.StorageType;
|
||||||
|
@ -39,7 +39,8 @@ import me.lucko.luckperms.common.model.Group;
|
|||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.utils.Iterators;
|
||||||
@ -218,7 +219,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
|||||||
String valueString = value.toString();
|
String valueString = value.toString();
|
||||||
if (valueString.isEmpty()) continue;
|
if (valueString.isEmpty()) continue;
|
||||||
|
|
||||||
if (key.equals(NodeFactory.PREFIX_KEY) || key.equals(NodeFactory.SUFFIX_KEY)) {
|
if (key.equals(NodeTypes.PREFIX_KEY) || key.equals(NodeTypes.SUFFIX_KEY)) {
|
||||||
ChatMetaType type = ChatMetaType.valueOf(key.toUpperCase());
|
ChatMetaType type = ChatMetaType.valueOf(key.toUpperCase());
|
||||||
holder.setPermission(NodeFactory.buildChatMetaNode(type, weight, valueString).build());
|
holder.setPermission(NodeFactory.buildChatMetaNode(type, weight, valueString).build());
|
||||||
} else {
|
} else {
|
||||||
|
@ -31,8 +31,8 @@ import me.lucko.luckperms.api.Node;
|
|||||||
import me.lucko.luckperms.bukkit.model.dummy.DummyPlugin;
|
import me.lucko.luckperms.bukkit.model.dummy.DummyPlugin;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.ImmutableTransientNode;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.model.ImmutableTransientNode;
|
||||||
|
|
||||||
import org.bukkit.permissions.PermissionAttachment;
|
import org.bukkit.permissions.PermissionAttachment;
|
||||||
import org.bukkit.permissions.PermissionRemovedExecutor;
|
import org.bukkit.permissions.PermissionRemovedExecutor;
|
||||||
|
@ -39,7 +39,8 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
|||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
|
|
||||||
import net.milkbowl.vault.chat.Chat;
|
import net.milkbowl.vault.chat.Chat;
|
||||||
|
|
||||||
@ -318,7 +319,7 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Node.Builder metaNode;
|
Node.Builder metaNode;
|
||||||
if (key.equalsIgnoreCase(NodeFactory.PREFIX_KEY) || key.equalsIgnoreCase(NodeFactory.SUFFIX_KEY)) {
|
if (key.equalsIgnoreCase(NodeTypes.PREFIX_KEY) || key.equalsIgnoreCase(NodeTypes.SUFFIX_KEY)) {
|
||||||
metaNode = NodeFactory.buildChatMetaNode(ChatMetaType.valueOf(key.toUpperCase()), 100, value.toString());
|
metaNode = NodeFactory.buildChatMetaNode(ChatMetaType.valueOf(key.toUpperCase()), 100, value.toString());
|
||||||
} else {
|
} else {
|
||||||
metaNode = NodeFactory.buildMetaNode(key, value.toString());
|
metaNode = NodeFactory.buildMetaNode(key, value.toString());
|
||||||
|
@ -39,7 +39,7 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
|||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
||||||
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
@ -210,7 +210,7 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
|
|
||||||
ContextSet contexts = contextForLookup(user, world).getContexts();
|
ContextSet contexts = contextForLookup(user, world).getContexts();
|
||||||
|
|
||||||
String[] ret = user.getEnduringNodes().values().stream()
|
String[] ret = user.enduringData().immutable().values().stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.filter(n -> n.shouldApplyWithContext(contexts))
|
.filter(n -> n.shouldApplyWithContext(contexts))
|
||||||
.map(n -> {
|
.map(n -> {
|
||||||
|
@ -34,7 +34,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.utils.Iterators;
|
||||||
|
@ -31,7 +31,7 @@ import me.lucko.luckperms.common.api.ApiUtils;
|
|||||||
import me.lucko.luckperms.common.api.delegates.model.ApiGroup;
|
import me.lucko.luckperms.common.api.delegates.model.ApiGroup;
|
||||||
import me.lucko.luckperms.common.managers.group.GroupManager;
|
import me.lucko.luckperms.common.managers.group.GroupManager;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ import me.lucko.luckperms.common.api.ApiUtils;
|
|||||||
import me.lucko.luckperms.common.api.delegates.model.ApiUser;
|
import me.lucko.luckperms.common.api.delegates.model.ApiUser;
|
||||||
import me.lucko.luckperms.common.managers.user.UserManager;
|
import me.lucko.luckperms.common.managers.user.UserManager;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
|
import me.lucko.luckperms.common.model.UserIdentifier;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.UserIdentifier;
|
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.api.ChatMetaType;
|
|||||||
import me.lucko.luckperms.api.Group;
|
import me.lucko.luckperms.api.Group;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.api.delegates.model.ApiGroup;
|
import me.lucko.luckperms.common.api.delegates.model.ApiGroup;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import me.lucko.luckperms.api.DataMutateResult;
|
|||||||
import me.lucko.luckperms.api.LocalizedNode;
|
import me.lucko.luckperms.api.LocalizedNode;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.api.NodeEqualityPredicate;
|
import me.lucko.luckperms.api.NodeEqualityPredicate;
|
||||||
|
import me.lucko.luckperms.api.StandardNodeEquality;
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.api.caching.CachedData;
|
import me.lucko.luckperms.api.caching.CachedData;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
@ -44,14 +45,18 @@ import me.lucko.luckperms.common.model.Group;
|
|||||||
import me.lucko.luckperms.common.model.NodeMapType;
|
import me.lucko.luckperms.common.model.NodeMapType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
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.comparator.NodeWithContextComparator;
|
||||||
|
import me.lucko.luckperms.common.node.utils.MetaType;
|
||||||
|
import me.lucko.luckperms.common.node.utils.NodeTools;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@ -99,13 +104,13 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ImmutableSetMultimap<ImmutableContextSet, Node> getNodes() {
|
public ImmutableSetMultimap<ImmutableContextSet, Node> getNodes() {
|
||||||
return this.handle.getEnduringNodes();
|
return this.handle.enduringData().immutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ImmutableSetMultimap<ImmutableContextSet, Node> getTransientNodes() {
|
public ImmutableSetMultimap<ImmutableContextSet, Node> getTransientNodes() {
|
||||||
return this.handle.getTransientNodes();
|
return this.handle.transientData().immutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -123,33 +128,55 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<Node> getEnduringPermissions() {
|
public Set<Node> getEnduringPermissions() {
|
||||||
return ImmutableSet.copyOf(this.handle.getEnduringNodes().values());
|
return ImmutableSet.copyOf(this.handle.enduringData().immutable().values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<Node> getTransientPermissions() {
|
public Set<Node> getTransientPermissions() {
|
||||||
return ImmutableSet.copyOf(this.handle.getTransientNodes().values());
|
return ImmutableSet.copyOf(this.handle.transientData().immutable().values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public SortedSet<LocalizedNode> getAllNodes(@Nonnull Contexts contexts) {
|
public SortedSet<LocalizedNode> getAllNodes(@Nonnull Contexts contexts) {
|
||||||
Objects.requireNonNull(contexts, "contexts");
|
Objects.requireNonNull(contexts, "contexts");
|
||||||
return ImmutableSortedSet.copyOfSorted(this.handle.resolveInheritancesAlmostEqual(contexts));
|
|
||||||
|
List<LocalizedNode> nodes = new LinkedList<>();
|
||||||
|
this.handle.accumulateInheritancesTo(nodes, contexts);
|
||||||
|
NodeTools.removeEqual(nodes.iterator(), StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
||||||
|
|
||||||
|
SortedSet<LocalizedNode> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
||||||
|
ret.addAll(nodes);
|
||||||
|
|
||||||
|
return ImmutableSortedSet.copyOfSorted(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public SortedSet<LocalizedNode> getAllNodes() {
|
public SortedSet<LocalizedNode> getAllNodes() {
|
||||||
return ImmutableSortedSet.copyOfSorted(this.handle.resolveInheritancesAlmostEqual());
|
List<LocalizedNode> nodes = new LinkedList<>();
|
||||||
|
this.handle.accumulateInheritancesTo(nodes);
|
||||||
|
NodeTools.removeEqual(nodes.iterator(), StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
||||||
|
|
||||||
|
SortedSet<LocalizedNode> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
||||||
|
ret.addAll(nodes);
|
||||||
|
|
||||||
|
return ImmutableSortedSet.copyOfSorted(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<LocalizedNode> getAllNodesFiltered(@Nonnull Contexts contexts) {
|
public Set<LocalizedNode> getAllNodesFiltered(@Nonnull Contexts contexts) {
|
||||||
Objects.requireNonNull(contexts, "contexts");
|
Objects.requireNonNull(contexts, "contexts");
|
||||||
return ImmutableSet.copyOf(this.handle.getAllNodes(contexts));
|
|
||||||
|
List<LocalizedNode> entries = this.handle.getAllEntries(contexts);
|
||||||
|
|
||||||
|
NodeTools.removeSamePermission(entries.iterator());
|
||||||
|
SortedSet<LocalizedNode> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
||||||
|
ret.addAll(entries);
|
||||||
|
|
||||||
|
return ImmutableSet.copyOf(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -187,21 +214,21 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
|||||||
@Override
|
@Override
|
||||||
public Tristate hasPermission(@Nonnull Node node) {
|
public Tristate hasPermission(@Nonnull Node node) {
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return this.handle.hasPermission(NodeMapType.ENDURING, node);
|
return this.handle.hasPermission(NodeMapType.ENDURING, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Tristate hasTransientPermission(@Nonnull Node node) {
|
public Tristate hasTransientPermission(@Nonnull Node node) {
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return this.handle.hasPermission(NodeMapType.TRANSIENT, node);
|
return this.handle.hasPermission(NodeMapType.TRANSIENT, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Tristate inheritsPermission(@Nonnull Node node) {
|
public Tristate inheritsPermission(@Nonnull Node node) {
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return this.handle.inheritsPermission(node);
|
return this.handle.inheritsPermission(node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,7 +33,7 @@ import me.lucko.luckperms.api.Track;
|
|||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.storage.Storage;
|
import me.lucko.luckperms.common.storage.Storage;
|
||||||
|
|
||||||
|
@ -28,9 +28,11 @@ package me.lucko.luckperms.common.api.delegates.model;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.DataMutateResult;
|
import me.lucko.luckperms.api.DataMutateResult;
|
||||||
|
import me.lucko.luckperms.api.StandardNodeEquality;
|
||||||
import me.lucko.luckperms.api.caching.UserData;
|
import me.lucko.luckperms.api.caching.UserData;
|
||||||
|
import me.lucko.luckperms.common.model.NodeMapType;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -80,7 +82,7 @@ public final class ApiUser extends ApiPermissionHolder implements me.lucko.luckp
|
|||||||
return DataMutateResult.ALREADY_HAS;
|
return DataMutateResult.ALREADY_HAS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.handle.hasPermission(NodeFactory.buildGroupNode(group.toLowerCase()).build()).asBoolean()) {
|
if (!this.handle.hasPermission(NodeMapType.ENDURING, NodeFactory.buildGroupNode(group.toLowerCase()).build(), StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean()) {
|
||||||
return DataMutateResult.FAIL;
|
return DataMutateResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,9 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.api.StandardNodeEquality;
|
import me.lucko.luckperms.api.StandardNodeEquality;
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
|
import me.lucko.luckperms.common.model.NodeMapType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.LegacyNodeFactory;
|
import me.lucko.luckperms.common.node.factory.LegacyNodeFactory;
|
||||||
import me.lucko.luckperms.common.utils.Scripting;
|
import me.lucko.luckperms.common.utils.Scripting;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -61,7 +62,7 @@ public class AssignmentExpression {
|
|||||||
throw new NullPointerException("script engine");
|
throw new NullPointerException("script engine");
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate<Node> checker = node -> holder.hasPermission(node, StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY) == tristate;
|
Predicate<Node> checker = node -> holder.hasPermission(NodeMapType.ENDURING, node, StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY) == tristate;
|
||||||
|
|
||||||
String exp = this.expression.stream().map(t -> t.forExpression(checker)).collect(Collectors.joining())
|
String exp = this.expression.stream().map(t -> t.forExpression(checker)).collect(Collectors.joining())
|
||||||
.replace("&", "&&").replace("|", "||");
|
.replace("&", "&&").replace("|", "||");
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.assignments;
|
|||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.LegacyNodeFactory;
|
import me.lucko.luckperms.common.node.factory.LegacyNodeFactory;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -29,11 +29,11 @@ import me.lucko.luckperms.api.Node;
|
|||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.HolderType;
|
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.storage.Storage;
|
import me.lucko.luckperms.common.storage.Storage;
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public class Exporter implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
write(writer, "# Export group: " + group.getName());
|
write(writer, "# Export group: " + group.getName());
|
||||||
for (Node node : group.getEnduringNodes().values()) {
|
for (Node node : group.enduringData().immutable().values()) {
|
||||||
write(writer, "/lp " + NodeFactory.nodeAsCommand(node, group.getName(), HolderType.GROUP, true));
|
write(writer, "/lp " + NodeFactory.nodeAsCommand(node, group.getName(), HolderType.GROUP, true));
|
||||||
}
|
}
|
||||||
write(writer, "");
|
write(writer, "");
|
||||||
@ -217,7 +217,7 @@ public class Exporter implements Runnable {
|
|||||||
output.add("# Export user: " + user.getUuid().toString() + " - " + user.getName().orElse("unknown username"));
|
output.add("# Export user: " + user.getUuid().toString() + " - " + user.getName().orElse("unknown username"));
|
||||||
|
|
||||||
boolean inDefault = false;
|
boolean inDefault = false;
|
||||||
for (Node node : user.getEnduringNodes().values()) {
|
for (Node node : user.enduringData().immutable().values()) {
|
||||||
if (node.isGroupNode() && node.getGroupName().equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME)) {
|
if (node.isGroupNode() && node.getGroupName().equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME)) {
|
||||||
inDefault = true;
|
inDefault = true;
|
||||||
continue;
|
continue;
|
||||||
@ -242,7 +242,7 @@ public class Exporter implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// all of the threads have been scheduled now and are running. we just need to wait for them all to complete
|
// all of the threads have been scheduled now and are running. we just need to wait for them all to complete
|
||||||
CompletableFuture<Void> overallFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()]));
|
CompletableFuture<Void> overallFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
|
@ -142,7 +142,7 @@ public class Importer implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// all of the threads have been scheduled now and are running. we just need to wait for them all to complete
|
// all of the threads have been scheduled now and are running. we just need to wait for them all to complete
|
||||||
CompletableFuture<Void> overallFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()]));
|
CompletableFuture<Void> overallFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||||
|
|
||||||
this.notify.forEach(s -> Message.IMPORT_INFO.send(s, "All commands have been processed and scheduled - now waiting for the execution to complete."));
|
this.notify.forEach(s -> Message.IMPORT_INFO.send(s, "All commands have been processed and scheduled - now waiting for the execution to complete."));
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.bulkupdate;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.bulkupdate.action.Action;
|
import me.lucko.luckperms.common.bulkupdate.action.Action;
|
||||||
import me.lucko.luckperms.common.bulkupdate.constraint.Constraint;
|
import me.lucko.luckperms.common.bulkupdate.constraint.Constraint;
|
||||||
import me.lucko.luckperms.common.node.NodeModel;
|
import me.lucko.luckperms.common.node.model.NodeDataContainer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -59,7 +59,7 @@ public final class BulkUpdate {
|
|||||||
* @param node the node to check
|
* @param node the node to check
|
||||||
* @return true if satisfied
|
* @return true if satisfied
|
||||||
*/
|
*/
|
||||||
public boolean satisfiesConstraints(NodeModel node) {
|
public boolean satisfiesConstraints(NodeDataContainer node) {
|
||||||
for (Constraint constraint : this.constraints) {
|
for (Constraint constraint : this.constraints) {
|
||||||
if (!constraint.isSatisfiedBy(node)) {
|
if (!constraint.isSatisfiedBy(node)) {
|
||||||
return false;
|
return false;
|
||||||
@ -74,7 +74,7 @@ public final class BulkUpdate {
|
|||||||
* @param from the node to base changes from
|
* @param from the node to base changes from
|
||||||
* @return the new nodemodel instance, or null if the node should be deleted.
|
* @return the new nodemodel instance, or null if the node should be deleted.
|
||||||
*/
|
*/
|
||||||
public NodeModel apply(NodeModel from) {
|
public NodeDataContainer apply(NodeDataContainer from) {
|
||||||
if (!satisfiesConstraints(from)) {
|
if (!satisfiesConstraints(from)) {
|
||||||
return from; // make no change
|
return from; // make no change
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.bulkupdate.action;
|
package me.lucko.luckperms.common.bulkupdate.action;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.node.NodeModel;
|
import me.lucko.luckperms.common.node.model.NodeDataContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an action to be applied to a given node.
|
* Represents an action to be applied to a given node.
|
||||||
@ -45,7 +45,7 @@ public interface Action {
|
|||||||
* @param from the node to base changes from
|
* @param from the node to base changes from
|
||||||
* @return the new nodemodel instance, or null if the node should be deleted.
|
* @return the new nodemodel instance, or null if the node should be deleted.
|
||||||
*/
|
*/
|
||||||
NodeModel apply(NodeModel from);
|
NodeDataContainer apply(NodeDataContainer from);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this action in SQL form.
|
* Gets this action in SQL form.
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.bulkupdate.action;
|
package me.lucko.luckperms.common.bulkupdate.action;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.node.NodeModel;
|
import me.lucko.luckperms.common.node.model.NodeDataContainer;
|
||||||
|
|
||||||
public class DeleteAction implements Action {
|
public class DeleteAction implements Action {
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class DeleteAction implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeModel apply(NodeModel from) {
|
public NodeDataContainer apply(NodeDataContainer from) {
|
||||||
return null; // this action just deletes nodes, so return null
|
return null; // this action just deletes nodes, so return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.bulkupdate.action;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.bulkupdate.BulkUpdate;
|
import me.lucko.luckperms.common.bulkupdate.BulkUpdate;
|
||||||
import me.lucko.luckperms.common.bulkupdate.constraint.QueryField;
|
import me.lucko.luckperms.common.bulkupdate.constraint.QueryField;
|
||||||
import me.lucko.luckperms.common.node.NodeModel;
|
import me.lucko.luckperms.common.node.model.NodeDataContainer;
|
||||||
|
|
||||||
public class UpdateAction implements Action {
|
public class UpdateAction implements Action {
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ public class UpdateAction implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeModel apply(NodeModel from) {
|
public NodeDataContainer apply(NodeDataContainer from) {
|
||||||
switch (this.field) {
|
switch (this.field) {
|
||||||
case PERMISSION:
|
case PERMISSION:
|
||||||
return from.setPermission(this.value);
|
return from.setPermission(this.value);
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.bulkupdate.constraint;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.bulkupdate.BulkUpdate;
|
import me.lucko.luckperms.common.bulkupdate.BulkUpdate;
|
||||||
import me.lucko.luckperms.common.bulkupdate.comparisons.Comparison;
|
import me.lucko.luckperms.common.bulkupdate.comparisons.Comparison;
|
||||||
import me.lucko.luckperms.common.node.NodeModel;
|
import me.lucko.luckperms.common.node.model.NodeDataContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a query constraint
|
* Represents a query constraint
|
||||||
@ -59,7 +59,7 @@ public class Constraint {
|
|||||||
* @param node the node
|
* @param node the node
|
||||||
* @return true if satisfied
|
* @return true if satisfied
|
||||||
*/
|
*/
|
||||||
public boolean isSatisfiedBy(NodeModel node) {
|
public boolean isSatisfiedBy(NodeDataContainer node) {
|
||||||
switch (this.field) {
|
switch (this.field) {
|
||||||
case PERMISSION:
|
case PERMISSION:
|
||||||
return this.comparison.matches(node.getPermission(), this.value);
|
return this.comparison.matches(node.getPermission(), this.value);
|
||||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.api.Contexts;
|
|||||||
import me.lucko.luckperms.api.caching.GroupData;
|
import me.lucko.luckperms.api.caching.GroupData;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.references.HolderType;
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds an easily accessible cache of a groups's data in a number of contexts
|
* Holds an easily accessible cache of a groups's data in a number of contexts
|
||||||
|
@ -28,8 +28,8 @@ package me.lucko.luckperms.common.caching;
|
|||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.caching.UserData;
|
import me.lucko.luckperms.api.caching.UserData;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.references.HolderType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds an easily accessible cache of a user's data in a number of contexts
|
* Holds an easily accessible cache of a user's data in a number of contexts
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.caching.handlers;
|
|
||||||
|
|
||||||
import com.google.common.collect.HashMultimap;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.common.references.HolderReference;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manages the cached state of all permission holders
|
|
||||||
*/
|
|
||||||
public class CachedStateManager {
|
|
||||||
|
|
||||||
// Group --> Groups/Users that inherit from that group. (reverse relationship)
|
|
||||||
private final Multimap<HolderReference, HolderReference> map = HashMultimap.create();
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a set of holder names that inherit permissions (either directly or via other groups)
|
|
||||||
* from the given holder name
|
|
||||||
*
|
|
||||||
* @param holder the holder name to query for
|
|
||||||
* @return a set of inherited groups
|
|
||||||
*/
|
|
||||||
public Set<HolderReference> getInheritances(HolderReference holder) {
|
|
||||||
Set<HolderReference> set = new HashSet<>();
|
|
||||||
set.add(holder);
|
|
||||||
|
|
||||||
this.lock.lock();
|
|
||||||
try {
|
|
||||||
while (true) {
|
|
||||||
Set<HolderReference> clone = new HashSet<>(set);
|
|
||||||
|
|
||||||
boolean work = false;
|
|
||||||
|
|
||||||
for (HolderReference s : clone) {
|
|
||||||
if (set.addAll(this.map.get(s))) {
|
|
||||||
work = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!work) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
this.lock.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
set.remove(holder);
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a holder and the groups they inherit from within this map.
|
|
||||||
*
|
|
||||||
* @param holder the holder to add
|
|
||||||
* @param inheritedGroups a list of groups the holder inherits from
|
|
||||||
*/
|
|
||||||
public void putAll(HolderReference holder, Set<HolderReference> inheritedGroups) {
|
|
||||||
this.lock.lock();
|
|
||||||
try {
|
|
||||||
this.map.entries().removeIf(entry -> entry.getValue().equals(holder));
|
|
||||||
|
|
||||||
for (HolderReference child : inheritedGroups) {
|
|
||||||
this.map.put(child, holder);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
this.lock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears defined inheritances for the given holder name.
|
|
||||||
*
|
|
||||||
* @param holder the holder name to clear
|
|
||||||
*/
|
|
||||||
public void clear(HolderReference holder) {
|
|
||||||
this.lock.lock();
|
|
||||||
try {
|
|
||||||
this.map.entries().removeIf(entry -> entry.getValue().equals(holder));
|
|
||||||
} finally {
|
|
||||||
this.lock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -30,10 +30,13 @@ import com.google.common.collect.ListMultimap;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.ChatMetaType;
|
import me.lucko.luckperms.api.ChatMetaType;
|
||||||
import me.lucko.luckperms.api.LocalizedNode;
|
import me.lucko.luckperms.api.LocalizedNode;
|
||||||
|
import me.lucko.luckperms.api.nodetype.types.MetaType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.types.PrefixType;
|
||||||
|
import me.lucko.luckperms.api.nodetype.types.SuffixType;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.metastacking.MetaStack;
|
import me.lucko.luckperms.common.metastacking.MetaStack;
|
||||||
import me.lucko.luckperms.common.metastacking.SimpleMetaStack;
|
import me.lucko.luckperms.common.metastacking.SimpleMetaStack;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -73,22 +76,19 @@ public class MetaAccumulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void accumulateNode(LocalizedNode n) {
|
public void accumulateNode(LocalizedNode n) {
|
||||||
if (n.isMeta()) {
|
n.getTypeData(MetaType.KEY).ifPresent(metaType ->
|
||||||
Map.Entry<String, String> entry = n.getMeta();
|
this.meta.put(metaType.getKey(), metaType.getValue())
|
||||||
this.meta.put(entry.getKey(), entry.getValue());
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if (n.isPrefix()) {
|
n.getTypeData(PrefixType.KEY).ifPresent(prefix -> {
|
||||||
Map.Entry<Integer, String> value = n.getPrefix();
|
this.prefixes.putIfAbsent(prefix.getPriority(), prefix.getPrefix());
|
||||||
this.prefixes.putIfAbsent(value.getKey(), value.getValue());
|
|
||||||
this.prefixStack.accumulateToAll(n);
|
this.prefixStack.accumulateToAll(n);
|
||||||
}
|
});
|
||||||
|
|
||||||
if (n.isSuffix()) {
|
n.getTypeData(SuffixType.KEY).ifPresent(suffix -> {
|
||||||
Map.Entry<Integer, String> value = n.getSuffix();
|
this.suffixes.putIfAbsent(suffix.getPriority(), suffix.getSuffix());
|
||||||
this.suffixes.putIfAbsent(value.getKey(), value.getValue());
|
|
||||||
this.suffixStack.accumulateToAll(n);
|
this.suffixStack.accumulateToAll(n);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void accumulateMeta(String key, String value) {
|
public void accumulateMeta(String key, String value) {
|
||||||
@ -103,8 +103,8 @@ public class MetaAccumulator {
|
|||||||
// (it's not going to accumulate more nodes)
|
// (it's not going to accumulate more nodes)
|
||||||
// Therefore, it should be ok to set the weight meta key, if not already present.
|
// Therefore, it should be ok to set the weight meta key, if not already present.
|
||||||
public ListMultimap<String, String> getMeta() {
|
public ListMultimap<String, String> getMeta() {
|
||||||
if (!this.meta.containsKey(NodeFactory.WEIGHT_KEY) && this.weight != 0) {
|
if (!this.meta.containsKey(NodeTypes.WEIGHT_KEY) && this.weight != 0) {
|
||||||
this.meta.put(NodeFactory.WEIGHT_KEY, String.valueOf(this.weight));
|
this.meta.put(NodeTypes.WEIGHT_KEY, String.valueOf(this.weight));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.meta;
|
return this.meta;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package me.lucko.luckperms.common.calculators;
|
package me.lucko.luckperms.common.calculators;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.common.references.HolderType;
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata about a given {@link PermissionCalculator}.
|
* Metadata about a given {@link PermissionCalculator}.
|
||||||
|
@ -42,7 +42,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -45,7 +45,7 @@ import me.lucko.luckperms.common.locale.command.CommandSpec;
|
|||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.TemporaryModifier;
|
import me.lucko.luckperms.common.model.TemporaryModifier;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.DurationFormatter;
|
import me.lucko.luckperms.common.utils.DurationFormatter;
|
||||||
|
@ -39,8 +39,8 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.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.node.model.NodeTypes;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.utils.MetaType;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
@ -68,13 +68,13 @@ public class MetaClear extends SharedSubCommand {
|
|||||||
if (typeId.equals("chat") || typeId.equals("chatmeta")) {
|
if (typeId.equals("chat") || typeId.equals("chatmeta")) {
|
||||||
type = MetaType.CHAT;
|
type = MetaType.CHAT;
|
||||||
}
|
}
|
||||||
if (typeId.equals(NodeFactory.META_KEY)) {
|
if (typeId.equals(NodeTypes.META_KEY)) {
|
||||||
type = MetaType.META;
|
type = MetaType.META;
|
||||||
}
|
}
|
||||||
if (typeId.equals(NodeFactory.PREFIX_KEY) || typeId.equals("prefixes")) {
|
if (typeId.equals(NodeTypes.PREFIX_KEY) || typeId.equals("prefixes")) {
|
||||||
type = MetaType.PREFIX;
|
type = MetaType.PREFIX;
|
||||||
}
|
}
|
||||||
if (typeId.equals(NodeFactory.SUFFIX_KEY) || typeId.equals("suffixes")) {
|
if (typeId.equals(NodeTypes.SUFFIX_KEY) || typeId.equals("suffixes")) {
|
||||||
type = MetaType.SUFFIX;
|
type = MetaType.SUFFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ public class MetaClear extends SharedSubCommand {
|
|||||||
type = MetaType.ANY;
|
type = MetaType.ANY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int before = holder.getEnduringNodes().size();
|
int before = holder.enduringData().immutable().size();
|
||||||
|
|
||||||
MutableContextSet context = ArgumentParser.parseContext(0, args, plugin);
|
MutableContextSet context = ArgumentParser.parseContext(0, args, plugin);
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ public class MetaClear extends SharedSubCommand {
|
|||||||
holder.clearMeta(type, context);
|
holder.clearMeta(type, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
int changed = before - holder.getEnduringNodes().size();
|
int changed = before - holder.enduringData().immutable().size();
|
||||||
if (changed == 1) {
|
if (changed == 1) {
|
||||||
Message.META_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), MessageUtils.contextSetToString(context), changed);
|
Message.META_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), MessageUtils.contextSetToString(context), changed);
|
||||||
} else {
|
} else {
|
||||||
|
@ -40,8 +40,8 @@ import me.lucko.luckperms.common.locale.command.CommandSpec;
|
|||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator;
|
||||||
import me.lucko.luckperms.common.node.NodeWithContextComparator;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -42,7 +42,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -42,7 +42,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.meta;
|
package me.lucko.luckperms.common.commands.generic.meta;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
|
import me.lucko.luckperms.api.StandardNodeEquality;
|
||||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
@ -39,8 +40,9 @@ import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
|||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
import me.lucko.luckperms.common.model.NodeMapType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
@ -79,7 +81,7 @@ public class MetaSet extends SharedSubCommand {
|
|||||||
|
|
||||||
Node n = NodeFactory.buildMetaNode(key, value).withExtraContext(context).build();
|
Node n = NodeFactory.buildMetaNode(key, value).withExtraContext(context).build();
|
||||||
|
|
||||||
if (holder.hasPermission(n).asBoolean()) {
|
if (holder.hasPermission(NodeMapType.ENDURING, n, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean()) {
|
||||||
Message.ALREADY_HAS_META.send(sender, holder.getFriendlyName(), key, value, MessageUtils.contextSetToString(context));
|
Message.ALREADY_HAS_META.send(sender, holder.getFriendlyName(), key, value, MessageUtils.contextSetToString(context));
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package me.lucko.luckperms.common.commands.generic.meta;
|
package me.lucko.luckperms.common.commands.generic.meta;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
|
import me.lucko.luckperms.api.StandardNodeEquality;
|
||||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
import me.lucko.luckperms.common.command.CommandManager;
|
||||||
@ -41,9 +42,10 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
|||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
import me.lucko.luckperms.common.model.NodeMapType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.TemporaryModifier;
|
import me.lucko.luckperms.common.model.TemporaryModifier;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.DurationFormatter;
|
import me.lucko.luckperms.common.utils.DurationFormatter;
|
||||||
@ -85,7 +87,7 @@ public class MetaSetTemp extends SharedSubCommand {
|
|||||||
|
|
||||||
Node n = NodeFactory.buildMetaNode(key, value).withExtraContext(context).setExpiry(duration).build();
|
Node n = NodeFactory.buildMetaNode(key, value).withExtraContext(context).setExpiry(duration).build();
|
||||||
|
|
||||||
if (holder.hasPermission(n).asBoolean()) {
|
if (holder.hasPermission(NodeMapType.ENDURING, n, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean()) {
|
||||||
Message.ALREADY_HAS_TEMP_META.send(sender, holder.getFriendlyName(), key, value, MessageUtils.contextSetToString(context));
|
Message.ALREADY_HAS_TEMP_META.send(sender, holder.getFriendlyName(), key, value, MessageUtils.contextSetToString(context));
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class HolderClear<T extends PermissionHolder> extends SubCommand<T> {
|
|||||||
return CommandResult.NO_PERMISSION;
|
return CommandResult.NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
int before = holder.getEnduringNodes().size();
|
int before = holder.enduringData().immutable().size();
|
||||||
|
|
||||||
MutableContextSet context = ArgumentParser.parseContext(0, args, plugin);
|
MutableContextSet context = ArgumentParser.parseContext(0, args, plugin);
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ public class HolderClear<T extends PermissionHolder> extends SubCommand<T> {
|
|||||||
holder.clearNodes(context);
|
holder.clearNodes(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
int changed = before - holder.getEnduringNodes().size();
|
int changed = before - holder.enduringData().immutable().size();
|
||||||
if (changed == 1) {
|
if (changed == 1) {
|
||||||
Message.CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed);
|
Message.CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed);
|
||||||
} else {
|
} else {
|
||||||
|
@ -73,9 +73,9 @@ public class HolderShowTracks<T extends PermissionHolder> extends SubCommand<T>
|
|||||||
|
|
||||||
if (holder.getType().isUser()) {
|
if (holder.getType().isUser()) {
|
||||||
// if the holder is a user, we want to query parent groups for tracks
|
// if the holder is a user, we want to query parent groups for tracks
|
||||||
Set<Node> nodes = holder.getEnduringNodes().values().stream()
|
Set<Node> nodes = holder.enduringData().immutable().values().stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.filter(Node::getValuePrimitive)
|
.filter(Node::getValue)
|
||||||
.filter(Node::isPermanent)
|
.filter(Node::isPermanent)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ import me.lucko.luckperms.common.locale.command.CommandSpec;
|
|||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -44,7 +44,7 @@ import me.lucko.luckperms.common.locale.message.Message;
|
|||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.TemporaryModifier;
|
import me.lucko.luckperms.common.model.TemporaryModifier;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.DurationFormatter;
|
import me.lucko.luckperms.common.utils.DurationFormatter;
|
||||||
|
@ -57,7 +57,7 @@ public class ParentClear extends SharedSubCommand {
|
|||||||
return CommandResult.NO_PERMISSION;
|
return CommandResult.NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
int before = holder.getEnduringNodes().size();
|
int before = holder.enduringData().immutable().size();
|
||||||
|
|
||||||
MutableContextSet context = ArgumentParser.parseContext(0, args, plugin);
|
MutableContextSet context = ArgumentParser.parseContext(0, args, plugin);
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ public class ParentClear extends SharedSubCommand {
|
|||||||
holder.clearParents(context, true);
|
holder.clearParents(context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int changed = before - holder.getEnduringNodes().size();
|
int changed = before - holder.enduringData().immutable().size();
|
||||||
if (changed == 1) {
|
if (changed == 1) {
|
||||||
Message.PARENT_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed);
|
Message.PARENT_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed);
|
||||||
} else {
|
} else {
|
||||||
|
@ -78,7 +78,7 @@ public class ParentClearTrack extends SharedSubCommand {
|
|||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int before = holder.getEnduringNodes().size();
|
int before = holder.enduringData().immutable().size();
|
||||||
|
|
||||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ public class ParentClearTrack extends SharedSubCommand {
|
|||||||
plugin.getUserManager().giveDefaultIfNeeded(((User) holder), false);
|
plugin.getUserManager().giveDefaultIfNeeded(((User) holder), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int changed = before - holder.getEnduringNodes().size();
|
int changed = before - holder.enduringData().immutable().size();
|
||||||
|
|
||||||
if (changed == 1) {
|
if (changed == 1) {
|
||||||
Message.PARENT_CLEAR_TRACK_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), track.getName(), MessageUtils.contextSetToString(context), changed);
|
Message.PARENT_CLEAR_TRACK_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), track.getName(), MessageUtils.contextSetToString(context), changed);
|
||||||
|
@ -40,8 +40,8 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator;
|
||||||
import me.lucko.luckperms.common.node.NodeWithContextComparator;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.CollationKeyCache;
|
import me.lucko.luckperms.common.utils.CollationKeyCache;
|
||||||
@ -77,10 +77,10 @@ public class ParentInfo extends SharedSubCommand {
|
|||||||
SortMode sortMode = SortMode.determine(args);
|
SortMode sortMode = SortMode.determine(args);
|
||||||
|
|
||||||
// get the holders nodes
|
// get the holders nodes
|
||||||
List<LocalizedNode> nodes = new ArrayList<>(holder.getEnduringData().asSortedSet());
|
List<LocalizedNode> nodes = new ArrayList<>(holder.enduringData().asSortedSet());
|
||||||
|
|
||||||
// remove irrelevant types (these are displayed in the other info commands)
|
// remove irrelevant types (these are displayed in the other info commands)
|
||||||
nodes.removeIf(node -> !node.isGroupNode() || !node.getValuePrimitive());
|
nodes.removeIf(node -> !node.isGroupNode() || !node.getValue());
|
||||||
|
|
||||||
// handle empty
|
// handle empty
|
||||||
if (nodes.isEmpty()) {
|
if (nodes.isEmpty()) {
|
||||||
|
@ -42,7 +42,7 @@ import me.lucko.luckperms.common.locale.command.CommandSpec;
|
|||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -40,7 +40,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -41,7 +41,7 @@ import me.lucko.luckperms.common.locale.message.Message;
|
|||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -41,7 +41,7 @@ import me.lucko.luckperms.common.locale.message.Message;
|
|||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.storage.DataConstraints;
|
import me.lucko.luckperms.common.storage.DataConstraints;
|
||||||
|
@ -38,7 +38,7 @@ import me.lucko.luckperms.common.locale.message.Message;
|
|||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -38,8 +38,9 @@ import me.lucko.luckperms.common.command.utils.MessageUtils;
|
|||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
import me.lucko.luckperms.common.model.NodeMapType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
@ -63,7 +64,7 @@ public class PermissionCheck extends SharedSubCommand {
|
|||||||
String node = ArgumentParser.parseString(0, args);
|
String node = ArgumentParser.parseString(0, args);
|
||||||
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
MutableContextSet context = ArgumentParser.parseContext(1, args, plugin);
|
||||||
|
|
||||||
Tristate result = holder.hasPermission(NodeFactory.builder(node).withExtraContext(context).build(), StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
|
Tristate result = holder.hasPermission(NodeMapType.ENDURING, NodeFactory.builder(node).withExtraContext(context).build(), StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
|
||||||
String s = MessageUtils.formatTristate(result);
|
String s = MessageUtils.formatTristate(result);
|
||||||
|
|
||||||
Message.CHECK_PERMISSION.send(sender, holder.getFriendlyName(), node, s, MessageUtils.contextSetToString(context));
|
Message.CHECK_PERMISSION.send(sender, holder.getFriendlyName(), node, s, MessageUtils.contextSetToString(context));
|
||||||
|
@ -38,8 +38,8 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.InheritanceInfo;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.utils.InheritanceInfo;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -57,7 +57,7 @@ public class PermissionClear extends SharedSubCommand {
|
|||||||
return CommandResult.NO_PERMISSION;
|
return CommandResult.NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
int before = holder.getEnduringNodes().size();
|
int before = holder.enduringData().immutable().size();
|
||||||
|
|
||||||
MutableContextSet context = ArgumentParser.parseContext(0, args, plugin);
|
MutableContextSet context = ArgumentParser.parseContext(0, args, plugin);
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ public class PermissionClear extends SharedSubCommand {
|
|||||||
holder.clearPermissions(context);
|
holder.clearPermissions(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
int changed = before - holder.getEnduringNodes().size();
|
int changed = before - holder.enduringData().immutable().size();
|
||||||
if (changed == 1) {
|
if (changed == 1) {
|
||||||
Message.PERMISSION_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed);
|
Message.PERMISSION_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed);
|
||||||
} else {
|
} else {
|
||||||
|
@ -40,8 +40,8 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator;
|
||||||
import me.lucko.luckperms.common.node.NodeWithContextComparator;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.CollationKeyCache;
|
import me.lucko.luckperms.common.utils.CollationKeyCache;
|
||||||
@ -77,14 +77,12 @@ public class PermissionInfo extends SharedSubCommand {
|
|||||||
SortMode sortMode = SortMode.determine(args);
|
SortMode sortMode = SortMode.determine(args);
|
||||||
|
|
||||||
// get the holders nodes
|
// get the holders nodes
|
||||||
List<LocalizedNode> nodes = new ArrayList<>(holder.getEnduringData().asSortedSet());
|
List<LocalizedNode> nodes = new ArrayList<>(holder.enduringData().asSortedSet());
|
||||||
|
|
||||||
// remove irrelevant types (these are displayed in the other info commands)
|
// remove irrelevant types (these are displayed in the other info commands)
|
||||||
nodes.removeIf(node ->
|
nodes.removeIf(node -> (node.isGroupNode() && node.getValue() && plugin.getGroupManager().isLoaded(node.getGroupName())) ||
|
||||||
// remove if the node is a group node, and if the value isn't false and if the group actually exists
|
// remove if the node is a meta node
|
||||||
(node.isGroupNode() && node.getValuePrimitive() && plugin.getGroupManager().isLoaded(node.getGroupName())) ||
|
node.isPrefix() || node.isSuffix() || node.isMeta()
|
||||||
// remove if the node is a meta node
|
|
||||||
node.isPrefix() || node.isSuffix() || node.isMeta()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// handle empty
|
// handle empty
|
||||||
@ -118,7 +116,7 @@ public class PermissionInfo extends SharedSubCommand {
|
|||||||
|
|
||||||
// send content
|
// send content
|
||||||
for (LocalizedNode node : content) {
|
for (LocalizedNode node : content) {
|
||||||
String s = "&3> " + (node.getValuePrimitive() ? "&a" : "&c") + node.getPermission() + (sender.isConsole() ? " &7(" + node.getValuePrimitive() + "&7)" : "") + MessageUtils.getAppendableNodeContextString(node);
|
String s = "&3> " + (node.getValue() ? "&a" : "&c") + node.getPermission() + (sender.isConsole() ? " &7(" + node.getValue() + "&7)" : "") + MessageUtils.getAppendableNodeContextString(node);
|
||||||
if (node.isTemporary()) {
|
if (node.isTemporary()) {
|
||||||
s += "\n&2- expires in " + DurationFormatter.LONG.formatDateDiff(node.getExpiryUnixTime());
|
s += "\n&2- expires in " + DurationFormatter.LONG.formatDateDiff(node.getExpiryUnixTime());
|
||||||
}
|
}
|
||||||
@ -142,7 +140,7 @@ public class PermissionInfo extends SharedSubCommand {
|
|||||||
|
|
||||||
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(PermissionHolder holder, String label, Node node) {
|
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(PermissionHolder holder, String label, Node node) {
|
||||||
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
|
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
|
||||||
"¥3> " + (node.getValuePrimitive() ? "¥a" : "¥c") + node.getPermission(),
|
"¥3> " + (node.getValue() ? "¥a" : "¥c") + node.getPermission(),
|
||||||
" ",
|
" ",
|
||||||
"¥7Click to remove this node from " + holder.getFriendlyName()
|
"¥7Click to remove this node from " + holder.getFriendlyName()
|
||||||
), '¥'));
|
), '¥'));
|
||||||
|
@ -40,7 +40,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -43,7 +43,7 @@ import me.lucko.luckperms.common.locale.command.CommandSpec;
|
|||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.TemporaryModifier;
|
import me.lucko.luckperms.common.model.TemporaryModifier;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.DurationFormatter;
|
import me.lucko.luckperms.common.utils.DurationFormatter;
|
||||||
|
@ -40,7 +40,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -40,7 +40,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -36,7 +36,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -36,6 +36,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
|
import me.lucko.luckperms.common.model.NodeMapType;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.storage.DataConstraints;
|
import me.lucko.luckperms.common.storage.DataConstraints;
|
||||||
@ -72,7 +73,7 @@ public class GroupClone extends SubCommand<Group> {
|
|||||||
return CommandResult.NO_PERMISSION;
|
return CommandResult.NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
newGroup.replaceEnduringNodes(group.getEnduringNodes());
|
newGroup.replaceNodes(NodeMapType.ENDURING, group.enduringData().immutable());
|
||||||
|
|
||||||
Message.CLONE_SUCCESS.send(sender, group.getName(), newGroup.getName());
|
Message.CLONE_SUCCESS.send(sender, group.getName(), newGroup.getName());
|
||||||
|
|
||||||
|
@ -62,12 +62,12 @@ public class GroupInfo extends SubCommand<Group> {
|
|||||||
group.getWeight().isPresent() ? group.getWeight().getAsInt() : "None"
|
group.getWeight().isPresent() ? group.getWeight().getAsInt() : "None"
|
||||||
);
|
);
|
||||||
|
|
||||||
Set<Node> parents = group.getEnduringData().asSet().stream()
|
Set<Node> parents = group.enduringData().asSet().stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.filter(Node::isPermanent)
|
.filter(Node::isPermanent)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
Set<Node> tempParents = group.getEnduringData().asSet().stream()
|
Set<Node> tempParents = group.enduringData().asSet().stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.filter(Node::isTemporary)
|
.filter(Node::isTemporary)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
@ -42,10 +42,10 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.node.HeldPermissionComparator;
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.comparator.HeldPermissionComparator;
|
||||||
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.HolderType;
|
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.DurationFormatter;
|
import me.lucko.luckperms.common.utils.DurationFormatter;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.utils.Iterators;
|
||||||
|
@ -36,6 +36,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
|
import me.lucko.luckperms.common.model.NodeMapType;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.storage.DataConstraints;
|
import me.lucko.luckperms.common.storage.DataConstraints;
|
||||||
@ -78,7 +79,7 @@ public class GroupRename extends SubCommand<Group> {
|
|||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
newGroup.replaceEnduringNodes(group.getEnduringNodes());
|
newGroup.replaceNodes(NodeMapType.ENDURING, group.enduringData().immutable());
|
||||||
|
|
||||||
Message.RENAME_SUCCESS.send(sender, group.getName(), newGroup.getName());
|
Message.RENAME_SUCCESS.send(sender, group.getName(), newGroup.getName());
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.commands.group;
|
package me.lucko.luckperms.common.commands.group;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.nodetype.types.WeightType;
|
||||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
import me.lucko.luckperms.common.command.abstraction.CommandException;
|
||||||
@ -37,7 +38,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
@ -58,7 +59,7 @@ public class GroupSetWeight extends SubCommand<Group> {
|
|||||||
|
|
||||||
int weight = ArgumentParser.parsePriority(0, args);
|
int weight = ArgumentParser.parsePriority(0, args);
|
||||||
|
|
||||||
group.removeIf(n -> NodeFactory.parseWeightNode(n.getPermission()) != null);
|
group.removeIf(n -> n.getTypeData(WeightType.KEY).isPresent());
|
||||||
group.setPermission(NodeFactory.buildWeightNode(weight).build());
|
group.setPermission(NodeFactory.buildWeightNode(weight).build());
|
||||||
|
|
||||||
Message.GROUP_SET_WEIGHT.send(sender, weight, group.getFriendlyName());
|
Message.GROUP_SET_WEIGHT.send(sender, weight, group.getFriendlyName());
|
||||||
|
@ -34,7 +34,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
@ -60,7 +60,7 @@ public class LogNotify extends SubCommand<Log> {
|
|||||||
|
|
||||||
// if they don't have the perm, they're not ignoring
|
// if they don't have the perm, they're not ignoring
|
||||||
// if set to false, ignore it, return false
|
// if set to false, ignore it, return false
|
||||||
return ret.map(Node::getValuePrimitive).orElse(false);
|
return ret.map(Node::getValue).orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setIgnoring(LuckPermsPlugin plugin, UUID uuid, boolean state) {
|
private static void setIgnoring(LuckPermsPlugin plugin, UUID uuid, boolean state) {
|
||||||
|
@ -26,8 +26,9 @@
|
|||||||
package me.lucko.luckperms.common.commands.migration;
|
package me.lucko.luckperms.common.commands.migration;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
|
import me.lucko.luckperms.api.nodetype.types.WeightType;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
|
|
||||||
public final class MigrationUtils {
|
public final class MigrationUtils {
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ public final class MigrationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setGroupWeight(Group group, int weight) {
|
public static void setGroupWeight(Group group, int weight) {
|
||||||
group.removeIf(n -> NodeFactory.parseWeightNode(n.getPermission()) != null);
|
group.removeIf(n -> n.getTypeData(WeightType.KEY).isPresent());
|
||||||
group.setPermission(NodeFactory.buildWeightNode(weight).build());
|
group.setPermission(NodeFactory.buildWeightNode(weight).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +41,9 @@ import me.lucko.luckperms.common.command.utils.StorageAssistant;
|
|||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
import me.lucko.luckperms.common.model.NodeMapType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.NodeModel;
|
import me.lucko.luckperms.common.node.model.NodeDataContainer;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.DurationFormatter;
|
import me.lucko.luckperms.common.utils.DurationFormatter;
|
||||||
@ -105,10 +106,10 @@ public class ApplyEditsCommand extends SingleCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<NodeModel> nodes = WebEditor.deserializePermissions(data.getAsJsonArray("nodes"));
|
Set<NodeDataContainer> nodes = WebEditor.deserializePermissions(data.getAsJsonArray("nodes"));
|
||||||
|
|
||||||
Set<Node> before = new HashSet<>(holder.getEnduringNodes().values());
|
Set<Node> before = new HashSet<>(holder.enduringData().immutable().values());
|
||||||
Set<Node> after = nodes.stream().map(NodeModel::toNode).collect(Collectors.toSet());
|
Set<Node> after = nodes.stream().map(NodeDataContainer::toNode).collect(Collectors.toSet());
|
||||||
|
|
||||||
Map.Entry<Set<Node>, Set<Node>> diff = diff(before, after);
|
Map.Entry<Set<Node>, Set<Node>> diff = diff(before, after);
|
||||||
Set<Node> diffAdded = diff.getKey();
|
Set<Node> diffAdded = diff.getKey();
|
||||||
@ -121,16 +122,16 @@ public class ApplyEditsCommand extends SingleCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.setEnduringNodes(after);
|
holder.setNodes(NodeMapType.ENDURING, after);
|
||||||
|
|
||||||
for (Node n : diffAdded) {
|
for (Node n : diffAdded) {
|
||||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||||
.action("webeditor", "add", n.getPermission(), n.getValuePrimitive(), n.getFullContexts())
|
.action("webeditor", "add", n.getPermission(), n.getValue(), n.getFullContexts())
|
||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
}
|
}
|
||||||
for (Node n : diffRemoved) {
|
for (Node n : diffRemoved) {
|
||||||
ExtendedLogEntry.build().actor(sender).acted(holder)
|
ExtendedLogEntry.build().actor(sender).acted(holder)
|
||||||
.action("webeditor", "remove", n.getPermission(), n.getValuePrimitive(), n.getFullContexts())
|
.action("webeditor", "remove", n.getPermission(), n.getValue(), n.getFullContexts())
|
||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +151,7 @@ public class ApplyEditsCommand extends SingleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String formatNode(Node n) {
|
private static String formatNode(Node n) {
|
||||||
return n.getPermission() + " &7(" + (n.getValuePrimitive() ? "&a" : "&c") + n.getValuePrimitive() + "&7)" + MessageUtils.getAppendableNodeContextString(n) +
|
return n.getPermission() + " &7(" + (n.getValue() ? "&a" : "&c") + n.getValue() + "&7)" + MessageUtils.getAppendableNodeContextString(n) +
|
||||||
(n.isTemporary() ? " &7(" + DurationFormatter.CONCISE.formatDateDiff(n.getExpiryUnixTime()) + ")" : "");
|
(n.isTemporary() ? " &7(" + DurationFormatter.CONCISE.formatDateDiff(n.getExpiryUnixTime()) + ")" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,11 +41,10 @@ import me.lucko.luckperms.common.command.utils.TabCompletions;
|
|||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.node.HeldPermissionComparator;
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.comparator.HeldPermissionComparator;
|
||||||
import me.lucko.luckperms.common.node.NodeHeldPermission;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.HolderType;
|
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.DurationFormatter;
|
import me.lucko.luckperms.common.utils.DurationFormatter;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.utils.Iterators;
|
||||||
@ -147,7 +146,7 @@ public class SearchCommand extends SingleCommand {
|
|||||||
|
|
||||||
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(String holderName, HolderType holderType, String label, HeldPermission<?> perm) {
|
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(String holderName, HolderType holderType, String label, HeldPermission<?> perm) {
|
||||||
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
|
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
|
||||||
"&3> " + (perm.asNode().getValuePrimitive() ? "&a" : "&c") + perm.asNode().getPermission(),
|
"&3> " + (perm.asNode().getValue() ? "&a" : "&c") + perm.asNode().getPermission(),
|
||||||
" ",
|
" ",
|
||||||
"&7Click to remove this node from " + holderName
|
"&7Click to remove this node from " + holderName
|
||||||
), CommandManager.AMPERSAND_CHAR));
|
), CommandManager.AMPERSAND_CHAR));
|
||||||
|
@ -35,6 +35,7 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
|||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
import me.lucko.luckperms.common.model.NodeMapType;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
@ -99,7 +100,7 @@ public class UserClone extends SubCommand<User> {
|
|||||||
return CommandResult.NO_PERMISSION;
|
return CommandResult.NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
otherUser.replaceEnduringNodes(user.getEnduringNodes());
|
otherUser.replaceNodes(NodeMapType.ENDURING, user.enduringData().immutable());
|
||||||
|
|
||||||
Message.CLONE_SUCCESS.send(sender, user.getFriendlyName(), otherUser.getFriendlyName());
|
Message.CLONE_SUCCESS.send(sender, user.getFriendlyName(), otherUser.getFriendlyName());
|
||||||
|
|
||||||
|
@ -72,12 +72,12 @@ public class UserInfo extends SubCommand<User> {
|
|||||||
user.getPrimaryGroup().getValue()
|
user.getPrimaryGroup().getValue()
|
||||||
);
|
);
|
||||||
|
|
||||||
Set<Node> parents = user.getEnduringData().asSet().stream()
|
Set<Node> parents = user.enduringData().asSet().stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.filter(Node::isPermanent)
|
.filter(Node::isPermanent)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
Set<Node> tempParents = user.getEnduringData().asSet().stream()
|
Set<Node> tempParents = user.enduringData().asSet().stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.filter(Node::isTemporary)
|
.filter(Node::isTemporary)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
@ -42,8 +42,8 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
|||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
|
import me.lucko.luckperms.common.model.UserIdentifier;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.UserIdentifier;
|
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.storage.DataConstraints;
|
import me.lucko.luckperms.common.storage.DataConstraints;
|
||||||
import me.lucko.luckperms.common.utils.Uuids;
|
import me.lucko.luckperms.common.utils.Uuids;
|
||||||
|
@ -123,7 +123,7 @@ public final class EventFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleGroupDelete(Group group, DeletionCause cause) {
|
public void handleGroupDelete(Group group, DeletionCause cause) {
|
||||||
EventGroupDelete event = new EventGroupDelete(group.getName(), ImmutableSet.copyOf(group.getEnduringNodes().values()), cause);
|
EventGroupDelete event = new EventGroupDelete(group.getName(), ImmutableSet.copyOf(group.enduringData().immutable().values()), cause);
|
||||||
fireEventAsync(event);
|
fireEventAsync(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.inheritance;
|
|||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import com.github.benmanes.caffeine.cache.Caffeine;
|
|||||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.references.Identifiable;
|
import me.lucko.luckperms.common.model.Identifiable;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.managers;
|
package me.lucko.luckperms.common.managers;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.references.Identifiable;
|
import me.lucko.luckperms.common.model.Identifiable;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -30,9 +30,9 @@ import me.lucko.luckperms.api.context.ImmutableContextSet;
|
|||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.managers.AbstractManager;
|
import me.lucko.luckperms.common.managers.AbstractManager;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.model.UserIdentifier;
|
||||||
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.UserIdentifier;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -83,7 +83,7 @@ public abstract class AbstractUserManager<T extends User> extends AbstractManage
|
|||||||
String pg = user.getPrimaryGroup().getValue();
|
String pg = user.getPrimaryGroup().getValue();
|
||||||
boolean has = false;
|
boolean has = false;
|
||||||
|
|
||||||
for (Node node : user.getEnduringNodes().get(ImmutableContextSet.empty())) {
|
for (Node node : user.enduringData().immutable().get(ImmutableContextSet.empty())) {
|
||||||
if (node.isGroupNode() && node.getGroupName().equalsIgnoreCase(pg)) {
|
if (node.isGroupNode() && node.getGroupName().equalsIgnoreCase(pg)) {
|
||||||
has = true;
|
has = true;
|
||||||
break;
|
break;
|
||||||
@ -92,7 +92,7 @@ public abstract class AbstractUserManager<T extends User> extends AbstractManage
|
|||||||
|
|
||||||
// need to find a new primary group for the user.
|
// need to find a new primary group for the user.
|
||||||
if (!has) {
|
if (!has) {
|
||||||
String group = user.getEnduringNodes().get(ImmutableContextSet.empty()).stream()
|
String group = user.enduringData().immutable().get(ImmutableContextSet.empty()).stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.map(Node::getGroupName)
|
.map(Node::getGroupName)
|
||||||
@ -109,7 +109,7 @@ public abstract class AbstractUserManager<T extends User> extends AbstractManage
|
|||||||
// check that all users are member of at least one group
|
// check that all users are member of at least one group
|
||||||
boolean hasGroup = false;
|
boolean hasGroup = false;
|
||||||
if (user.getPrimaryGroup().getStoredValue().isPresent()) {
|
if (user.getPrimaryGroup().getStoredValue().isPresent()) {
|
||||||
for (Node node : user.getEnduringNodes().values()) {
|
for (Node node : user.enduringData().immutable().values()) {
|
||||||
if (node.hasSpecificContext()) {
|
if (node.hasSpecificContext()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -160,11 +160,11 @@ public abstract class AbstractUserManager<T extends User> extends AbstractManage
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldSave(User user) {
|
public boolean shouldSave(User user) {
|
||||||
if (user.getEnduringNodes().size() != 1) {
|
if (user.enduringData().immutable().size() != 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Node node : user.getEnduringNodes().values()) {
|
for (Node node : user.enduringData().immutable().values()) {
|
||||||
// There's only one.
|
// There's only one.
|
||||||
if (!node.isGroupNode()) {
|
if (!node.isGroupNode()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
package me.lucko.luckperms.common.managers.user;
|
package me.lucko.luckperms.common.managers.user;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
|
import me.lucko.luckperms.common.model.UserIdentifier;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.UserIdentifier;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.managers.user;
|
package me.lucko.luckperms.common.managers.user;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.model.UserIdentifier;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.UserIdentifier;
|
|
||||||
import me.lucko.luckperms.common.utils.ExpiringSet;
|
import me.lucko.luckperms.common.utils.ExpiringSet;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -27,7 +27,7 @@ package me.lucko.luckperms.common.managers.user;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.managers.Manager;
|
import me.lucko.luckperms.common.managers.Manager;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.references.UserIdentifier;
|
import me.lucko.luckperms.common.model.UserIdentifier;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
@ -29,30 +29,37 @@ import me.lucko.luckperms.api.Node;
|
|||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.common.api.delegates.model.ApiGroup;
|
import me.lucko.luckperms.common.api.delegates.model.ApiGroup;
|
||||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||||
|
import me.lucko.luckperms.common.buffers.Cache;
|
||||||
import me.lucko.luckperms.common.caching.GroupCachedData;
|
import me.lucko.luckperms.common.caching.GroupCachedData;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.GroupReference;
|
|
||||||
import me.lucko.luckperms.common.references.HolderType;
|
|
||||||
import me.lucko.luckperms.common.references.Identifiable;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.OptionalInt;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class Group extends PermissionHolder implements Identifiable<String> {
|
public class Group extends PermissionHolder implements Identifiable<String> {
|
||||||
|
private final ApiGroup apiDelegate = new ApiGroup(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the group
|
* The name of the group
|
||||||
*/
|
*/
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
private final ApiGroup apiDelegate = new ApiGroup(this);
|
/**
|
||||||
|
* Caches the holders weight
|
||||||
|
* @see #getWeight()
|
||||||
|
*/
|
||||||
|
private final Cache<OptionalInt> weightCache = new WeightCache(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The groups data cache instance
|
* The groups data cache instance
|
||||||
*/
|
*/
|
||||||
private final GroupCachedData cachedData;
|
private final GroupCachedData cachedData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The group's cached data refresh buffer
|
||||||
|
*/
|
||||||
private final GroupRefreshBuffer refreshBuffer;
|
private final GroupRefreshBuffer refreshBuffer;
|
||||||
|
|
||||||
public Group(String name, LuckPermsPlugin plugin) {
|
public Group(String name, LuckPermsPlugin plugin) {
|
||||||
@ -67,6 +74,12 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
|||||||
getStateListeners().add(this.refreshBuffer::request);
|
getStateListeners().add(this.refreshBuffer::request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void invalidateCache() {
|
||||||
|
this.weightCache.invalidate();
|
||||||
|
super.invalidateCache();
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
@ -92,7 +105,7 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
|||||||
|
|
||||||
public Optional<String> getDisplayName() {
|
public Optional<String> getDisplayName() {
|
||||||
String name = null;
|
String name = null;
|
||||||
for (Node n : getEnduringNodes().get(ImmutableContextSet.empty())) {
|
for (Node n : enduringData().immutable().get(ImmutableContextSet.empty())) {
|
||||||
if (!n.getPermission().startsWith("displayname.")) {
|
if (!n.getPermission().startsWith("displayname.")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -116,8 +129,8 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GroupReference toReference() {
|
public OptionalInt getWeight() {
|
||||||
return GroupReference.of(getId());
|
return this.weightCache.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.references;
|
package me.lucko.luckperms.common.model;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
|
||||||
|
|
||||||
public enum HolderType {
|
public enum HolderType {
|
||||||
|
|
@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.references;
|
package me.lucko.luckperms.common.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to represent an identifiable object
|
* Interface to represent an identifiable object
|
@ -37,9 +37,9 @@ import me.lucko.luckperms.api.context.ContextSet;
|
|||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.common.buffers.Cache;
|
import me.lucko.luckperms.common.buffers.Cache;
|
||||||
import me.lucko.luckperms.common.contexts.ContextSetComparator;
|
import me.lucko.luckperms.common.contexts.ContextSetComparator;
|
||||||
import me.lucko.luckperms.common.node.ImmutableLocalizedNode;
|
import me.lucko.luckperms.common.node.comparator.NodeComparator;
|
||||||
import me.lucko.luckperms.common.node.NodeComparator;
|
import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator;
|
||||||
import me.lucko.luckperms.common.node.NodeWithContextComparator;
|
import me.lucko.luckperms.common.node.model.ImmutableLocalizedNode;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -207,7 +207,7 @@ public final class NodeMap {
|
|||||||
try {
|
try {
|
||||||
ImmutableContextSet context = node.getFullContexts().makeImmutable();
|
ImmutableContextSet context = node.getFullContexts().makeImmutable();
|
||||||
this.map.put(context, node);
|
this.map.put(context, node);
|
||||||
if (node.isGroupNode() && node.getValuePrimitive()) {
|
if (node.isGroupNode() && node.getValue()) {
|
||||||
this.inheritanceMap.put(context, node);
|
this.inheritanceMap.put(context, node);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@ -233,7 +233,7 @@ public final class NodeMap {
|
|||||||
try {
|
try {
|
||||||
ImmutableContextSet context = node.getFullContexts().makeImmutable();
|
ImmutableContextSet context = node.getFullContexts().makeImmutable();
|
||||||
this.map.remove(context, node);
|
this.map.remove(context, node);
|
||||||
if (node.isGroupNode() && node.getValuePrimitive()) {
|
if (node.isGroupNode() && node.getValue()) {
|
||||||
this.inheritanceMap.remove(context, node);
|
this.inheritanceMap.remove(context, node);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@ -293,7 +293,7 @@ public final class NodeMap {
|
|||||||
|
|
||||||
this.map.putAll(multimap);
|
this.map.putAll(multimap);
|
||||||
for (Map.Entry<ImmutableContextSet, Node> entry : this.map.entries()) {
|
for (Map.Entry<ImmutableContextSet, Node> entry : this.map.entries()) {
|
||||||
if (entry.getValue().isGroupNode() && entry.getValue().getValuePrimitive()) {
|
if (entry.getValue().isGroupNode() && entry.getValue().getValue()) {
|
||||||
this.inheritanceMap.put(entry.getKey(), entry.getValue());
|
this.inheritanceMap.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -342,7 +342,7 @@ public final class NodeMap {
|
|||||||
if (removed != null) {
|
if (removed != null) {
|
||||||
removed.add(entry);
|
removed.add(entry);
|
||||||
}
|
}
|
||||||
if (entry.isGroupNode() && entry.getValuePrimitive()) {
|
if (entry.isGroupNode() && entry.getValue()) {
|
||||||
this.inheritanceMap.remove(entry.getFullContexts().makeImmutable(), entry);
|
this.inheritanceMap.remove(entry.getFullContexts().makeImmutable(), entry);
|
||||||
}
|
}
|
||||||
work = true;
|
work = true;
|
||||||
|
@ -27,7 +27,6 @@ package me.lucko.luckperms.common.model;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableCollection;
|
import com.google.common.collect.ImmutableCollection;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSetMultimap;
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
@ -42,23 +41,19 @@ import me.lucko.luckperms.api.Tristate;
|
|||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||||
import me.lucko.luckperms.common.buffers.Cache;
|
|
||||||
import me.lucko.luckperms.common.caching.HolderCachedData;
|
import me.lucko.luckperms.common.caching.HolderCachedData;
|
||||||
import me.lucko.luckperms.common.caching.handlers.StateListener;
|
import me.lucko.luckperms.common.caching.handlers.StateListener;
|
||||||
import me.lucko.luckperms.common.caching.type.MetaAccumulator;
|
import me.lucko.luckperms.common.caching.type.MetaAccumulator;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.inheritance.InheritanceComparator;
|
import me.lucko.luckperms.common.inheritance.InheritanceComparator;
|
||||||
import me.lucko.luckperms.common.inheritance.InheritanceGraph;
|
import me.lucko.luckperms.common.inheritance.InheritanceGraph;
|
||||||
import me.lucko.luckperms.common.node.ImmutableLocalizedNode;
|
import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator;
|
||||||
import me.lucko.luckperms.common.node.InheritanceInfo;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.node.MetaType;
|
import me.lucko.luckperms.common.node.model.ImmutableLocalizedNode;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.utils.InheritanceInfo;
|
||||||
import me.lucko.luckperms.common.node.NodeTools;
|
import me.lucko.luckperms.common.node.utils.MetaType;
|
||||||
import me.lucko.luckperms.common.node.NodeWithContextComparator;
|
import me.lucko.luckperms.common.node.utils.NodeTools;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.GroupReference;
|
|
||||||
import me.lucko.luckperms.common.references.HolderReference;
|
|
||||||
import me.lucko.luckperms.common.references.HolderType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -76,7 +71,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an object that can hold permissions, (a user or group)
|
* Represents an object that can hold permissions, (a user or group)
|
||||||
@ -124,7 +118,7 @@ public abstract class PermissionHolder {
|
|||||||
*
|
*
|
||||||
* <p>These (unlike transient nodes) are saved to the storage backing.</p>
|
* <p>These (unlike transient nodes) are saved to the storage backing.</p>
|
||||||
*
|
*
|
||||||
* @see #getEnduringData()
|
* @see #enduringData()
|
||||||
*/
|
*/
|
||||||
private final NodeMap enduringNodes = new NodeMap(this);
|
private final NodeMap enduringNodes = new NodeMap(this);
|
||||||
|
|
||||||
@ -136,16 +130,10 @@ public abstract class PermissionHolder {
|
|||||||
* when the server stops, and for a user, it's when they log out, or get
|
* when the server stops, and for a user, it's when they log out, or get
|
||||||
* unloaded.)</p>
|
* unloaded.)</p>
|
||||||
*
|
*
|
||||||
* @see #getTransientData()
|
* @see #transientData()
|
||||||
*/
|
*/
|
||||||
private final NodeMap transientNodes = new NodeMap(this);
|
private final NodeMap transientNodes = new NodeMap(this);
|
||||||
|
|
||||||
/**
|
|
||||||
* Caches the holders weight
|
|
||||||
* @see #getWeight()
|
|
||||||
*/
|
|
||||||
private final Cache<OptionalInt> weightCache = WeightCache.getFor(this);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lock used by Storage implementations to prevent concurrent read/writes
|
* Lock used by Storage implementations to prevent concurrent read/writes
|
||||||
* @see #getIoLock()
|
* @see #getIoLock()
|
||||||
@ -183,10 +171,9 @@ public abstract class PermissionHolder {
|
|||||||
return this.stateListeners;
|
return this.stateListeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invalidateCache() {
|
protected void invalidateCache() {
|
||||||
this.enduringNodes.invalidate();
|
this.enduringNodes.invalidate();
|
||||||
this.transientNodes.invalidate();
|
this.transientNodes.invalidate();
|
||||||
this.weightCache.invalidate();
|
|
||||||
|
|
||||||
// Invalidate listeners
|
// Invalidate listeners
|
||||||
for (StateListener listener : this.stateListeners) {
|
for (StateListener listener : this.stateListeners) {
|
||||||
@ -196,17 +183,6 @@ public abstract class PermissionHolder {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Declare new state to the state manager
|
|
||||||
declareState();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void declareState() {
|
|
||||||
/* only declare state of groups. the state manager isn't really being used now the caches in this class
|
|
||||||
are gone, but it's useful for command output. */
|
|
||||||
if (this.getType().isGroup()) {
|
|
||||||
this.plugin.getCachedStateManager().putAll(toReference(), getGroupReferences());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -223,14 +199,12 @@ public abstract class PermissionHolder {
|
|||||||
*/
|
*/
|
||||||
public abstract HolderCachedData<?> getCachedData();
|
public abstract HolderCachedData<?> getCachedData();
|
||||||
|
|
||||||
public abstract BufferedRequest<Void> getRefreshBuffer();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forms a HolderReference for this PermissionHolder.
|
* Gets the holders refresh buffer
|
||||||
*
|
*
|
||||||
* @return this holders reference
|
* @return the holders refresh buffer
|
||||||
*/
|
*/
|
||||||
public abstract HolderReference<?, ?> toReference();
|
public abstract BufferedRequest<Void> getRefreshBuffer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of this PermissionHolder.
|
* Returns the type of this PermissionHolder.
|
||||||
@ -254,43 +228,21 @@ public abstract class PermissionHolder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeMap getEnduringData() {
|
public NodeMap enduringData() {
|
||||||
return this.enduringNodes;
|
return this.enduringNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeMap getTransientData() {
|
public NodeMap transientData() {
|
||||||
return this.transientNodes;
|
return this.transientNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableSetMultimap<ImmutableContextSet, Node> getNodes(NodeMapType type) {
|
public void setNodes(NodeMapType type, Set<Node> set) {
|
||||||
return getData(type).immutable();
|
getData(type).setContent(set);
|
||||||
}
|
|
||||||
|
|
||||||
public ImmutableSetMultimap<ImmutableContextSet, Node> getEnduringNodes() {
|
|
||||||
return this.enduringNodes.immutable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImmutableSetMultimap<ImmutableContextSet, Node> getTransientNodes() {
|
|
||||||
return this.transientNodes.immutable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets this objects nodes to the values in the set
|
|
||||||
*
|
|
||||||
* @param set the set of nodes to apply to the object
|
|
||||||
*/
|
|
||||||
public void setEnduringNodes(Set<Node> set) {
|
|
||||||
this.enduringNodes.setContent(set);
|
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void replaceNodes(NodeMapType type, Multimap<ImmutableContextSet, Node> multimap) {
|
||||||
* Replaces the multimap backing this object with another
|
getData(type).setContent(multimap);
|
||||||
*
|
|
||||||
* @param multimap the replacement multimap
|
|
||||||
*/
|
|
||||||
public void replaceEnduringNodes(Multimap<ImmutableContextSet, Node> multimap) {
|
|
||||||
this.enduringNodes.setContent(multimap);
|
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +286,7 @@ public abstract class PermissionHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeIf(Predicate<Node> predicate, Runnable taskIfSuccess) {
|
public boolean removeIf(Predicate<Node> predicate, Runnable taskIfSuccess) {
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = enduringData().immutable().values();
|
||||||
if (!this.enduringNodes.removeIf(predicate)) {
|
if (!this.enduringNodes.removeIf(predicate)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -342,7 +294,7 @@ public abstract class PermissionHolder {
|
|||||||
taskIfSuccess.run();
|
taskIfSuccess.run();
|
||||||
}
|
}
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = enduringData().immutable().values();
|
||||||
|
|
||||||
this.plugin.getEventFactory().handleNodeClear(this, before, after);
|
this.plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
@ -353,7 +305,7 @@ public abstract class PermissionHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeIf(ContextSet contextSet, Predicate<Node> predicate, Runnable taskIfSuccess) {
|
public boolean removeIf(ContextSet contextSet, Predicate<Node> predicate, Runnable taskIfSuccess) {
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = enduringData().immutable().values();
|
||||||
if (!this.enduringNodes.removeIf(contextSet, predicate)) {
|
if (!this.enduringNodes.removeIf(contextSet, predicate)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -361,7 +313,7 @@ public abstract class PermissionHolder {
|
|||||||
taskIfSuccess.run();
|
taskIfSuccess.run();
|
||||||
}
|
}
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = enduringData().immutable().values();
|
||||||
|
|
||||||
this.plugin.getEventFactory().handleNodeClear(this, before, after);
|
this.plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
@ -375,7 +327,7 @@ public abstract class PermissionHolder {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void accumulateInheritancesTo(List<LocalizedNode> accumulator, Contexts context) {
|
public void accumulateInheritancesTo(List<LocalizedNode> accumulator, Contexts context) {
|
||||||
InheritanceGraph graph = this.plugin.getInheritanceHandler().getGraph(context);
|
InheritanceGraph graph = this.plugin.getInheritanceHandler().getGraph(context);
|
||||||
Iterable<PermissionHolder> traversal = graph.traverse(this.plugin.getConfiguration().get(ConfigKeys.INHERITANCE_TRAVERSAL_ALGORITHM), this);
|
Iterable<PermissionHolder> traversal = graph.traverse(this.plugin.getConfiguration().get(ConfigKeys.INHERITANCE_TRAVERSAL_ALGORITHM), this);
|
||||||
for (PermissionHolder holder : traversal) {
|
for (PermissionHolder holder : traversal) {
|
||||||
@ -393,27 +345,7 @@ public abstract class PermissionHolder {
|
|||||||
return accumulator;
|
return accumulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedSet<LocalizedNode> resolveInheritancesAlmostEqual(Contexts contexts) {
|
public void accumulateInheritancesTo(List<LocalizedNode> accumulator) {
|
||||||
List<LocalizedNode> nodes = new LinkedList<>();
|
|
||||||
accumulateInheritancesTo(nodes, contexts);
|
|
||||||
|
|
||||||
NodeTools.removeEqual(nodes.iterator(), StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
|
||||||
SortedSet<LocalizedNode> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
|
||||||
ret.addAll(nodes);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SortedSet<LocalizedNode> resolveInheritancesMergeTemp(Contexts contexts) {
|
|
||||||
List<LocalizedNode> nodes = new LinkedList<>();
|
|
||||||
accumulateInheritancesTo(nodes, contexts);
|
|
||||||
|
|
||||||
NodeTools.removeEqual(nodes.iterator(), StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
|
|
||||||
SortedSet<LocalizedNode> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
|
||||||
ret.addAll(nodes);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void accumulateInheritancesTo(List<LocalizedNode> accumulator) {
|
|
||||||
InheritanceGraph graph = this.plugin.getInheritanceHandler().getGraph();
|
InheritanceGraph graph = this.plugin.getInheritanceHandler().getGraph();
|
||||||
Iterable<PermissionHolder> traversal = graph.traverse(this.plugin.getConfiguration().get(ConfigKeys.INHERITANCE_TRAVERSAL_ALGORITHM), this);
|
Iterable<PermissionHolder> traversal = graph.traverse(this.plugin.getConfiguration().get(ConfigKeys.INHERITANCE_TRAVERSAL_ALGORITHM), this);
|
||||||
for (PermissionHolder holder : traversal) {
|
for (PermissionHolder holder : traversal) {
|
||||||
@ -431,27 +363,7 @@ public abstract class PermissionHolder {
|
|||||||
return accumulator;
|
return accumulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedSet<LocalizedNode> resolveInheritancesAlmostEqual() {
|
public List<LocalizedNode> getAllEntries(Contexts context) {
|
||||||
List<LocalizedNode> nodes = new LinkedList<>();
|
|
||||||
accumulateInheritancesTo(nodes);
|
|
||||||
|
|
||||||
NodeTools.removeEqual(nodes.iterator(), StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
|
||||||
SortedSet<LocalizedNode> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
|
||||||
ret.addAll(nodes);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SortedSet<LocalizedNode> resolveInheritancesMergeTemp() {
|
|
||||||
List<LocalizedNode> nodes = new LinkedList<>();
|
|
||||||
accumulateInheritancesTo(nodes);
|
|
||||||
|
|
||||||
NodeTools.removeEqual(nodes.iterator(), StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
|
|
||||||
SortedSet<LocalizedNode> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
|
||||||
ret.addAll(nodes);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<LocalizedNode> getAllEntries(Contexts context) {
|
|
||||||
List<LocalizedNode> entries = new LinkedList<>();
|
List<LocalizedNode> entries = new LinkedList<>();
|
||||||
if (context.hasSetting(LookupSetting.RESOLVE_INHERITANCE)) {
|
if (context.hasSetting(LookupSetting.RESOLVE_INHERITANCE)) {
|
||||||
accumulateInheritancesTo(entries, context);
|
accumulateInheritancesTo(entries, context);
|
||||||
@ -472,15 +384,6 @@ public abstract class PermissionHolder {
|
|||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedSet<LocalizedNode> getAllNodes(Contexts context) {
|
|
||||||
List<LocalizedNode> entries = getAllEntries(context);
|
|
||||||
|
|
||||||
NodeTools.removeSamePermission(entries.iterator());
|
|
||||||
SortedSet<LocalizedNode> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
|
||||||
ret.addAll(entries);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Boolean> exportNodesAndShorthand(Contexts context, boolean lowerCase) {
|
public Map<String, Boolean> exportNodesAndShorthand(Contexts context, boolean lowerCase) {
|
||||||
List<LocalizedNode> entries = getAllEntries(context);
|
List<LocalizedNode> entries = getAllEntries(context);
|
||||||
|
|
||||||
@ -489,12 +392,12 @@ public abstract class PermissionHolder {
|
|||||||
for (Node node : entries) {
|
for (Node node : entries) {
|
||||||
String perm = lowerCase ? node.getPermission().toLowerCase() : node.getPermission();
|
String perm = lowerCase ? node.getPermission().toLowerCase() : node.getPermission();
|
||||||
|
|
||||||
if (perms.putIfAbsent(perm, node.getValuePrimitive()) == null) {
|
if (perms.putIfAbsent(perm, node.getValue()) == null) {
|
||||||
if (applyShorthand) {
|
if (applyShorthand) {
|
||||||
List<String> shorthand = node.resolveShorthand();
|
List<String> shorthand = node.resolveShorthand();
|
||||||
if (!shorthand.isEmpty()) {
|
if (!shorthand.isEmpty()) {
|
||||||
for (String s : shorthand) {
|
for (String s : shorthand) {
|
||||||
perms.putIfAbsent(lowerCase ? s.toLowerCase() : s, node.getValuePrimitive());
|
perms.putIfAbsent(lowerCase ? s.toLowerCase() : s, node.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -512,11 +415,11 @@ public abstract class PermissionHolder {
|
|||||||
for (Node node : entries) {
|
for (Node node : entries) {
|
||||||
String perm = lowerCase ? node.getPermission().toLowerCase().intern() : node.getPermission();
|
String perm = lowerCase ? node.getPermission().toLowerCase().intern() : node.getPermission();
|
||||||
|
|
||||||
if (perms.putIfAbsent(perm, node.getValuePrimitive()) == null && applyShorthand) {
|
if (perms.putIfAbsent(perm, node.getValue()) == null && applyShorthand) {
|
||||||
List<String> shorthand = node.resolveShorthand();
|
List<String> shorthand = node.resolveShorthand();
|
||||||
if (!shorthand.isEmpty()) {
|
if (!shorthand.isEmpty()) {
|
||||||
for (String s : shorthand) {
|
for (String s : shorthand) {
|
||||||
perms.putIfAbsent((lowerCase ? s.toLowerCase() : s).intern(), node.getValuePrimitive());
|
perms.putIfAbsent((lowerCase ? s.toLowerCase() : s).intern(), node.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -535,7 +438,7 @@ public abstract class PermissionHolder {
|
|||||||
for (PermissionHolder holder : traversal) {
|
for (PermissionHolder holder : traversal) {
|
||||||
List<Node> nodes = holder.getOwnNodes(context.getContexts());
|
List<Node> nodes = holder.getOwnNodes(context.getContexts());
|
||||||
for (Node node : nodes) {
|
for (Node node : nodes) {
|
||||||
if (!node.getValuePrimitive()) continue;
|
if (!node.getValue()) continue;
|
||||||
if (!node.isMeta() && !node.isPrefix() && !node.isSuffix()) continue;
|
if (!node.isMeta() && !node.isPrefix() && !node.isSuffix()) continue;
|
||||||
|
|
||||||
if (!((context.hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER) || node.isServerSpecific()) && (context.hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD) || node.isWorldSpecific()))) {
|
if (!((context.hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER) || node.isServerSpecific()) && (context.hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD) || node.isWorldSpecific()))) {
|
||||||
@ -564,7 +467,7 @@ public abstract class PermissionHolder {
|
|||||||
for (PermissionHolder holder : traversal) {
|
for (PermissionHolder holder : traversal) {
|
||||||
List<Node> nodes = holder.getOwnNodes();
|
List<Node> nodes = holder.getOwnNodes();
|
||||||
for (Node node : nodes) {
|
for (Node node : nodes) {
|
||||||
if (!node.getValuePrimitive()) continue;
|
if (!node.getValue()) continue;
|
||||||
if (!node.isMeta() && !node.isPrefix() && !node.isSuffix()) continue;
|
if (!node.isMeta() && !node.isPrefix() && !node.isSuffix()) continue;
|
||||||
|
|
||||||
accumulator.accumulateNode(ImmutableLocalizedNode.of(node, holder.getObjectName()));
|
accumulator.accumulateNode(ImmutableLocalizedNode.of(node, holder.getObjectName()));
|
||||||
@ -589,7 +492,7 @@ public abstract class PermissionHolder {
|
|||||||
// we don't call events for transient nodes
|
// we don't call events for transient nodes
|
||||||
boolean transientWork = this.transientNodes.auditTemporaryNodes(null);
|
boolean transientWork = this.transientNodes.auditTemporaryNodes(null);
|
||||||
|
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = enduringData().immutable().values();
|
||||||
Set<Node> removed = new HashSet<>();
|
Set<Node> removed = new HashSet<>();
|
||||||
|
|
||||||
boolean enduringWork = this.enduringNodes.auditTemporaryNodes(removed);
|
boolean enduringWork = this.enduringNodes.auditTemporaryNodes(removed);
|
||||||
@ -598,7 +501,7 @@ public abstract class PermissionHolder {
|
|||||||
invalidateCache();
|
invalidateCache();
|
||||||
|
|
||||||
// call event
|
// call event
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = enduringData().immutable().values();
|
||||||
for (Node r : removed) {
|
for (Node r : removed) {
|
||||||
this.plugin.getEventFactory().handleNodeRemove(r, this, before, after);
|
this.plugin.getEventFactory().handleNodeRemove(r, this, before, after);
|
||||||
}
|
}
|
||||||
@ -636,18 +539,6 @@ public abstract class PermissionHolder {
|
|||||||
return searchForMatch(type, node, equalityPredicate).map(Node::getTristate).orElse(Tristate.UNDEFINED);
|
return searchForMatch(type, node, equalityPredicate).map(Node::getTristate).orElse(Tristate.UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tristate hasPermission(NodeMapType type, Node node) {
|
|
||||||
return hasPermission(type, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tristate hasPermission(Node node, NodeEqualityPredicate equalityPredicate) {
|
|
||||||
return hasPermission(NodeMapType.ENDURING, node, equalityPredicate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tristate hasPermission(Node node) {
|
|
||||||
return hasPermission(NodeMapType.ENDURING, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the holder inherits a node
|
* Check if the holder inherits a node
|
||||||
*
|
*
|
||||||
@ -676,24 +567,20 @@ public abstract class PermissionHolder {
|
|||||||
return searchForInheritedMatch(node, equalityPredicate).getResult();
|
return searchForInheritedMatch(node, equalityPredicate).getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tristate inheritsPermission(Node node) {
|
|
||||||
return inheritsPermission(node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a permission node
|
* Sets a permission node
|
||||||
*
|
*
|
||||||
* @param node the node to set
|
* @param node the node to set
|
||||||
*/
|
*/
|
||||||
public DataMutateResult setPermission(Node node) {
|
public DataMutateResult setPermission(Node node) {
|
||||||
if (hasPermission(NodeMapType.ENDURING, node) != Tristate.UNDEFINED) {
|
if (hasPermission(NodeMapType.ENDURING, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE) != Tristate.UNDEFINED) {
|
||||||
return DataMutateResult.ALREADY_HAS;
|
return DataMutateResult.ALREADY_HAS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = enduringData().immutable().values();
|
||||||
this.enduringNodes.add(node);
|
this.enduringNodes.add(node);
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = enduringData().immutable().values();
|
||||||
|
|
||||||
this.plugin.getEventFactory().handleNodeAdd(node, this, before, after);
|
this.plugin.getEventFactory().handleNodeAdd(node, this, before, after);
|
||||||
return DataMutateResult.SUCCESS;
|
return DataMutateResult.SUCCESS;
|
||||||
@ -720,10 +607,10 @@ public abstract class PermissionHolder {
|
|||||||
Node newNode = node.toBuilder().setExpiry(previous.getExpiryUnixTime() + node.getSecondsTilExpiry()).build();
|
Node newNode = node.toBuilder().setExpiry(previous.getExpiryUnixTime() + node.getSecondsTilExpiry()).build();
|
||||||
|
|
||||||
// Remove the old node & add the new one.
|
// Remove the old node & add the new one.
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = enduringData().immutable().values();
|
||||||
this.enduringNodes.replace(newNode, previous);
|
this.enduringNodes.replace(newNode, previous);
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = enduringData().immutable().values();
|
||||||
|
|
||||||
this.plugin.getEventFactory().handleNodeAdd(newNode, this, before, after);
|
this.plugin.getEventFactory().handleNodeAdd(newNode, this, before, after);
|
||||||
return Maps.immutableEntry(DataMutateResult.SUCCESS, newNode);
|
return Maps.immutableEntry(DataMutateResult.SUCCESS, newNode);
|
||||||
@ -740,10 +627,10 @@ public abstract class PermissionHolder {
|
|||||||
// Only replace if the new expiry time is greater than the old one.
|
// Only replace if the new expiry time is greater than the old one.
|
||||||
if (node.getExpiryUnixTime() > previous.getExpiryUnixTime()) {
|
if (node.getExpiryUnixTime() > previous.getExpiryUnixTime()) {
|
||||||
|
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = enduringData().immutable().values();
|
||||||
this.enduringNodes.replace(node, previous);
|
this.enduringNodes.replace(node, previous);
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = enduringData().immutable().values();
|
||||||
|
|
||||||
this.plugin.getEventFactory().handleNodeAdd(node, this, before, after);
|
this.plugin.getEventFactory().handleNodeAdd(node, this, before, after);
|
||||||
return Maps.immutableEntry(DataMutateResult.SUCCESS, node);
|
return Maps.immutableEntry(DataMutateResult.SUCCESS, node);
|
||||||
@ -764,7 +651,7 @@ public abstract class PermissionHolder {
|
|||||||
* @param node the node to set
|
* @param node the node to set
|
||||||
*/
|
*/
|
||||||
public DataMutateResult setTransientPermission(Node node) {
|
public DataMutateResult setTransientPermission(Node node) {
|
||||||
if (hasPermission(NodeMapType.TRANSIENT, node) != Tristate.UNDEFINED) {
|
if (hasPermission(NodeMapType.TRANSIENT, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE) != Tristate.UNDEFINED) {
|
||||||
return DataMutateResult.ALREADY_HAS;
|
return DataMutateResult.ALREADY_HAS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,14 +666,14 @@ public abstract class PermissionHolder {
|
|||||||
* @param node the node to unset
|
* @param node the node to unset
|
||||||
*/
|
*/
|
||||||
public DataMutateResult unsetPermission(Node node) {
|
public DataMutateResult unsetPermission(Node node) {
|
||||||
if (hasPermission(NodeMapType.ENDURING, node) == Tristate.UNDEFINED) {
|
if (hasPermission(NodeMapType.ENDURING, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE) == Tristate.UNDEFINED) {
|
||||||
return DataMutateResult.LACKS;
|
return DataMutateResult.LACKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = enduringData().immutable().values();
|
||||||
this.enduringNodes.remove(node);
|
this.enduringNodes.remove(node);
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = enduringData().immutable().values();
|
||||||
|
|
||||||
this.plugin.getEventFactory().handleNodeRemove(node, this, before, after);
|
this.plugin.getEventFactory().handleNodeRemove(node, this, before, after);
|
||||||
return DataMutateResult.SUCCESS;
|
return DataMutateResult.SUCCESS;
|
||||||
@ -798,7 +685,7 @@ public abstract class PermissionHolder {
|
|||||||
* @param node the node to unset
|
* @param node the node to unset
|
||||||
*/
|
*/
|
||||||
public DataMutateResult unsetTransientPermission(Node node) {
|
public DataMutateResult unsetTransientPermission(Node node) {
|
||||||
if (hasPermission(NodeMapType.TRANSIENT, node) == Tristate.UNDEFINED) {
|
if (hasPermission(NodeMapType.TRANSIENT, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE) == Tristate.UNDEFINED) {
|
||||||
return DataMutateResult.LACKS;
|
return DataMutateResult.LACKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -808,21 +695,21 @@ public abstract class PermissionHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean inheritsGroup(Group group) {
|
public boolean inheritsGroup(Group group) {
|
||||||
return group.getName().equalsIgnoreCase(this.getObjectName()) || hasPermission(NodeFactory.buildGroupNode(group.getName()).build()).asBoolean();
|
return group.getName().equalsIgnoreCase(this.getObjectName()) || hasPermission(NodeMapType.ENDURING, NodeFactory.buildGroupNode(group.getName()).build(), StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inheritsGroup(Group group, ContextSet contextSet) {
|
public boolean inheritsGroup(Group group, ContextSet contextSet) {
|
||||||
return group.getName().equalsIgnoreCase(this.getObjectName()) || hasPermission(NodeFactory.buildGroupNode(group.getName()).withExtraContext(contextSet).build()).asBoolean();
|
return group.getName().equalsIgnoreCase(this.getObjectName()) || hasPermission(NodeMapType.ENDURING, NodeFactory.buildGroupNode(group.getName()).withExtraContext(contextSet).build(), StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all of the holders permission nodes
|
* Clear all of the holders permission nodes
|
||||||
*/
|
*/
|
||||||
public boolean clearNodes() {
|
public boolean clearNodes() {
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = enduringData().immutable().values();
|
||||||
this.enduringNodes.clear();
|
this.enduringNodes.clear();
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = enduringData().immutable().values();
|
||||||
|
|
||||||
if (before.size() == after.size()) {
|
if (before.size() == after.size()) {
|
||||||
return false;
|
return false;
|
||||||
@ -833,10 +720,10 @@ public abstract class PermissionHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean clearNodes(ContextSet contextSet) {
|
public boolean clearNodes(ContextSet contextSet) {
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = enduringData().immutable().values();
|
||||||
this.enduringNodes.clear(contextSet);
|
this.enduringNodes.clear(contextSet);
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = enduringData().immutable().values();
|
||||||
|
|
||||||
if (before.size() == after.size()) {
|
if (before.size() == after.size()) {
|
||||||
return false;
|
return false;
|
||||||
@ -847,11 +734,11 @@ public abstract class PermissionHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean clearPermissions() {
|
public boolean clearPermissions() {
|
||||||
return removeIf(Node::isRegularPermissionNode);
|
return removeIf(node -> !node.hasTypeData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean clearPermissions(ContextSet contextSet) {
|
public boolean clearPermissions(ContextSet contextSet) {
|
||||||
return removeIf(contextSet, Node::isRegularPermissionNode);
|
return removeIf(contextSet, node -> !node.hasTypeData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean clearParents(boolean giveDefault) {
|
public boolean clearParents(boolean giveDefault) {
|
||||||
@ -893,14 +780,6 @@ public abstract class PermissionHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OptionalInt getWeight() {
|
public OptionalInt getWeight() {
|
||||||
return this.weightCache.get();
|
return OptionalInt.empty();
|
||||||
}
|
|
||||||
|
|
||||||
public Set<HolderReference> getGroupReferences() {
|
|
||||||
return getOwnGroupNodes().stream()
|
|
||||||
.map(Node::getGroupName)
|
|
||||||
.map(String::toLowerCase)
|
|
||||||
.map(GroupReference::of)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,8 @@ import me.lucko.luckperms.api.context.ContextSet;
|
|||||||
import me.lucko.luckperms.common.api.DemotionResults;
|
import me.lucko.luckperms.common.api.DemotionResults;
|
||||||
import me.lucko.luckperms.common.api.PromotionResults;
|
import me.lucko.luckperms.common.api.PromotionResults;
|
||||||
import me.lucko.luckperms.common.api.delegates.model.ApiTrack;
|
import me.lucko.luckperms.common.api.delegates.model.ApiTrack;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.references.Identifiable;
|
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -277,9 +276,9 @@ public final class Track implements Identifiable<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find all groups that are inherited by the user in the exact contexts given and applicable to this track
|
// find all groups that are inherited by the user in the exact contexts given and applicable to this track
|
||||||
List<Node> nodes = user.getEnduringNodes().get(context.makeImmutable()).stream()
|
List<Node> nodes = user.enduringData().immutable().get(context.makeImmutable()).stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.filter(Node::getValuePrimitive)
|
.filter(Node::getValue)
|
||||||
.filter(node -> containsGroup(node.getGroupName()))
|
.filter(node -> containsGroup(node.getGroupName()))
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@ -339,9 +338,9 @@ public final class Track implements Identifiable<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find all groups that are inherited by the user in the exact contexts given and applicable to this track
|
// find all groups that are inherited by the user in the exact contexts given and applicable to this track
|
||||||
List<Node> nodes = user.getEnduringNodes().get(context.makeImmutable()).stream()
|
List<Node> nodes = user.enduringData().immutable().get(context.makeImmutable()).stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.filter(Node::getValuePrimitive)
|
.filter(node -> node.getValue())
|
||||||
.filter(node -> containsGroup(node.getGroupName()))
|
.filter(node -> containsGroup(node.getGroupName()))
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
@ -31,10 +31,6 @@ import me.lucko.luckperms.common.caching.UserCachedData;
|
|||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.primarygroup.PrimaryGroupHolder;
|
import me.lucko.luckperms.common.primarygroup.PrimaryGroupHolder;
|
||||||
import me.lucko.luckperms.common.references.HolderType;
|
|
||||||
import me.lucko.luckperms.common.references.Identifiable;
|
|
||||||
import me.lucko.luckperms.common.references.UserIdentifier;
|
|
||||||
import me.lucko.luckperms.common.references.UserReference;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -161,11 +157,6 @@ public class User extends PermissionHolder implements Identifiable<UserIdentifie
|
|||||||
return this.name != null ? this.name : this.uuid.toString();
|
return this.name != null ? this.name : this.uuid.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserReference toReference() {
|
|
||||||
return UserReference.of(getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HolderType getType() {
|
public HolderType getType() {
|
||||||
return HolderType.USER;
|
return HolderType.USER;
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.references;
|
package me.lucko.luckperms.common.model;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.model.User;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
@ -27,35 +27,21 @@ package me.lucko.luckperms.common.model;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
import me.lucko.luckperms.api.nodetype.types.WeightType;
|
||||||
import me.lucko.luckperms.common.buffers.Cache;
|
import me.lucko.luckperms.common.buffers.Cache;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache instance to supply the weight of a {@link PermissionHolder}.
|
* Cache instance to supply the weight of a {@link PermissionHolder}.
|
||||||
*/
|
*/
|
||||||
public class WeightCache extends Cache<OptionalInt> {
|
public class WeightCache extends Cache<OptionalInt> {
|
||||||
private static final Cache<OptionalInt> NULL = new Cache<OptionalInt>() {
|
|
||||||
@Override
|
|
||||||
protected OptionalInt supply() {
|
|
||||||
return OptionalInt.empty();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static Cache<OptionalInt> getFor(PermissionHolder holder) {
|
|
||||||
if (holder.getType().isUser()) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new WeightCache(((Group) holder));
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Group group;
|
private final Group group;
|
||||||
|
|
||||||
private WeightCache(Group group) {
|
public WeightCache(Group group) {
|
||||||
this.group = group;
|
this.group = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,14 +50,16 @@ public class WeightCache extends Cache<OptionalInt> {
|
|||||||
boolean seen = false;
|
boolean seen = false;
|
||||||
int best = 0;
|
int best = 0;
|
||||||
for (Node n : this.group.getOwnNodes(ImmutableContextSet.empty())) {
|
for (Node n : this.group.getOwnNodes(ImmutableContextSet.empty())) {
|
||||||
Integer weight = NodeFactory.parseWeightNode(n.getPermission());
|
Optional<WeightType> weight = n.getTypeData(WeightType.KEY);
|
||||||
if (weight == null) {
|
if (!weight.isPresent()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!seen || weight > best) {
|
int value = weight.get().getWeight();
|
||||||
|
|
||||||
|
if (!seen || value > best) {
|
||||||
seen = true;
|
seen = true;
|
||||||
best = weight;
|
best = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OptionalInt weight = seen ? OptionalInt.of(best) : OptionalInt.empty();
|
OptionalInt weight = seen ? OptionalInt.of(best) : OptionalInt.empty();
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.node;
|
package me.lucko.luckperms.common.node.comparator;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.HeldPermission;
|
import me.lucko.luckperms.api.HeldPermission;
|
||||||
|
|
@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.node;
|
package me.lucko.luckperms.common.node.comparator;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.utils.CollationKeyCache;
|
import me.lucko.luckperms.common.utils.CollationKeyCache;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user