@Override
 public Map<Subject, Boolean> getAllWithPermission(Set<Context> contexts, String permission) {
   final ImmutableMap.Builder<Subject, Boolean> ret = ImmutableMap.builder();
   for (PEXSubject subject : subjectCache.asMap().values()) {
     Tristate permissionValue =
         subject.getPermissionValue(
             contexts == null ? subject.getActiveContexts() : contexts, permission);
     if (permissionValue != Tristate.UNDEFINED) {
       ret.put(subject, permissionValue.asBoolean());
     }
   }
   return ret.build();
 }
예제 #2
0
  private void loadWorldConfig(
      @Nullable PublicContext context, CommentedConfigurationNode parentNode, boolean wild) {
    for (Permission permission : values()) {
      CommentedConfigurationNode node = parentNode.getNode(permission.toString().toLowerCase());
      boolean def =
          wild ? permission.isAllowedByDefaultOnTheWild() : permission.isAllowedByDefault();
      node.setComment(permission.getDescription() + " [Default:" + def + "]");

      if (context != null) {
        if (!node.isVirtual()) {
          Object value = node.getValue();
          if (value instanceof Boolean) {
            context.setPublicPermission(permission, Tristate.fromBoolean((boolean) value));
            context.setModified(false);
          }
        }
      } else {
        boolean val = node.getBoolean(def);
        if (val != def) {
          if (wild) permission.setAllowedByDefaultOnTheWild(val);
          else permission.setAllowedByDefault(val);
          permission.setModified(false);
        }
      }
    }
  }