Package org.bukkit.configuration

Examples of org.bukkit.configuration.ConfigurationSection


    public MySQLDB(Fe plugin) {
        super(plugin, true);
    }

    protected Connection getNewConnection() {
        ConfigurationSection config = getConfigSection();

        setAccountTable(config.getString("tables.accounts"));

        setAccountsColumnUser(config.getString("columns.accounts.username"));

        setAccountsColumnMoney(config.getString("columns.accounts.money"));

        setAccountsColumnUUID(config.getString("columns.accounts.uuid"));

        try {
            Class.forName("com.mysql.jdbc.Driver");

            String url = "jdbc:mysql://" + config.getString("host") + ":" + config.getString("port") + "/" + config.getString("database");

            return DriverManager.getConnection(url, config.getString("user"), config.getString("password"));
        } catch (Exception e) {
            return null;
        }
    }
View Full Code Here


            return null;
        }
    }

    private ConfigurationSection getSection(ConfigurationSection parent, String childName) {
        ConfigurationSection child = parent.getConfigurationSection(childName);

        if (child == null) {
            child = parent.createSection(childName);
        }
View Full Code Here

        section.addDefault("password", "minecraft");

        section.addDefault("database", "Fe");

        ConfigurationSection tables = getSection(section, "tables");

        tables.addDefault("accounts", "fe_accounts");

        ConfigurationSection columns = getSection(section, "columns");

        ConfigurationSection columnsAccounts = getSection(columns, "accounts");

        columnsAccounts.addDefault("username", "name");

        columnsAccounts.addDefault("money", "money");

        columnsAccounts.addDefault("uuid", "uuid");
    }
View Full Code Here

        databases.add(new MongoDB(this));

        for (Database database : databases) {
            String name = database.getConfigName();

            ConfigurationSection section = getConfig().getConfigurationSection(name);

            if (section == null) {
                section = getConfig().createSection(name);
            }

            database.getConfigDefaults(section);

            if (section.getKeys(false).isEmpty()) {
                getConfig().set(name, null);
            }
        }

        getConfig().options().copyDefaults(true);
View Full Code Here

    // the border bypass list used to be stored as list of names rather than UUIDs; wipe that old list so the data won't be automatically saved back to the config file again
    if (cfgVersion < 11)
      cfg.set("bypass-list", null);

    ConfigurationSection worlds = cfg.getConfigurationSection("worlds");
    if (worlds != null)
    {
      Set<String> worldNames = worlds.getKeys(false);

      for(String worldName : worldNames)
      {
        ConfigurationSection bord = worlds.getConfigurationSection(worldName);

        // we're swapping "<" to "." at load since periods denote configuration nodes without a working way to change that, so world names with periods wreak havoc and are thus modified for storage
        if (cfgVersion > 3)
          worldName = worldName.replace("<", ".");

        // backwards compatibility for config from before elliptical/rectangular borders were supported
        if (bord.isSet("radius") && !bord.isSet("radiusX"))
        {
          int radius = bord.getInt("radius");
          bord.set("radiusX", radius);
          bord.set("radiusZ", radius);
        }

        Boolean overrideShape = (Boolean) bord.get("shape-round");
        boolean wrap = (boolean) bord.getBoolean("wrapping", false);
        BorderData border = new BorderData(bord.getDouble("x", 0), bord.getDouble("z", 0), bord.getInt("radiusX", 0), bord.getInt("radiusZ", 0), overrideShape, wrap);
        borders.put(worldName, border);
        logConfig(BorderDescription(worldName));
      }
    }

    // if we have an unfinished fill task stored from a previous run, load it up
    ConfigurationSection storedFillTask = cfg.getConfigurationSection("fillTask");
    if (storedFillTask != null)
    {
      String worldName = storedFillTask.getString("world");
      int fillDistance = storedFillTask.getInt("fillDistance", 176);
      int chunksPerRun = storedFillTask.getInt("chunksPerRun", 5);
      int tickFrequency = storedFillTask.getInt("tickFrequency", 20);
      int fillX = storedFillTask.getInt("x", 0);
      int fillZ = storedFillTask.getInt("z", 0);
      int fillLength = storedFillTask.getInt("length", 0);
      int fillTotal = storedFillTask.getInt("total", 0);
      boolean forceLoad = storedFillTask.getBoolean("forceLoad", false);
      RestoreFillTask(worldName, fillDistance, chunksPerRun, tickFrequency, fillX, fillZ, fillLength, fillTotal, forceLoad);
      save(false);
    }

    if (logIt)
View Full Code Here

    FileConfiguration config = plugin.getConfig();
    config.options().header("CityWorld Plugin Options");
    config.options().copyDefaults(true);
   
    // get the right section
    ConfigurationSection section = null;
   
    // see if we can find the specific world
    if (config.isConfigurationSection(worldname))
      section = config.getConfigurationSection(worldname);
   
    // if not then create it
    if (section == null)
      section = config.createSection(worldname);
   
    /* Create a config in the world's folder
     * Find the generation section
     * Does the global config contain a world section?
     *   Load from that world section
     *   Copy that world section over to the generation section of the world's config
     *   Delete the world section in the global config
     *   Save the global config
     * Read from the generation section
     * Save the generation section
     */
   
    // did we get a section?
    if (section != null) {
     
      // create items stacks
     
      //===========================================================================
      // set up the defaults if needed
      section.addDefault(tagIncludeRoads, includeRoads);
      section.addDefault(tagIncludeRoundabouts, includeRoundabouts);
      section.addDefault(tagIncludeSewers, includeSewers);
      section.addDefault(tagIncludeCisterns, includeCisterns);
      section.addDefault(tagIncludeBasements, includeBasements);
      section.addDefault(tagIncludeMines, includeMines);
      section.addDefault(tagIncludeBunkers, includeBunkers);
      section.addDefault(tagIncludeBuildings, includeBuildings);
      section.addDefault(tagIncludeHouses, includeHouses);
      section.addDefault(tagIncludeFarms, includeFarms);
     
      section.addDefault(tagIncludeCaves, includeCaves);
      section.addDefault(tagIncludeLavaFields, includeLavaFields);
      section.addDefault(tagIncludeSeas, includeSeas);
      section.addDefault(tagIncludeMountains, includeMountains);
      section.addDefault(tagIncludeOres, includeOres);
     
      section.addDefault(tagTreasuresInSewers, treasuresInSewers);
      section.addDefault(tagSpawnersInSewers, spawnersInSewers);
      section.addDefault(tagTreasuresInMines, treasuresInMines);
      section.addDefault(tagSpawnersInMines, spawnersInMines);
      section.addDefault(tagTreasuresInBunkers, treasuresInBunkers);
      section.addDefault(tagSpawnersInBunkers, spawnersInBunkers);
     
      section.addDefault(tagIncludeUndergroundFluids, includeUndergroundFluids);
      section.addDefault(tagIncludeAbovegroundFluids, includeAbovegroundFluids);
      section.addDefault(tagIncludeWorkingLights, includeWorkingLights);
      section.addDefault(tagIncludeNamedRoads, includeNamedRoads);
      section.addDefault(tagIncludeDecayedRoads, includeDecayedRoads);
      section.addDefault(tagIncludeDecayedBuildings, includeDecayedBuildings);
      section.addDefault(tagIncludeDecayedNature, includeDecayedNature);
      section.addDefault(tagIncludeBuildingInteriors, includeBuildingInteriors);
      section.addDefault(tagIncludeFloatingSubsurface, includeFloatingSubsurface);
     
      section.addDefault(tagForceLoadWorldEdit, forceLoadWorldEdit);
      section.addDefault(tagBroadcastSpecialPlaces, broadcastSpecialPlaces);

      section.addDefault(tagTreeStyle, TreeStyle.NORMAL.name());
     
      section.addDefault(tagCenterPointOfChunkRadiusX, centerPointOfChunkRadiusX);
      section.addDefault(tagCenterPointOfChunkRadiusZ, centerPointOfChunkRadiusZ);
      section.addDefault(tagConstructChunkRadius, constructChunkRadius);
      section.addDefault(tagRoadChunkRadius, roadChunkRadius);
      section.addDefault(tagCityChunkRadius, cityChunkRadius);
     
      //===========================================================================
      // now read the bits
      includeRoads = section.getBoolean(tagIncludeRoads, includeRoads);
      includeRoundabouts = section.getBoolean(tagIncludeRoundabouts, includeRoundabouts);
      includeSewers = section.getBoolean(tagIncludeSewers, includeSewers);
      includeCisterns = section.getBoolean(tagIncludeCisterns, includeCisterns);
      includeBasements = section.getBoolean(tagIncludeBasements, includeBasements);
      includeMines = section.getBoolean(tagIncludeMines, includeMines);
      includeBunkers = section.getBoolean(tagIncludeBunkers, includeBunkers);
      includeBuildings = section.getBoolean(tagIncludeBuildings, includeBuildings);
      includeHouses = section.getBoolean(tagIncludeHouses, includeHouses);
      includeFarms = section.getBoolean(tagIncludeFarms, includeFarms);
     
      includeCaves = section.getBoolean(tagIncludeCaves, includeCaves);
      includeLavaFields = section.getBoolean(tagIncludeLavaFields, includeLavaFields);
      includeSeas = section.getBoolean(tagIncludeSeas, includeSeas);
      includeMountains = section.getBoolean(tagIncludeMountains, includeMountains);
      includeOres = section.getBoolean(tagIncludeOres, includeOres);

      treasuresInSewers = section.getBoolean(tagTreasuresInSewers, treasuresInSewers);
      spawnersInSewers = section.getBoolean(tagSpawnersInSewers, spawnersInSewers);
      treasuresInMines = section.getBoolean(tagTreasuresInMines, treasuresInMines);
      spawnersInMines = section.getBoolean(tagSpawnersInMines, spawnersInMines);
      treasuresInBunkers = section.getBoolean(tagTreasuresInBunkers, treasuresInBunkers);
      spawnersInBunkers = section.getBoolean(tagSpawnersInBunkers, spawnersInBunkers);
     
      includeUndergroundFluids = section.getBoolean(tagIncludeUndergroundFluids, includeUndergroundFluids);
      includeAbovegroundFluids = section.getBoolean(tagIncludeAbovegroundFluids, includeAbovegroundFluids);
      includeWorkingLights = section.getBoolean(tagIncludeWorkingLights, includeWorkingLights);
      includeNamedRoads = section.getBoolean(tagIncludeNamedRoads, includeNamedRoads);
      includeDecayedRoads = section.getBoolean(tagIncludeDecayedRoads, includeDecayedRoads);
      includeDecayedBuildings = section.getBoolean(tagIncludeDecayedBuildings, includeDecayedBuildings);
      includeDecayedNature = section.getBoolean(tagIncludeDecayedNature, includeDecayedNature);
      includeBuildingInteriors = section.getBoolean(tagIncludeBuildingInteriors, includeBuildingInteriors);
      includeFloatingSubsurface = section.getBoolean(tagIncludeFloatingSubsurface, includeFloatingSubsurface);
     
      forceLoadWorldEdit = section.getBoolean(tagForceLoadWorldEdit, forceLoadWorldEdit);
      broadcastSpecialPlaces = section.getBoolean(tagBroadcastSpecialPlaces, broadcastSpecialPlaces);
     
      treeStyle = TreeProvider.toTreeStyle(section.getString(tagTreeStyle, treeStyle.name()), treeStyle);

      centerPointOfChunkRadiusX = section.getInt(tagCenterPointOfChunkRadiusX, centerPointOfChunkRadiusX);
      centerPointOfChunkRadiusZ = section.getInt(tagCenterPointOfChunkRadiusZ, centerPointOfChunkRadiusZ);
      centerPointOfChunkRadius = new Vector(centerPointOfChunkRadiusX, 0, centerPointOfChunkRadiusZ);
      constructChunkRadius = Math.min(Integer.MAX_VALUE, Math.max(0, section.getInt(tagConstructChunkRadius, constructChunkRadius)));
      checkConstructRange = constructChunkRadius > 0 && constructChunkRadius < Integer.MAX_VALUE;
     
      roadChunkRadius = Math.min(constructChunkRadius, Math.max(0, section.getInt(tagRoadChunkRadius, roadChunkRadius)));
      checkRoadRange = roadChunkRadius > 0 && roadChunkRadius < Integer.MAX_VALUE;
      if (roadChunkRadius == 0) {
        includeRoads = false;
        includeSewers = false;
      }

      cityChunkRadius = Math.min(roadChunkRadius, Math.max(0, section.getInt(tagCityChunkRadius, cityChunkRadius)));
      checkCityRange = cityChunkRadius > 0 && cityChunkRadius < Integer.MAX_VALUE;
      if (cityChunkRadius == 0) {
        includeCisterns = false;
        includeBasements = false;
        includeMines = false;
        includeBunkers = false;
        includeBuildings = false;
        includeHouses = false;
        includeFarms = false;
      }
     
      //===========================================================================
      // validate settings against world style settings
      validateSettingsAgainstWorldStyle(generator);
     
      //===========================================================================
      // write things back out with corrections
      section.set(tagIncludeRoads, includeRoads);
      section.set(tagIncludeRoundabouts, includeRoundabouts);
      section.set(tagIncludeSewers, includeSewers);
      section.set(tagIncludeCisterns, includeCisterns);
      section.set(tagIncludeBasements, includeBasements);
      section.set(tagIncludeMines, includeMines);
      section.set(tagIncludeBunkers, includeBunkers);
      section.set(tagIncludeBuildings, includeBuildings);
      section.set(tagIncludeHouses, includeHouses);
      section.set(tagIncludeFarms, includeFarms);
     
      section.set(tagIncludeCaves, includeCaves);
      section.set(tagIncludeLavaFields, includeLavaFields);
      section.set(tagIncludeSeas, includeSeas);
      section.set(tagIncludeMountains, includeMountains);
      section.set(tagIncludeOres, includeOres);
     
      section.set(tagTreasuresInSewers, treasuresInSewers);
      section.set(tagSpawnersInSewers, spawnersInSewers);
      section.set(tagTreasuresInMines, treasuresInMines);
      section.set(tagSpawnersInMines, spawnersInMines);
      section.set(tagTreasuresInBunkers, treasuresInBunkers);
      section.set(tagSpawnersInBunkers, spawnersInBunkers);
     
      section.set(tagIncludeUndergroundFluids, includeUndergroundFluids);
      section.set(tagIncludeAbovegroundFluids, includeAbovegroundFluids);
      section.set(tagIncludeWorkingLights, includeWorkingLights);
      section.set(tagIncludeNamedRoads, includeNamedRoads);
      section.set(tagIncludeDecayedRoads, includeDecayedRoads);
      section.set(tagIncludeDecayedBuildings, includeDecayedBuildings);
      section.set(tagIncludeDecayedNature, includeDecayedNature);
      section.set(tagIncludeBuildingInteriors, includeBuildingInteriors);
      section.set(tagIncludeFloatingSubsurface, includeFloatingSubsurface);
     
      section.set(tagForceLoadWorldEdit, forceLoadWorldEdit);
      section.set(tagBroadcastSpecialPlaces, broadcastSpecialPlaces);
     
      section.set(tagTreeStyle, treeStyle.name());

      section.set(tagCenterPointOfChunkRadiusX, centerPointOfChunkRadiusX);
      section.set(tagCenterPointOfChunkRadiusZ, centerPointOfChunkRadiusZ);
      section.set(tagConstructChunkRadius, constructChunkRadius);
      section.set(tagRoadChunkRadius, roadChunkRadius);
      section.set(tagCityChunkRadius, cityChunkRadius);
     
      //===========================================================================
      // note the depreciations
      deprecateOption(section, "IncludeWoolRoads", "DEPRECATED: CityWorld now uses stained clay and quartz for roads");
      deprecateOption(section, "IncludePavedRoads", "DEPRECATED: See deprecated note for IncludeWoolRoads");
View Full Code Here

        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;
View Full Code Here

   * @see de.beimax.simplespleef.statistics.StatisticsModule#getStatistics(org.bukkit.entity.Player)
   */
  @Override
  public HashMap<String, Object> getStatistics(String player) {
    // get config section
    ConfigurationSection playerSection = statistics.getConfigurationSection("players." + player);
   
    // is it null?
    if (playerSection == null) return null;
   
    // create hashmap
    HashMap<String, Object> map = new HashMap<String, Object>();
    // populate with values
    map.put("gamesCount", playerSection.getInt("gamesCount", 0));
    map.put("gamesLost", playerSection.getInt("gamesLost", 0));
    map.put("gamesWon", playerSection.getInt("gamesWon", 0));
    map.put("lastGameTick", playerSection.getLong("lastGameTick", -1));

    return map;
  }
View Full Code Here

   * @see de.beimax.simplespleef.statistics.StatisticsModule#getStatistics(de.beimax.simplespleef.game.Game)
   */
  @Override
  public HashMap<String, Object> getStatistics(Game game) {
    // get config section
    ConfigurationSection arenaSection = statistics.getConfigurationSection("arenas." + game.getId());
   
    // is it null?
    if (arenaSection == null) return null;

    // create hashmap
    HashMap<String, Object> map = new HashMap<String, Object>();
    // populate with values
    map.put("gamesCount", arenaSection.getInt("gamesCount", 0));
    map.put("lastGamePlayers", arenaSection.getInt("lastGamePlayers", 0));
    map.put("gamesTotalPlayers", arenaSection.getInt("gamesTotalPlayers", 0));
    map.put("lastGameStartedAt", arenaSection.getLong("lastGameStartedAt", 0));
    map.put("lastGameFinishedAt", arenaSection.getLong("lastGameFinishedAt", 0));
    map.put("lastGameLength", arenaSection.getInt("lastGameLength", 0));
    map.put("gamesTotalLength", arenaSection.getInt("gamesTotalLength", 0));

    return map;
  }
View Full Code Here

  private List<TopTenEntry> getTopTen(String key) {
    TreeSet<TopTenEntry> topTenList = new TreeSet<TopTenEntry>(TopTenEntry.getAscendingComparator());
    if (statistics == null || statistics.getConfigurationSection(key) == null) return null; // avoid NPEs
    // get list of all gamers
    for (String playerName : statistics.getConfigurationSection(key).getKeys(false)) {
      ConfigurationSection playerSection = statistics.getConfigurationSection(key + "." + playerName);

      TopTenEntry topTenEntry = new TopTenEntry();
      topTenEntry.player = playerName;
      topTenEntry.games = playerSection.getInt("gamesCount", 0);
      topTenEntry.lost = playerSection.getInt("gamesLost", 0);
      topTenEntry.won = playerSection.getInt("gamesWon", 0);
     
      topTenList.add(topTenEntry);
    }

    // get top 10
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.