Package org.bukkit.configuration

Examples of org.bukkit.configuration.ConfigurationSection


  /**
   * Creates a backend but does not set it as the active backend. Useful for data transfer & such
   * @param backendName Name of the configuration section which describes this backend
   */
  public PermissionBackend createBackend(String backendName) throws PermissionBackendException {
    ConfigurationSection config = this.config.getBackendConfig(backendName);
    String backendType = config.getString("type");
    if (backendType == null) {
      config.set("type", backendType = backendName);
    }

    return PermissionBackend.getBackend(backendType, this, config);
  }
View Full Code Here


  public String getBasedir() {
    return basedir;
  }

  public ConfigurationSection getBackendConfig(String backend) {
    ConfigurationSection section = config.getConfigurationSection("permissions.backends." + backend);
    if (section == null) {
      section = config.createSection("permissions.backends." + backend);
    }
    return section;
  }
View Full Code Here

      backends.add(backend);
      backendMap.put(name, backend);
    }

    // Fallbacks
    ConfigurationSection fallbackSection = backendConfig.getConfigurationSection("fallback");
    if (fallbackSection != null) {
      for (Map.Entry<String, Object> ent : fallbackSection.getValues(false).entrySet()) {
        @SuppressWarnings("SuspiciousMethodCalls")
        PermissionBackend backend = backendMap.get(ent.getValue());
        if (backend == null) {
          throw new PermissionBackendException("Fallback backend type " + ent.getValue() + " is not listed in the backends section of MultiBackend (and must be for this contraption to work)");
        }
View Full Code Here

    this.permissionsFile = new File(baseDir, permissionFilename);
    addSchemaUpdate(new SchemaUpdate(1) {
      @Override
      public void performUpdate() {
        ConfigurationSection userSection = permissions.getConfigurationSection("users");
        if (userSection != null) {
          for (Map.Entry<String, Object> e : userSection.getValues(false).entrySet()) {
            if (e.getValue() instanceof ConfigurationSection) {
              allWorlds((ConfigurationSection) e.getValue());
            }
          }
        }
        ConfigurationSection groupSection = permissions.getConfigurationSection("groups");
        if (groupSection != null) {
          for (Map.Entry<String, Object> e : groupSection.getValues(false).entrySet()) {
            if (e.getValue() instanceof ConfigurationSection) {
              allWorlds((ConfigurationSection) e.getValue());
            }
          }
        }
      }

      private void allWorlds(ConfigurationSection section) {
        singleWorld(section);
        ConfigurationSection worldSection = section.getConfigurationSection("worlds");
        if (worldSection != null) {
          for (Map.Entry<String, Object> e : worldSection.getValues(false).entrySet()) {
            if (e.getValue() instanceof ConfigurationSection) {
              singleWorld((ConfigurationSection) e.getValue());
            }
          }
        }
View Full Code Here

  }

  @Override
  public Map<String, List<String>> getAllWorldInheritance() {
    synchronized (lock) {
      ConfigurationSection worldsSection = this.permissions.getConfigurationSection("worlds");
      if (worldsSection == null) {
        return Collections.emptyMap();
      }

      Map<String, List<String>> ret = new HashMap<>();
      for (String world : worldsSection.getKeys(false)) {
        ret.put(world, getWorldInheritance(world));
      }
      return Collections.unmodifiableMap(ret);
    }
  }
View Full Code Here

    synchronized (lock) {
      if (this.permissions.isConfigurationSection(buildPath("groups", group))) {
        return true;
      }

      ConfigurationSection userSection = this.permissions.getConfigurationSection("groups");
      if (userSection != null) {
        for (String name : userSection.getKeys(false)) {
          if (group.equalsIgnoreCase(name)) {
            return true;
          }
        }
View Full Code Here

  }

  @Override
  public Collection<String> getUserIdentifiers() {
    synchronized (lock) {
      ConfigurationSection users = this.permissions.getConfigurationSection("users");
      return users != null ? users.getKeys(false) : Collections.<String>emptyList();
    }
  }
View Full Code Here

  }

  @Override
  public Collection<String> getUserNames() {
    synchronized (lock) {
      ConfigurationSection users = this.permissions.getConfigurationSection("users");

      if (users == null) {
        return Collections.emptySet();
      }

      Set<String> userNames = new HashSet<>();

      for (Map.Entry<String, Object> entry : users.getValues(false).entrySet()) {
        if (entry.getValue() instanceof ConfigurationSection) {
          ConfigurationSection userSection = (ConfigurationSection) entry.getValue();

          String name = userSection.getString(buildPath("options", "name"));
          if (name != null) {
            userNames.add(name);
          }
        }
      }
View Full Code Here

  }

  @Override
  public Collection<String> getGroupNames() {
    synchronized (lock) {
      ConfigurationSection groups = this.permissions.getConfigurationSection("groups");
      return groups != null ? groups.getKeys(false) : Collections.<String>emptySet();
    }
  }
View Full Code Here

    if (config.isLowerCased(basePath)) {
      entityName = entityName.toLowerCase();
    }
    String nodePath = FileBackend.buildPath(basePath, entityName);

    ConfigurationSection entityNode = this.config.getConfigurationSection(nodePath);

    if (entityNode != null) {
      this.virtual = false;
      if (set) {
        this.nodePath = nodePath;
        this.entityName = entityName;
      }
      return entityNode;
    }

    if (!config.isLowerCased(basePath)) {
      ConfigurationSection users = this.config.getConfigurationSection(basePath);

      if (users != null) {
        for (Map.Entry<String, Object> entry : users.getValues(false).entrySet()) {
          if (entry.getKey().equalsIgnoreCase(entityName)
              && entry.getValue() instanceof ConfigurationSection) {
            if (set) {
              this.nodePath = FileBackend.buildPath(basePath, entry.getKey());
              this.entityName = entry.getKey();
View Full Code Here

TOP

Related Classes of org.bukkit.configuration.ConfigurationSection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.