Package com.bergerkiller.bukkit.common.config

Examples of com.bergerkiller.bukkit.common.config.ConfigurationNode


    }
    statementShortcuts.clear().load(config.getNode("statementShortcuts"));
   
    //parser shortcuts
    config.setHeader("itemShortcuts", "\nSeveral shortcuts you can use on signs to set the items");
    ConfigurationNode itemshort = config.getNode("itemShortcuts");
    parsers.clear();

    // ================= Defaults ===============
    if (!itemshort.contains("fuel")) {
      itemshort.set("fuel", MaterialUtil.ISFUEL.toString());
    }
    if (!itemshort.contains("heatable")) {
      itemshort.set("heatable", MaterialUtil.ISHEATABLE.toString());
    }
    if (!itemshort.contains("armor")) {
      itemshort.set("armor", MaterialUtil.ISARMOR.toString());
    }
    if (!itemshort.contains("sword")) {
      itemshort.set("sword", MaterialUtil.ISSWORD.toString());
    }
    if (!itemshort.contains("boots")) {
      itemshort.set("boots", MaterialUtil.ISBOOTS.toString());
    }
    if (!itemshort.contains("leggings")) {
      itemshort.set("leggins", MaterialUtil.ISLEGGINGS.toString());
    }
    if (!itemshort.contains("chestplate")) {
      itemshort.set("chestplate", MaterialUtil.ISCHESTPLATE.toString());
    }
    if (!itemshort.contains("helmet")) {
      itemshort.set("helmet", MaterialUtil.ISHELMET.toString());
    }
    // ===========================================

    for (Map.Entry<String, String> entry : itemshort.getValues(String.class).entrySet()) {
      putParsers(entry.getKey(), Util.getParsers(entry.getValue()));
      itemshort.setRead(entry.getKey());
    }

    config.trim();
    config.save();
  }
View Full Code Here


    }
    if (this.trainCollision != CollisionMode.LINK) {
      node.set("collision.train", this.trainCollision);
    }
    if (!this.isEmpty()) {
      ConfigurationNode carts = node.getNode("carts");
      for (CartProperties prop : this) {
        ConfigurationNode cart = carts.getNode(prop.getUUID().toString());
        prop.save(cart);
        if (cart.getKeys().isEmpty()) carts.remove(cart.getName());
      }
    }
  }
View Full Code Here

  public static void loadDefaults() {
    defconfig = new FileConfiguration(TrainCarts.plugin, defaultPropertiesFile);
    defconfig.load();
    boolean changed = false;
    if (!defconfig.contains("default")) {
      ConfigurationNode node = defconfig.getNode("default");
      TrainProperties.EMPTY.saveAsDefault(node);
      changed = true;
    }
    if (!defconfig.contains("admin")) {
      ConfigurationNode node = defconfig.getNode("admin");
      for (Entry<String, Object> entry : defconfig.getNode("default").getValues().entrySet()) {
        node.set(entry.getKey(), entry.getValue());
      }
      changed = true;
    }
    if (!defconfig.contains("spawner")) {
      ConfigurationNode node = defconfig.getNode("spawner");
      for (Entry<String, Object> entry : defconfig.getNode("default").getValues().entrySet()) {
        node.set(entry.getKey(), entry.getValue());
      }
      changed = true;
    }
    if (fixDeprecation(defconfig)) {
      changed = true;
View Full Code Here

    } else {
      // Generate new properties
      WorldConfig defConfig = new WorldConfig(null);
      defConfig.gameMode = Bukkit.getDefaultGameMode();
      defConfig.saveDefault(defaultProperties);
      ConfigurationNode defEnv = defaultProperties.getNode("normal");
      defEnv.set("gamemode", "NONE");
      defEnv.setHeader("\nAll settings applied to worlds with the normal environment");
      defEnv.addHeader("You can add all the same world settings here and they will override the main defaults");
      defEnv.addHeader("You can use multiple environments, of which nether, the_end and even nether_flat");
      defaultProperties.save();
    }

    // Worlds configuration
    worldConfigs.clear();
View Full Code Here

      if (inventory.worlds.size() > 1) {
        String name = inventory.name;
        for (int i = 0; i < Integer.MAX_VALUE && !savedNames.add(name.toLowerCase()); i++) {
          name = inventory.name + i;
        }
        ConfigurationNode node = config.getNode(name);
        node.set("folder", inventory.worldname);
        node.set("worlds", new ArrayList<String>(inventory.worlds));
      }
    }
    config.save();
  }
View Full Code Here

   */
  public void reset() {
    // Try to import from other World Management plugins
    if (!MyWorlds.importFromMultiVerse || !MultiverseHandler.readWorldConfiguration(this)) {
      // Not imported, (try to) load from the default world configuration
      ConfigurationNode defaultsConfig = getDefaultProperties();
      if (defaultsConfig != null) {
        // Load using a clone to prevent altering the original
        this.load(defaultsConfig);
        if (defaultsConfig.contains(this.worldmode.getName())) {
          this.load(defaultsConfig.getNode(this.worldmode.getName()));
        }
      }
    }

    // Refresh
View Full Code Here

   *
   * @param command name (case insensitive)
   * @return command usage
   */
  public String getCommandUsage(String command) {
    ConfigurationNode node = getCommandNode(command);
    final String defValue = "/" + command;
    if (node == null) {
      return defValue;
    } else {
      return node.get("usage", defValue);
    }
  }
View Full Code Here

   *
   * @param command name (case insensitive)
   * @return command description
   */
  public String getCommandDescription(String command) {
    ConfigurationNode node = getCommandNode(command);
    final String defValue = "No description specified";
    if (node == null) {
      return defValue;
    } else {
      return node.get("description", defValue);
    }
  }
View Full Code Here

    // Load all the commands for this Plugin
    Map<String, Map<String, Object>> commands = this.getDescription().getCommands();
    if (commands != null && PluginDescriptionFileRef.commands.isValid()) {
      // Prepare commands localization node
      ConfigurationNode commandsNode = getLocalizationNode("commands");

      // Create a new modifiable commands map to replace with
      commands = new HashMap<String, Map<String, Object>>(commands);
      for (Entry<String, Map<String, Object>> commandEntry : commands.entrySet()) {
        ConfigurationNode node = commandsNode.getNode(commandEntry.getKey());

        // Transfer description and usage
        Map<String, Object> data = new HashMap<String, Object>(commandEntry.getValue());
        node.shareWith(data, "description", "No description specified");
        node.shareWith(data, "usage", "/" + commandEntry.getKey());
        commandEntry.setValue(Collections.unmodifiableMap(data));
      }

      // Set the new commands map using reflection
      PluginDescriptionFileRef.commands.set(this.getDescription(), Collections.unmodifiableMap(commands));
View Full Code Here

TOP

Related Classes of com.bergerkiller.bukkit.common.config.ConfigurationNode

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.