mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-27 11:37:35 +01:00
Update API to 4.1
This commit is contained in:
parent
2889c28815
commit
168e712324
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>luckperms</artifactId>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<version>4.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -32,22 +32,59 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* Represents a permission node.
|
||||
* Represents a LuckPerms "node".
|
||||
*
|
||||
* <p>All implementations of this interface must be immutable.</p>
|
||||
* <p>The {@link Node} class encapsulates more than just permission assignments.
|
||||
* Nodes are used to store data about inherited groups, as well as assigned
|
||||
* prefixes, suffixes and meta values.</p>
|
||||
*
|
||||
* <p>Use the {@link NodeFactory} to obtain and construct instances.</p>
|
||||
* <p>Combining these various states into one object (a "node") means that a
|
||||
* holder only has to have one type of data set (a set of nodes) in order to
|
||||
* take on various properties.</p>
|
||||
*
|
||||
* <p>It is recommended that users of the API make use of {@link Stream}s
|
||||
* to manipulate data and obtain the required information.</p>
|
||||
*
|
||||
* <p>This interface provides a number of methods to read the attributes of the
|
||||
* node, as well as methods to query and extract additional state and properties
|
||||
* from these settings.</p>
|
||||
*
|
||||
* <p>Nodes have the following attributes:</p>
|
||||
* <p></p>
|
||||
* <ul>
|
||||
* <li>{@link #getPermission() permission} - the actual permission string</li>
|
||||
* <li>{@link #getValuePrimitive() 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 #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 #getContexts() context} - the additional contexts required for this node to apply </li>
|
||||
* <li>{@link #getExpiry() expiry} - the time when this node should expire</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Nodes can also fall into the following sub categories.</p>
|
||||
* <p></p>
|
||||
* <ul>
|
||||
* <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 #isPrefix() prefix} - represents an assigned prefix</li>
|
||||
* <li>{@link #isSuffix() suffix} - represents an assigned suffix</li>
|
||||
* <li>{@link #isMeta() meta} - represents an assigned meta option</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>The core node state must be immutable in all implementations.</p>
|
||||
*
|
||||
* @see NodeFactory for obtaining and constructing instances.
|
||||
* @since 2.6
|
||||
*/
|
||||
@Immutable
|
||||
public interface Node extends Map.Entry<String, Boolean> {
|
||||
public interface Node {
|
||||
|
||||
/**
|
||||
* Gets the permission string
|
||||
@ -64,7 +101,6 @@ public interface Node extends Map.Entry<String, Boolean> {
|
||||
*
|
||||
* @return the permission's value
|
||||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
default Boolean getValue() {
|
||||
return getValuePrimitive();
|
||||
@ -394,6 +430,15 @@ public interface Node extends Map.Entry<String, Boolean> {
|
||||
return equals(other, StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new builder initially containing the current properties of
|
||||
* this node.
|
||||
*
|
||||
* @return a new builder
|
||||
* @since 4.1
|
||||
*/
|
||||
Builder toBuilder();
|
||||
|
||||
/**
|
||||
* Builds a Node instance
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>luckperms</artifactId>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<version>4.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>luckperms</artifactId>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<version>4.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>luckperms</artifactId>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<version>4.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -52,8 +52,7 @@ public final class ApiNodeFactory implements me.lucko.luckperms.api.NodeFactory
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder newBuilderFromExisting(@Nonnull Node other) {
|
||||
Objects.requireNonNull(other, "other");
|
||||
return NodeFactory.builder(other);
|
||||
return Objects.requireNonNull(other, "other").toBuilder();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -50,7 +50,7 @@ public class ApiPlatformInfo implements PlatformInfo {
|
||||
|
||||
@Override
|
||||
public double getApiVersion() {
|
||||
return 4.0;
|
||||
return 4.1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -55,7 +55,7 @@ public enum CommandSpec {
|
||||
)
|
||||
),
|
||||
DEBUG("Produce debugging output", "/%s debug"),
|
||||
VERBOSE("Manage verbose permission checking", "/%s verbose <true|false> [filter]",
|
||||
VERBOSE("Manage verbose permission checking", "/%s verbose <on|record|off|paste> [filter]",
|
||||
Arg.list(
|
||||
Arg.create("on|record|off|paste", true, "whether to enable/disable logging, or to paste the logged output"),
|
||||
Arg.create("filter", false, "the filter to match entries against")
|
||||
|
@ -686,7 +686,7 @@ public abstract class PermissionHolder {
|
||||
Node previous = existing.get();
|
||||
|
||||
// Create a new node with the same properties, but add the expiry dates together
|
||||
Node newNode = NodeFactory.builder(node).setExpiry(previous.getExpiryUnixTime() + node.getSecondsTilExpiry()).build();
|
||||
Node newNode = node.toBuilder().setExpiry(previous.getExpiryUnixTime() + node.getSecondsTilExpiry()).build();
|
||||
|
||||
// Remove the old node & add the new one.
|
||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
||||
|
@ -230,12 +230,7 @@ public abstract class ForwardingNode implements Node {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return delegate().getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setValue(Boolean value) {
|
||||
return delegate().setValue(value);
|
||||
public Builder toBuilder() {
|
||||
return delegate().toBuilder();
|
||||
}
|
||||
}
|
||||
|
@ -162,6 +162,11 @@ public final class ImmutableNode implements Node {
|
||||
this.hashCode = calculateHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new NodeBuilder(this);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getPermission() {
|
||||
@ -443,16 +448,6 @@ public final class ImmutableNode implements Node {
|
||||
public abstract boolean areEqual(@Nonnull ImmutableNode o1, @Nonnull ImmutableNode o2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setValue(Boolean value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return getPermission();
|
||||
}
|
||||
|
||||
private static String internString(String s) {
|
||||
return s == null ? null : s.intern();
|
||||
}
|
||||
|
@ -62,10 +62,6 @@ public final class NodeFactory {
|
||||
return new NodeBuilder(s);
|
||||
}
|
||||
|
||||
public static Node.Builder builder(Node other) {
|
||||
return new NodeBuilder(other);
|
||||
}
|
||||
|
||||
public static Node.Builder buildGroupNode(String groupName) {
|
||||
return new NodeBuilder(groupNode(groupName));
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>luckperms</artifactId>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<version>4.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<artifactId>luckperms</artifactId>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<version>4.1-SNAPSHOT</version>
|
||||
|
||||
<modules>
|
||||
<module>api</module>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>luckperms</artifactId>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<version>4.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>luckperms</artifactId>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<version>4.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>luckperms</artifactId>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<version>4.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>luckperms</artifactId>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<version>4.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
Loading…
Reference in New Issue
Block a user