Cleanup some of the Sponge permission holder implementation code
This commit is contained in:
+1
-1
@@ -298,7 +298,7 @@ public final class ArgumentPermissions {
|
||||
throw new IllegalStateException("Unable to get a User for " + sender.getUuid() + " - " + sender.getName());
|
||||
}
|
||||
|
||||
PermissionCache permissionData = user.getCachedData().getPermissionData(Contexts.of(contextSet, Contexts.global().getSettings()));
|
||||
PermissionCache permissionData = user.getCachedData().getPermissionData(Contexts.global().setContexts(contextSet));
|
||||
return !permissionData.getPermissionValue(NodeFactory.groupNode(targetGroupName), PermissionCheckEvent.Origin.INTERNAL).result().asBoolean();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ public class MetaSetChatMeta extends SharedSubCommand {
|
||||
|
||||
// determine the priority to set at
|
||||
if (priority == Integer.MIN_VALUE) {
|
||||
MetaAccumulator metaAccumulator = holder.accumulateMeta(null, Contexts.of(context, Contexts.global().getSettings()));
|
||||
MetaAccumulator metaAccumulator = holder.accumulateMeta(null, Contexts.global().setContexts(context));
|
||||
metaAccumulator.complete();
|
||||
priority = metaAccumulator.getChatMeta(this.type).keySet().stream().mapToInt(e -> e).max().orElse(0) + 1;
|
||||
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ public class MetaSetTempChatMeta extends SharedSubCommand {
|
||||
|
||||
// determine the priority to set at
|
||||
if (priority == Integer.MIN_VALUE) {
|
||||
MetaAccumulator metaAccumulator = holder.accumulateMeta(null, Contexts.of(context, Contexts.global().getSettings()));
|
||||
MetaAccumulator metaAccumulator = holder.accumulateMeta(null, Contexts.global().setContexts(context));
|
||||
metaAccumulator.complete();
|
||||
priority = metaAccumulator.getChatMeta(this.type).keySet().stream().mapToInt(e -> e).max().orElse(0) + 1;
|
||||
|
||||
|
||||
@@ -29,26 +29,34 @@ import java.util.function.Supplier;
|
||||
|
||||
public enum NodeMapType {
|
||||
|
||||
ENDURING,
|
||||
TRANSIENT;
|
||||
ENDURING {
|
||||
@Override
|
||||
public void run(Runnable enduringTask, Runnable transientTask) {
|
||||
enduringTask.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T supply(Supplier<T> enduringSupplier, Supplier<T> transientSupplier) {
|
||||
return enduringSupplier.get();
|
||||
}
|
||||
},
|
||||
TRANSIENT {
|
||||
@Override
|
||||
public void run(Runnable enduringTask, Runnable transientTask) {
|
||||
transientTask.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T supply(Supplier<T> enduringSupplier, Supplier<T> transientSupplier) {
|
||||
return transientSupplier.get();
|
||||
}
|
||||
};
|
||||
|
||||
// useful methods for fluent/conditional execution
|
||||
|
||||
public void run(Runnable ifEnduring, Runnable ifTransient) {
|
||||
if (this == ENDURING) {
|
||||
ifEnduring.run();
|
||||
} else {
|
||||
ifTransient.run();
|
||||
}
|
||||
}
|
||||
public abstract void run(Runnable enduringTask, Runnable transientTask);
|
||||
|
||||
public <T> T supply(Supplier<T> ifEnduring, Supplier<T> ifTransient) {
|
||||
if (this == ENDURING) {
|
||||
return ifEnduring.get();
|
||||
} else {
|
||||
return ifTransient.get();
|
||||
}
|
||||
}
|
||||
public abstract <T> T supply(Supplier<T> enduringSupplier, Supplier<T> transientSupplier);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user