mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +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 {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
@ -58,12 +58,19 @@ class NodeBuilder implements Node.Builder {
|
||||
|
||||
NodeBuilder(Node other) {
|
||||
this.permission = other.getPermission();
|
||||
this.value = other.getValuePrimitive();
|
||||
this.override = other.isOverride();
|
||||
this.server = other.getServer().orElse(null);
|
||||
this.world = other.getWorld().orElse(null);
|
||||
this.expireAt = other.isPermanent() ? 0L : other.getExpiryUnixTime();
|
||||
this.extraContexts.addAll(other.getContexts());
|
||||
copyFrom(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node.Builder copyFrom(@Nonnull Node node) {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user