mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-08-31 10:01:45 +02:00
Include whether a node is normal/transient in InheritanceOriginMetadata
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
package net.luckperms.api.node.metadata.types;
|
package net.luckperms.api.node.metadata.types;
|
||||||
|
|
||||||
import net.luckperms.api.model.PermissionHolder;
|
import net.luckperms.api.model.PermissionHolder;
|
||||||
|
import net.luckperms.api.model.data.DataType;
|
||||||
import net.luckperms.api.node.Node;
|
import net.luckperms.api.node.Node;
|
||||||
import net.luckperms.api.node.metadata.NodeMetadataKey;
|
import net.luckperms.api.node.metadata.NodeMetadataKey;
|
||||||
|
|
||||||
@@ -56,6 +57,15 @@ public interface InheritanceOriginMetadata {
|
|||||||
*/
|
*/
|
||||||
PermissionHolder.@NonNull Identifier getOrigin();
|
PermissionHolder.@NonNull Identifier getOrigin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link DataType type} of the {@link net.luckperms.api.model.data.NodeMap}
|
||||||
|
* the node was inherited from.
|
||||||
|
*
|
||||||
|
* @return the type of the NodeMap the node was inherited from.
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
@NonNull DataType getDataType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets whether the associated node was inherited from another holder.
|
* Gets whether the associated node was inherited from another holder.
|
||||||
*
|
*
|
||||||
|
@@ -26,19 +26,27 @@
|
|||||||
package me.lucko.luckperms.common.model;
|
package me.lucko.luckperms.common.model;
|
||||||
|
|
||||||
import net.luckperms.api.model.PermissionHolder;
|
import net.luckperms.api.model.PermissionHolder;
|
||||||
|
import net.luckperms.api.model.data.DataType;
|
||||||
import net.luckperms.api.node.metadata.types.InheritanceOriginMetadata;
|
import net.luckperms.api.node.metadata.types.InheritanceOriginMetadata;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
public class InheritanceOrigin implements InheritanceOriginMetadata {
|
public class InheritanceOrigin implements InheritanceOriginMetadata {
|
||||||
private final PermissionHolder.Identifier location;
|
private final PermissionHolder.Identifier location;
|
||||||
|
private final DataType dataType;
|
||||||
|
|
||||||
public InheritanceOrigin(PermissionHolder.Identifier location) {
|
public InheritanceOrigin(PermissionHolder.Identifier location, DataType dataType) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
this.dataType = dataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionHolder.@NonNull Identifier getOrigin() {
|
public PermissionHolder.@NonNull Identifier getOrigin() {
|
||||||
return this.location;
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull DataType getDataType() {
|
||||||
|
return this.dataType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -111,7 +111,7 @@ public abstract class PermissionHolder {
|
|||||||
*
|
*
|
||||||
* @see #normalData()
|
* @see #normalData()
|
||||||
*/
|
*/
|
||||||
private final RecordedNodeMap normalNodes = new RecordedNodeMap(new NodeMapMutable(this));
|
private final RecordedNodeMap normalNodes = new RecordedNodeMap(new NodeMapMutable(this, DataType.NORMAL));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The holders transient nodes.
|
* The holders transient nodes.
|
||||||
@@ -123,7 +123,7 @@ public abstract class PermissionHolder {
|
|||||||
*
|
*
|
||||||
* @see #transientData()
|
* @see #transientData()
|
||||||
*/
|
*/
|
||||||
private final NodeMap transientNodes = new NodeMapMutable(this);
|
private final NodeMap transientNodes = new NodeMapMutable(this, DataType.TRANSIENT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comparator used to ordering groups when calculating inheritance
|
* Comparator used to ordering groups when calculating inheritance
|
||||||
|
@@ -35,6 +35,7 @@ import me.lucko.luckperms.common.node.comparator.NodeComparator;
|
|||||||
import net.luckperms.api.context.ContextSatisfyMode;
|
import net.luckperms.api.context.ContextSatisfyMode;
|
||||||
import net.luckperms.api.context.ContextSet;
|
import net.luckperms.api.context.ContextSet;
|
||||||
import net.luckperms.api.context.ImmutableContextSet;
|
import net.luckperms.api.context.ImmutableContextSet;
|
||||||
|
import net.luckperms.api.model.data.DataType;
|
||||||
import net.luckperms.api.node.Node;
|
import net.luckperms.api.node.Node;
|
||||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||||
import net.luckperms.api.node.metadata.types.InheritanceOriginMetadata;
|
import net.luckperms.api.node.metadata.types.InheritanceOriginMetadata;
|
||||||
@@ -89,9 +90,11 @@ public class NodeMapMutable extends NodeMapBase {
|
|||||||
private final Lock lock = new ReentrantLock();
|
private final Lock lock = new ReentrantLock();
|
||||||
|
|
||||||
protected final PermissionHolder holder;
|
protected final PermissionHolder holder;
|
||||||
|
private final DataType type;
|
||||||
|
|
||||||
public NodeMapMutable(PermissionHolder holder) {
|
public NodeMapMutable(PermissionHolder holder, DataType type) {
|
||||||
this.holder = holder;
|
this.holder = holder;
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -115,7 +118,7 @@ public class NodeMapMutable extends NodeMapBase {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
return node.toBuilder().withMetadata(InheritanceOriginMetadata.KEY, new InheritanceOrigin(this.holder.getIdentifier())).build();
|
return node.toBuilder().withMetadata(InheritanceOriginMetadata.KEY, new InheritanceOrigin(this.holder.getIdentifier(), this.type)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -155,7 +155,7 @@ public class CalculatedSubjectData implements LPSubjectData {
|
|||||||
.permission(key)
|
.permission(key)
|
||||||
.value(value)
|
.value(value)
|
||||||
.context(entry.getKey())
|
.context(entry.getKey())
|
||||||
.withMetadata(InheritanceOriginMetadata.KEY, new InheritanceOrigin(this.parentSubject.getIdentifier()))
|
.withMetadata(InheritanceOriginMetadata.KEY, new InheritanceOrigin(this.parentSubject.getIdentifier(), this.type))
|
||||||
.build();
|
.build();
|
||||||
nodeMap.put(key, node);
|
nodeMap.put(key, node);
|
||||||
});
|
});
|
||||||
@@ -320,7 +320,7 @@ public class CalculatedSubjectData implements LPSubjectData {
|
|||||||
.key(key)
|
.key(key)
|
||||||
.value(value)
|
.value(value)
|
||||||
.context(entry.getKey())
|
.context(entry.getKey())
|
||||||
.withMetadata(InheritanceOriginMetadata.KEY, new InheritanceOrigin(this.parentSubject.getIdentifier()))
|
.withMetadata(InheritanceOriginMetadata.KEY, new InheritanceOrigin(this.parentSubject.getIdentifier(), this.type))
|
||||||
.build();
|
.build();
|
||||||
nodeMap.put(key, node);
|
nodeMap.put(key, node);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user