Examples of FileConfiguration


Examples of org.bukkit.configuration.file.FileConfiguration

  /**
   * Clears and then populates the plugin's tier list
   */
  public void build() {
    plugin.tiers.clear();
    FileConfiguration cs = new YamlConfiguration();
    File f = new File(plugin.getDataFolder(), "tier.yml");
    if (f.exists())
      try {
        cs.load(f);
      } catch (Exception e) {
        if (plugin.getDebug())
          plugin.log.warning(e.getMessage());
      }
    for (String name : cs.getKeys(false)) {
      int amt = cs.getInt(name + ".Enchantments.Amt");
      int lvl = cs.getInt(name + ".Enchantments.Levels");
      double chance = cs.getDouble(name + ".Chance");
      String color = cs.getString(name + ".Color");
      List<Material> l = new ArrayList<Material>();
      for (String s : cs.getStringList(name + ".Materials")) {
        Material mat = Material.getMaterial(s.toUpperCase());
        if (mat != null)
          l.add(mat);
      }
      for (String s : cs.getStringList(name + ".Material")) {
        Material mat = Material.getMaterial(s.toUpperCase());
        if (mat != null)
          l.add(mat);
      }
      List<String> lore = new ArrayList<String>();
      for (String s : cs.getStringList(name + ".Lore"))
        if (s != null)
          lore.add(ChatColor.translateAlternateColorCodes('&', s));
      plugin.tiers.add(new Tier(name, ChatColor.valueOf(color
          .toUpperCase()), Math.abs(amt), Math.abs(lvl), Math
          .abs((int) (chance * 100)), l, lore, cs.getString(name
          + ".DisplayName", name), ((float) cs.getDouble(name
          + ".DropChance", 100)) / 100));
    }
  }
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

  /**
   * Clears and then populates the plugin's custom items list
   */
  public void build() {
    FileConfiguration fc = new YamlConfiguration();
    File f = new File(plugin.getDataFolder(), "custom.yml");
    if (f.exists()) {
      try {
        fc.load(f);
      } catch (Exception e) {
        if (plugin.getDebug())
          plugin.log.warning(e.getMessage());
      }
    }
    for (String name : fc.getKeys(false)) {
      ConfigurationSection cs = fc.getConfigurationSection(name);
      Material mat = Material.matchMaterial(cs.getString("Material"));
      ChatColor color = ChatColor.valueOf(cs.getString("Color")
          .toUpperCase());
      List<String> lore = cs.getStringList("Lore");
      ItemStack tool = new ItemStack(mat);
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

    nameLoader.writeDefault("set.yml", false);
    nameLoader.writeDefault("prefix.txt", false);
    nameLoader.writeDefault("suffix.txt", false);
    nameLoader.writeDefault("defenselore.txt", false);
    nameLoader.writeDefault("offenselore.txt", false);
    FileConfiguration config = getConfig();
    settings = new Settings(config);
    if (config.getBoolean("Display.ItemMaterialExtras", false)) {
      File loc = new File(getDataFolder(), "/NamesPrefix/");
      if (!loc.exists()) {
        loc.mkdir();
      }
      for (File f : loc.listFiles())
        if (f.getName().endsWith(".txt")) {
          getLogger().info("Loading Prefix File:" + f.getName());
          nameLoader.loadMaterialFile(hmprefix,
              new File(loc, f.getName()));
        }
      File sloc = new File(getDataFolder(), "/NamesSuffix/");
      if (!sloc.exists()) {
        sloc.mkdir();
      }
      for (File f : sloc.listFiles())
        if (f.getName().endsWith(".txt")) {
          getLogger().info("Loading Suffix File:" + f.getName());
          nameLoader.loadMaterialFile(hmsuffix,
              new File(sloc, f.getName()));
        }
    }

    nameLoader.loadFile(prefix, "prefix.txt");
    nameLoader.loadFile(suffix, "suffix.txt");

    nameLoader.loadFile(defenselore, "defenselore.txt");
    nameLoader.loadFile(offenselore, "offenselore.txt");
    custom = new ArrayList<ItemStack>();
    drop = new ItemAPI();
    new CustomBuilder(this).build();
    new SocketBuilder(this).build();
    new TierBuilder(this).build();
    new ArmorSetBuilder(this).build();
    dropsAPI = new DropsAPI(this);
    setsAPI = new SetsAPI(this);
    if (config.getBoolean("Worlds.Enabled", false)) {
      for (String s : config.getStringList("Worlds.Allowed")) {
        worlds.add(s.toLowerCase());
      }
    }
    debug = config.getBoolean("Plugin.Debug", false);

    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new MobListener(this), this);
    pm.registerEvents(new TomeListener(this), this);
    pm.registerEvents(new SocketListener(this), this);
    pm.registerEvents(new EffectsListener(this), this);
    pm.registerEvents(new SetListener(this), this);

    getCommand("diablodrops").setExecutor(new DiabloDropCommand(this));

    ShapelessRecipe re = new ShapelessRecipe(new IdentifyTome());
    re.addIngredient(3, Material.BOOK);
    re.addIngredient(Material.EYE_OF_ENDER);
    this.getServer().addRecipe(re);

    if (config.getBoolean("Plugin.AutoUpdate", true)) {
      getServer().getScheduler().runTask(this, new Runnable() {
        @Override
        public void run() {
          Updater up = new Updater(getInstance(), 46631, getFile(),
              UpdateType.DEFAULT, true);
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

  /**
   * Clears and then populates the plugin's ArmorSet list
   */
  public void build() {
    plugin.armorSets.clear();
    FileConfiguration cs = new YamlConfiguration();
    File f = new File(plugin.getDataFolder(), "set.yml");
    if (f.exists()) {
      try {
        cs.load(f);
      } catch (Exception e) {
        if (plugin.getDebug())
          plugin.log.warning(e.getMessage());
      }
    }
    for (String name : cs.getKeys(false)) {
      List<String> bonuses = cs.getStringList(name + ".Bonuses");
      if (bonuses == null)
        bonuses = new ArrayList<String>();
      plugin.armorSets.add(new ArmorSet(name, bonuses));
    }
  }
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

            return String.valueOf(value);
        }
    }

    public static void load(File configuration) {
        FileConfiguration config = YamlConfiguration.loadConfiguration(configuration);

        for(Nodes n: Nodes.values())
            if(!n.getNode().isEmpty())
                if(config.get(n.getNode()) != null)
                    n.setValue(config.get(n.getNode()));
    }
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

            Bukkit.getScheduler().cancelTask(viewer.getTask());
        }

        viewers.clear();

        FileConfiguration saves = DenizenAPI.getCurrentInstance().getSaves();

        if (saves.contains("Viewers"))
            for (final String id : saves.getConfigurationSection("Viewers").getKeys(false)) {
                Viewer viewer = new Viewer(id, saves.getString("Viewers." + id.toLowerCase() + ".content"), dLocation.valueOf(saves.getString("Viewers." + id.toLowerCase() + ".location")));
                viewers.put(id, viewer);
                if (viewer.getContent().startsWith("LOCATION")) {
                    int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(DenizenAPI.getCurrentInstance(), new Runnable() {
                        public void run() {
                            Player player = Bukkit.getPlayer(UUID.fromString(viewers.get(id).getContent().split("; ")[1]));
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

        private int getTask() {
            return this.task;
        }

        void save() {
            FileConfiguration saves = DenizenAPI.getCurrentInstance().getSaves();

            // Save content
            saves.set("Viewers." + id.toLowerCase() + ".content", content);
            // Save location
            saves.set("Viewers." + id.toLowerCase() + ".location", location.identify());
        }
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

            // Save location
            saves.set("Viewers." + id.toLowerCase() + ".location", location.identify());
        }

        void remove() {
            FileConfiguration saves = DenizenAPI.getCurrentInstance().getSaves();

            saves.set("Viewers." + id.toLowerCase(), null);
        }
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

    String nodeName = args.get("node");
    if (nodeName == null || nodeName.isEmpty()) {
      return;
    }

    FileConfiguration config = plugin.getConfig();

    if (args.get("value") != null) {
      config.set(nodeName, this.parseValue(args.get("value")));
      try {
        config.save(new File(plugin.getDataFolder(), "config.yml"));
      } catch (Throwable e) {
        sender.sendMessage(ChatColor.RED + "[PermissionsEx] Failed to save configuration: " + e.getMessage());
      }
    }

    Object node = config.get(nodeName);
    if (node instanceof Map) {
      sender.sendMessage("Node \"" + nodeName + "\": ");
      for (Map.Entry<?, ?> entry : ((Map<?, ?>) node).entrySet()) {
        sender.sendMessage("  " + entry.getKey() + " = " + entry.getValue());
      }
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

    /**
     * Called on by '/denizen save'.
     */
    private static void _saveNotables() {

        FileConfiguration notables = DenizenAPI.getCurrentInstance().notableManager().getNotables();
        for (String key: notables.getKeys(false)) {
            notables.set(key, null);
        }

        for (Map.Entry<String, Notable> notable : notableObjects.entrySet()) {

            // If the object is serializable, save that info... fetching the objects back
            // will require this information TODO: make this do something?..
      //      if (notable.getValue().getSaveObject() instanceof ConfigurationSerializable)
      //          DenizenAPI.getCurrentInstance().notableManager().getNotables()
      //                  .set(getClassId(notable.getValue().getClass()) + "." + "_serializable", true);

            notables.set(getClassId(getClass(notable.getValue())) + "." + notable.getKey().toLowerCase().replace(".", "DOT"),
                    notable.getValue().getSaveObject());
        }

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.