1
0
mirror of https://github.com/lucko/LuckPerms.git synced 2025-09-01 18:32:33 +02:00

Fix NPE from permission holder initialisation order (#3263)

This commit is contained in:
Luck
2022-01-02 16:58:15 +00:00
parent a53c9fad00
commit f61d9ff9f0
3 changed files with 12 additions and 9 deletions

View File

@@ -37,8 +37,8 @@ public class InheritanceOrigin implements InheritanceOriginMetadata {
private final DataType dataType;
public InheritanceOrigin(PermissionHolderIdentifier origin, DataType dataType) {
this.origin = origin;
this.dataType = dataType;
this.origin = Objects.requireNonNull(origin, "origin");
this.dataType = Objects.requireNonNull(dataType, "dataType");
}
@Override

View File

@@ -110,7 +110,7 @@ public abstract class PermissionHolder {
*
* @see #normalData()
*/
private final RecordedNodeMap normalNodes = new RecordedNodeMap(new NodeMapMutable(this, DataType.NORMAL));
private final RecordedNodeMap normalNodes;
/**
* The holders transient nodes.
@@ -122,12 +122,12 @@ public abstract class PermissionHolder {
*
* @see #transientData()
*/
private final NodeMap transientNodes = new NodeMapMutable(this, DataType.TRANSIENT);
private final NodeMap transientNodes;
/**
* Comparator used to ordering groups when calculating inheritance
*/
private final Comparator<? super PermissionHolder> inheritanceComparator = InheritanceComparator.getFor(this);
private final Comparator<? super PermissionHolder> inheritanceComparator;
/**
* Creates a new instance
@@ -137,6 +137,9 @@ public abstract class PermissionHolder {
protected PermissionHolder(LuckPermsPlugin plugin, String objectName) {
this.plugin = plugin;
this.identifier = new PermissionHolderIdentifier(getType(), objectName);
this.normalNodes = new RecordedNodeMap(new NodeMapMutable(this, DataType.NORMAL));
this.transientNodes = new NodeMapMutable(this, DataType.TRANSIENT);
this.inheritanceComparator = InheritanceComparator.getFor(this);
}
// getters

View File

@@ -36,15 +36,15 @@ public final class PermissionHolderIdentifier implements Identifier {
private final String name;
public PermissionHolderIdentifier(HolderType type, String name) {
this.type = type == HolderType.USER
this.type = Objects.requireNonNull(type, "type") == HolderType.USER
? Identifier.USER_TYPE
: Identifier.GROUP_TYPE;
this.name = name;
this.name = Objects.requireNonNull(name, "name");
}
public PermissionHolderIdentifier(String type, String name) {
this.type = type;
this.name = name;
this.type = Objects.requireNonNull(type, "type");
this.name = Objects.requireNonNull(name, "name");
}
@Override