Update API to 4.1
This commit is contained in:
parent
2889c28815
commit
168e712324
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>luckperms</artifactId>
|
<artifactId>luckperms</artifactId>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -32,22 +32,59 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.concurrent.Immutable;
|
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
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Immutable
|
@Immutable
|
||||||
public interface Node extends Map.Entry<String, Boolean> {
|
public interface Node {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the permission string
|
* Gets the permission string
|
||||||
@ -64,7 +101,6 @@ public interface Node extends Map.Entry<String, Boolean> {
|
|||||||
*
|
*
|
||||||
* @return the permission's value
|
* @return the permission's value
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
default Boolean getValue() {
|
default Boolean getValue() {
|
||||||
return getValuePrimitive();
|
return getValuePrimitive();
|
||||||
@ -394,6 +430,15 @@ public interface Node extends Map.Entry<String, Boolean> {
|
|||||||
return equals(other, StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
|
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
|
* Builds a Node instance
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>luckperms</artifactId>
|
<artifactId>luckperms</artifactId>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>luckperms</artifactId>
|
<artifactId>luckperms</artifactId>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>luckperms</artifactId>
|
<artifactId>luckperms</artifactId>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -52,8 +52,7 @@ public final class ApiNodeFactory implements me.lucko.luckperms.api.NodeFactory
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Node.Builder newBuilderFromExisting(@Nonnull Node other) {
|
public Node.Builder newBuilderFromExisting(@Nonnull Node other) {
|
||||||
Objects.requireNonNull(other, "other");
|
return Objects.requireNonNull(other, "other").toBuilder();
|
||||||
return NodeFactory.builder(other);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -50,7 +50,7 @@ public class ApiPlatformInfo implements PlatformInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getApiVersion() {
|
public double getApiVersion() {
|
||||||
return 4.0;
|
return 4.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -55,7 +55,7 @@ public enum CommandSpec {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
DEBUG("Produce debugging output", "/%s debug"),
|
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.list(
|
||||||
Arg.create("on|record|off|paste", true, "whether to enable/disable logging, or to paste the logged output"),
|
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")
|
Arg.create("filter", false, "the filter to match entries against")
|
||||||
|
@ -686,7 +686,7 @@ public abstract class PermissionHolder {
|
|||||||
Node previous = existing.get();
|
Node previous = existing.get();
|
||||||
|
|
||||||
// Create a new node with the same properties, but add the expiry dates together
|
// 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.
|
// Remove the old node & add the new one.
|
||||||
ImmutableCollection<Node> before = getEnduringNodes().values();
|
ImmutableCollection<Node> before = getEnduringNodes().values();
|
||||||
|
@ -230,12 +230,7 @@ public abstract class ForwardingNode implements Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public Builder toBuilder() {
|
||||||
return delegate().getKey();
|
return delegate().toBuilder();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Boolean setValue(Boolean value) {
|
|
||||||
return delegate().setValue(value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,11 @@ public final class ImmutableNode implements Node {
|
|||||||
this.hashCode = calculateHashCode();
|
this.hashCode = calculateHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new NodeBuilder(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getPermission() {
|
public String getPermission() {
|
||||||
@ -443,16 +448,6 @@ public final class ImmutableNode implements Node {
|
|||||||
public abstract boolean areEqual(@Nonnull ImmutableNode o1, @Nonnull ImmutableNode o2);
|
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) {
|
private static String internString(String s) {
|
||||||
return s == null ? null : s.intern();
|
return s == null ? null : s.intern();
|
||||||
}
|
}
|
||||||
|
@ -62,10 +62,6 @@ public final class NodeFactory {
|
|||||||
return new NodeBuilder(s);
|
return new NodeBuilder(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Node.Builder builder(Node other) {
|
|
||||||
return new NodeBuilder(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Node.Builder buildGroupNode(String groupName) {
|
public static Node.Builder buildGroupNode(String groupName) {
|
||||||
return new NodeBuilder(groupNode(groupName));
|
return new NodeBuilder(groupNode(groupName));
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>luckperms</artifactId>
|
<artifactId>luckperms</artifactId>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<artifactId>luckperms</artifactId>
|
<artifactId>luckperms</artifactId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>api</module>
|
<module>api</module>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>luckperms</artifactId>
|
<artifactId>luckperms</artifactId>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>luckperms</artifactId>
|
<artifactId>luckperms</artifactId>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>luckperms</artifactId>
|
<artifactId>luckperms</artifactId>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>luckperms</artifactId>
|
<artifactId>luckperms</artifactId>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
Loading…
Reference in New Issue
Block a user