mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-02 23:53:25 +01:00
Add copyFrom method to Node.Builder
This commit is contained in:
parent
fbe84322b5
commit
8f82ef7eb4
@ -444,6 +444,16 @@ public interface Node {
|
|||||||
*/
|
*/
|
||||||
interface Builder {
|
interface Builder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies the attributes from the given node and applies them to this
|
||||||
|
* builder.
|
||||||
|
*
|
||||||
|
* @param node the node to copy from
|
||||||
|
* @return the builder
|
||||||
|
* @since 4.2
|
||||||
|
*/
|
||||||
|
Builder copyFrom(@Nonnull Node node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of negated for the node.
|
* Sets the value of negated for the node.
|
||||||
*
|
*
|
||||||
|
@ -58,12 +58,19 @@ class NodeBuilder implements Node.Builder {
|
|||||||
|
|
||||||
NodeBuilder(Node other) {
|
NodeBuilder(Node other) {
|
||||||
this.permission = other.getPermission();
|
this.permission = other.getPermission();
|
||||||
this.value = other.getValuePrimitive();
|
copyFrom(other);
|
||||||
this.override = other.isOverride();
|
}
|
||||||
this.server = other.getServer().orElse(null);
|
|
||||||
this.world = other.getWorld().orElse(null);
|
@Override
|
||||||
this.expireAt = other.isPermanent() ? 0L : other.getExpiryUnixTime();
|
public Node.Builder copyFrom(@Nonnull Node node) {
|
||||||
this.extraContexts.addAll(other.getContexts());
|
Objects.requireNonNull(node, "node");
|
||||||
|
this.value = node.getValuePrimitive();
|
||||||
|
this.override = node.isOverride();
|
||||||
|
this.server = node.getServer().orElse(null);
|
||||||
|
this.world = node.getWorld().orElse(null);
|
||||||
|
this.expireAt = node.isPermanent() ? 0L : node.getExpiryUnixTime();
|
||||||
|
this.extraContexts.addAll(node.getContexts());
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
Loading…
Reference in New Issue
Block a user