use of org.spongepowered.api.service.permission.NodeTree in project SpongeCommon by SpongePowered.
the class MemorySubjectData method clearFallbackPermissionValues.
@Override
public CompletableFuture<Boolean> clearFallbackPermissionValues() {
boolean anyUpdated = false;
for (final Set<Context> key : this.permissions.keySet()) {
while (true) {
final NodeTree oldTree = this.permissions.get(key);
if (oldTree == null || oldTree.rootValue() == Tristate.UNDEFINED) {
continue;
}
if (this.updateCollection(this.permissions, key, oldTree, oldTree.withRootValue(Tristate.UNDEFINED))) {
anyUpdated = true;
break;
}
}
}
this.onUpdate();
return CompletableFuture.completedFuture(anyUpdated);
}
use of org.spongepowered.api.service.permission.NodeTree in project SpongeCommon by SpongePowered.
the class NodeTreeTest method testCreateFromValues.
@Test
public void testCreateFromValues() throws Exception {
final Map<String, Boolean> testPermissions = new HashMap<>();
testPermissions.put("generate.rainbow", true);
testPermissions.put("generate.sunset", false);
testPermissions.put("generate", true);
testPermissions.put("generate.thunderstorm.explosive", false);
final NodeTree nodes = NodeTreeTest.FACTORY.ofBooleans(testPermissions, Tristate.UNDEFINED);
Assertions.assertEquals(Tristate.TRUE, nodes.get("generate.rainbow"));
Assertions.assertEquals(Tristate.TRUE, nodes.get("generate.rainbow.double"));
Assertions.assertEquals(Tristate.FALSE, nodes.get("generate.sunset"));
Assertions.assertEquals(Tristate.FALSE, nodes.get("generate.sunset.east"));
Assertions.assertEquals(Tristate.TRUE, nodes.get("generate.thunderstorm"));
Assertions.assertEquals(Tristate.FALSE, nodes.get("generate.thunderstorm.explosive"));
Assertions.assertEquals(Tristate.UNDEFINED, nodes.get("random.perm"));
}