Package org.bukkit.configuration

Examples of org.bukkit.configuration.Configuration


// Use global defaults as the defaults for top-level sections
public ConfigurationSection createSection(String path) {
  ConfigurationSection section = super.createSection(path);
  if (section != null && section.getParent() == this) {
   Configuration defaults = this.getDefaults();
   if (defaults != null) {
    for (String key : defaults.getKeys(true))
     section.addDefault(key, defaults.get(key));
   }
  }
  return section;
}
View Full Code Here


    @Override
    protected String buildHeader() {
        String header = options().header();

        if (options().copyHeader()) {
            Configuration def = getDefaults();

            if ((def != null) && (def instanceof FileConfiguration)) {
                FileConfiguration filedefaults = (FileConfiguration) def;
                String defaultsHeader = filedefaults.buildHeader();
View Full Code Here

    }

    public void loadConfig() {

        this.MVPConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
        Configuration portalsDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
        this.MVPConfig.setDefaults(portalsDefaults);
        this.MVPConfig.options().copyDefaults(true);
        this.saveMainConfig();
        this.MVPConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));

        MultiversePortals.UseOnMove = this.MVPConfig.getBoolean("useonmove", true);
        MultiversePortals.EnforcePortalAccess = this.MVPConfig.getBoolean("enforceportalaccess", true);
        this.portalCooldown = this.MVPConfig.getInt("portalcooldown", 1000);
        MultiversePortals.ClearOnRemove = this.MVPConfig.getBoolean("clearonremove", false);
        MultiversePortals.TeleportVehicles = this.MVPConfig.getBoolean("teleportvehicles", true);
        MultiversePortals.FrameMaterials = this.MVPConfig.getIntegerList("framematerials");
        // Migrate useportalaccess -> enforceportalaccess
        if (this.MVPConfig.get("useportalaccess") != null) {
            this.MVPConfig.set("enforceportalaccess", this.MVPConfig.getBoolean("useportalaccess", true));
            this.log(Level.INFO, "Migrating useportalaccess -> enforceportalaccess...");
        }

        if (this.MVPConfig.get("mvportals_default_to_nether") != null) {
            this.MVPConfig.set("portalsdefaulttonether", this.MVPConfig.getBoolean("mvportals_default_to_nether", false));
            this.log(Level.INFO, "Migrating mvportals_default_to_nether -> portalsdefaulttonether...");
        }

        if (this.MVPConfig.get("use_onmove") != null) {
            this.MVPConfig.set("useonmove", this.MVPConfig.getBoolean("use_onmove", false));
            this.log(Level.INFO, "Migrating use_onmove -> useonmove...");
        }

        if (this.MVPConfig.get("portal_cooldown") != null) {
            this.MVPConfig.set("portalcooldown", this.MVPConfig.getInt("portal_cooldown", 1000));
            this.log(Level.INFO, "Migrating portal_cooldown -> portalcooldown...");
        }

        // Remove old properties
        this.MVPConfig.set("mvportals_default_to_nether", null);
        this.MVPConfig.set("useportalaccess", null);
        this.MVPConfig.set("use_onmove", null);
        this.MVPConfig.set("portal_cooldown", null);
        // Update the version
        this.MVPConfig.set("version", portalsDefaults.get("version"));

        this.saveMainConfig();
    }
View Full Code Here

  /**
   * Update configuration files, if needed.
   * @param simpleSpleef
   */
  public void updateConfigurationVersion(SimpleSpleef simpleSpleef) {
    Configuration config = SimpleSpleef.getPlugin().getConfig();
    // check version number in config file
    int version = config.getInt("version", 1);
    // changed?
    boolean changed = false;
   
    // update stuff
    if (version <= 1) {
      config.set("allowDiggingOutsideArena", null); // delete obsolete setting allowDiggingOutsideArena
      changed = true;
    }
    if (version <= 2) {
      //update loose => lose
      if (config.contains("announceLoose")) {
        config.set("announceLose", config.getBoolean("announceLoose", true));
        config.set("announceLoose", null);
      }
      ConfigHelper configHelper = new ConfigHelper();
      // for each arena
      for (String arena : config.getConfigurationSection("arenas").getKeys(false)) {
        ConfigurationSection myConfig = config.getConfigurationSection("arenas." + arena);
        if (myConfig.contains("looseOnTouchBlocks")) {
          myConfig.set("loseOnTouchBlocks", myConfig.getBoolean("looseOnTouchBlocks", true));
          myConfig.set("looseOnTouchBlocks", null);
        }
        if (myConfig.contains("looseBlocks")) {
          if (myConfig.isList("looseBlocks"))
            myConfig.set("loseBlocks", myConfig.getStringList("looseBlocks"));
          else myConfig.set("loseBlocks", myConfig.get("looseBlocks"));
          myConfig.set("looseBlocks", null);
        }
        if (myConfig.contains("looseOnDeath")) {
          myConfig.set("loseOnDeath", myConfig.getBoolean("looseOnDeath", true));
          myConfig.set("looseOnDeath", null);
        }
        if (myConfig.contains("looseOnLogout")) {
          myConfig.set("loseOnLogout", myConfig.getBoolean("looseOnLogout", true));
          myConfig.set("looseOnLogout", null);
        }
        if (myConfig.contains("playersLooseShovelAtGameEnd")) {
          myConfig.set("playersLoseShovelAtGameEnd", myConfig.getBoolean("playersLooseShovelAtGameEnd", true));
          myConfig.set("playersLooseShovelAtGameEnd", null);
        }
        if (myConfig.contains("loose") && myConfig.isConfigurationSection("loose")) {
          // copy loose to lose
          ConfigurationSection newSection = myConfig.createSection("lose");
          configHelper.copySection(newSection, myConfig.getConfigurationSection("loose"));
          myConfig.set("loose", null); // delete old section
        }
        if (myConfig.contains("looseSpawn") && myConfig.isConfigurationSection("looseSpawn")) {
          // copy looseSpawn to loseSpawn
          ConfigurationSection newSection = myConfig.createSection("loseSpawn");
          configHelper.copySection(newSection, myConfig.getConfigurationSection("looseSpawn"));
          myConfig.set("looseSpawn", null); // delete old section
        }
      }
      changed = true;
    }
    // add new update versions here
   
    // increase version number
    if (changed) {
      SimpleSpleef.log.info("[SimpleSpleef] Updating configuration from version " + version + " to version 3.");
      config.set("version", 3);
      SimpleSpleef.getPlugin().saveConfig();
    }
  }
View Full Code Here

     */
    @Override
    public void loadConfigs() {
        // Now grab the Configuration Files.
        this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
        Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
        this.multiverseConfig.setDefaults(coreDefaults);
        this.multiverseConfig.options().copyDefaults(false);
        this.multiverseConfig.options().copyHeader(true);

        MultiverseCoreConfiguration wantedConfig = null;
View Full Code Here

TOP

Related Classes of org.bukkit.configuration.Configuration

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.