Package org.bukkit.configuration.file

Examples of org.bukkit.configuration.file.YamlConfiguration


  private final FileConfiguration config;
  private final File file;

  public ConfigurationHandler(String fileName) {
    this.file = new File(fileName);
    this.config = new YamlConfiguration();
    if (!file.exists()) {
      create();
      save();
    } else {
      load();
View Full Code Here


 
  @Override
  protected void load(WorldGenerator generator, File file) throws Exception {
   
    // prepare to read the meta data
    YamlConfiguration metaYaml = new YamlConfiguration();
    metaYaml.options().header("CityWorld/WorldEdit schematic configuration");
    metaYaml.options().copyDefaults(true);
   
    // add the defaults
    metaYaml.addDefault(tagGroundLevelY, groundLevelY);
    metaYaml.addDefault(tagFlipableX, flipableX);
    metaYaml.addDefault(tagFlipableZ, flipableZ);
//    metaYaml.addDefault(tagScalableX, ScalableX);
//    metaYaml.addDefault(tagScalableZ, ScalableZ);
//    metaYaml.addDefault(tagScalableY, ScalableY);
//    metaYaml.addDefault(tagFloorHeightY, FloorHeightY);
    metaYaml.addDefault(tagOddsOfAppearance, oddsOfAppearance);
    metaYaml.addDefault(tagBroadcastLocation, broadcastLocation);
    metaYaml.addDefault(tagDecayable, decayable);
   
    // start reading it
    File metaFile = new File(file.getAbsolutePath() + metaExtension);
    if (metaFile.exists()) {
      metaYaml.load(metaFile);
      groundLevelY = Math.max(0, metaYaml.getInt(tagGroundLevelY, groundLevelY));
      flipableX = metaYaml.getBoolean(tagFlipableX, flipableX);
      flipableZ = metaYaml.getBoolean(tagFlipableZ, flipableZ);
//      ScalableX = metaYaml.getBoolean(tagScalableX, ScalableX) && sizeX == 3;
//      ScalableZ = metaYaml.getBoolean(tagScalableZ, ScalableZ) && sizeZ == 3;
//      ScalableY = metaYaml.getBoolean(tagScalableY, ScalableY);
//      FloorHeightY = Math.max(2, Math.min(16, metaYaml.getInt(tagFloorHeightY, FloorHeightY)));
      oddsOfAppearance = Math.max(0.0, Math.min(1.0, metaYaml.getDouble(tagOddsOfAppearance, oddsOfAppearance)));
      broadcastLocation = metaYaml.getBoolean(tagBroadcastLocation, broadcastLocation);
      decayable = metaYaml.getBoolean(tagDecayable, decayable);
    }
   
    // load the actual blocks
    CuboidClipboard cuboid = SchematicFormat.getFormat(file).load(file);
   
    // how big is it?
    sizeX = cuboid.getWidth();
    sizeZ = cuboid.getLength();
    sizeY = cuboid.getHeight();
   
    //TODO Validate the size
   
    // try and save the meta data if we can
    try {
      metaYaml.save(metaFile);
    } catch (IOException e) {
     
      // we can recover from this... so eat it!
      generator.reportException("[WorldEdit] Could not resave " + metaFile.getAbsolutePath(), e);
    }
View Full Code Here

    statisticsFile = new File(SimpleSpleef.getPlugin().getDataFolder(), "statistics.yml");
   
    // does the file exist - no
    if (!statisticsFile.exists()) {
      SimpleSpleef.log.info("[SimpleSpleef] Using flat file statistics - creating new file.");
      statistics = new YamlConfiguration();
      try {
        statistics.save(statisticsFile);
      } catch (IOException e) {
        SimpleSpleef.log.severe("[SimpleSpleef] Could not create statistics file. Error: " + e.getMessage());
      }
View Full Code Here

  public boolean createNewArena(String id, String name) {
    // get sample config from ressource
    try {
      // input default file
      InputStream is = SimpleSpleef.getPlugin().getResource("config.yml");
      YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(is);
     
      // create new configuration section in main config
      ConfigurationSection newSection = SimpleSpleef.getPlugin().getConfig().createSection("arenas." + id);

      // get default arena
      ConfigurationSection section = defConfig.getConfigurationSection("arenas.default");

      // copy default to target section
      copySection(newSection, section);
      newSection.set("name", name); //set new name
View Full Code Here

     
      // get default config from resource
      InputStream languageConfigStream = SimpleSpleef.getPlugin().getResource("lang_" + language + ".yml");
        if (languageConfigStream != null) {
          // read into string - this will circumvent breaks in non-UTF-8-environments
          YamlConfiguration defConfig = loadUTF8Stream(languageConfigStream, "lang_" + language + ".yml");
          // the above is the same as
            //YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(languageConfigStream);
          // only save...
          if (defConfig == null) continue; // errors have been logged already
            // update config
            languageConfig.setDefaults(defConfig);
            languageConfig.options().copyDefaults(true); // copy defaults, too
            // force update of admin.help
            languageConfig.set("admin.help", defConfig.getString("admin.help"));
            try {
              // save updated config
              languageConfig.save(languageFile);
            } catch (Exception e) {
              SimpleSpleef.log.warning("[SimpleSpleef] Warning: Could not write lang_" + language + ".yml - reason: " + e.getMessage());
View Full Code Here

      } catch (Exception e) {
        SimpleSpleef.log.severe("[SimpleSpleef] Could not load resource file " + file + "! Reason: " + e.getMessage());
        return null;
    }

      YamlConfiguration defConfig = new YamlConfiguration();
      try {
      defConfig.loadFromString(config);
      return defConfig;
    } catch (InvalidConfigurationException e) {
      SimpleSpleef.log.severe("[SimpleSpleef] Could not convert resource file " + file + " to valid configuration! Reason: " + e.getMessage());
      return null;
    }
View Full Code Here

    public void reloadConfig() {
        newConfig = YamlConfiguration.loadConfiguration(configFile);

        InputStream defConfigStream = getResource("config.yml");
        if (defConfigStream != null) {
            YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);

            newConfig.setDefaults(defConfig);
        }
    }
View Full Code Here

      strings = null;
    }
   
   
    // Load the strings file.
    strings = new YamlConfiguration();
    try{
      strings.load(stringsFile);
    }
    catch(InvalidConfigurationException ex){
      log.warning("[" + getDescription().getName() + "] Error loading " + fileName + ": " + ex.getMessage());
View Full Code Here

    public static SqlConnector con;
   
    public static void loadConfig() {
        config = loadYamlFile("config.yml");
        if(config == null) {
            config = new YamlConfiguration();
            // setConfigDefaults(config);
            config.set("useSQL", false);
            config.set("splitHealth", true);
            config.set("splitHunger", true);
            config.set("controlGamemode", true);
View Full Code Here

    }
   
    public static void loadPlayerLogoutWorlds() {
        playerlogoutmap = loadYamlFile("logoutworld.yml");
        if(playerlogoutmap == null) {
            playerlogoutmap = new YamlConfiguration();
            saveYamlFile(playerlogoutmap, "logoutworld.yml");
        } else {
            Map<String,Object> playermap = playerlogoutmap.getValues(false);
            Set<String> players = playermap.keySet();
            for(String player : players) {
View Full Code Here

TOP

Related Classes of org.bukkit.configuration.file.YamlConfiguration

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.