Cleanup LuckPermsSubjectData (fixes #194)
This commit is contained in:
@@ -36,6 +36,7 @@ import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.Tristate;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.constants.Patterns;
|
||||
import me.lucko.luckperms.common.core.NodeFactory;
|
||||
import me.lucko.luckperms.common.utils.ShorthandParser;
|
||||
@@ -148,6 +149,9 @@ public class ImmutableNode implements Node {
|
||||
@Getter
|
||||
private final ImmutableContextSet contexts;
|
||||
|
||||
@Getter
|
||||
private final ImmutableContextSet fullContexts;
|
||||
|
||||
// Cached state
|
||||
private final boolean isGroup;
|
||||
private String groupName;
|
||||
@@ -234,6 +238,16 @@ public class ImmutableNode implements Node {
|
||||
|
||||
resolvedShorthand = ImmutableList.copyOf(ShorthandParser.parseShorthand(getPermission()));
|
||||
serializedNode = calculateSerializedNode();
|
||||
|
||||
MutableContextSet fullContexts = this.contexts.mutableCopy();
|
||||
if (isServerSpecific()) {
|
||||
fullContexts.add("server", this.server);
|
||||
}
|
||||
if (isWorldSpecific()) {
|
||||
fullContexts.add("world", this.world);
|
||||
}
|
||||
|
||||
this.fullContexts = fullContexts.makeImmutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -714,6 +714,12 @@ public abstract class PermissionHolder {
|
||||
plugin.getApiProvider().getEventFactory().handleNodeAdd(node, this, before, after);
|
||||
}
|
||||
|
||||
public void setPermissionUnchecked(Node node) {
|
||||
try {
|
||||
setPermission(node);
|
||||
} catch (ObjectAlreadyHasException ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a permission node, applying a temporary modifier if the node is temporary.
|
||||
* @param node the node to set
|
||||
@@ -783,6 +789,12 @@ public abstract class PermissionHolder {
|
||||
return node;
|
||||
}
|
||||
|
||||
public void setPermissionUnchecked(Node node, TemporaryModifier modifier) {
|
||||
try {
|
||||
setPermission(node, modifier);
|
||||
} catch (ObjectAlreadyHasException ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a transient permission node
|
||||
*
|
||||
@@ -806,6 +818,12 @@ public abstract class PermissionHolder {
|
||||
plugin.getApiProvider().getEventFactory().handleNodeAdd(node, this, before, after);
|
||||
}
|
||||
|
||||
public void setTransientPermissionUnchecked(Node node) {
|
||||
try {
|
||||
setTransientPermission(node);
|
||||
} catch (ObjectAlreadyHasException ignored) {}
|
||||
}
|
||||
|
||||
public void setPermission(String node, boolean value) throws ObjectAlreadyHasException {
|
||||
setPermission(buildNode(node).setValue(value).build());
|
||||
}
|
||||
@@ -852,6 +870,12 @@ public abstract class PermissionHolder {
|
||||
plugin.getApiProvider().getEventFactory().handleNodeRemove(node, this, before, after);
|
||||
}
|
||||
|
||||
public void unsetPermissionUnchecked(Node node) {
|
||||
try {
|
||||
unsetPermission(node);
|
||||
} catch (ObjectLacksException ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets a transient permission node
|
||||
*
|
||||
@@ -874,6 +898,12 @@ public abstract class PermissionHolder {
|
||||
plugin.getApiProvider().getEventFactory().handleNodeRemove(node, this, before, after);
|
||||
}
|
||||
|
||||
public void unsetTransientPermissionUnchecked(Node node) {
|
||||
try {
|
||||
unsetTransientPermission(node);
|
||||
} catch (ObjectLacksException ignored) {}
|
||||
}
|
||||
|
||||
public void unsetPermission(String node, boolean temporary) throws ObjectLacksException {
|
||||
unsetPermission(buildNode(node).setExpiry(temporary ? 10L : 0L).build());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user