Esempio n. 1
0
 public boolean removePower(String pow) {
   Iterator<Power> it = powers.iterator();
   Power power = null;
   while (it.hasNext()) {
     Power p = it.next();
     if (p.getName().equalsIgnoreCase(pow)) {
       it.remove();
       power = p;
       rebuild();
       break;
     }
   }
   if (power != null) {
     if (power instanceof PowerHit) {
       powerHit.remove((PowerHit) power);
     }
     if (power instanceof PowerLeftClick) {
       powerLeftClick.remove(power);
     }
     if (power instanceof PowerRightClick) {
       powerRightClick.remove(power);
     }
     if (power instanceof PowerProjectileHit) {
       powerProjectileHit.remove(power);
     }
     if (power instanceof PowerTick) {
       powerTick.remove(power);
     }
   }
   return power != null;
 }
Esempio n. 2
0
 public void addPower(Power power, boolean update) {
   powers.add(power);
   Power.powerUsage.put(power.getName(), Power.powerUsage.get(power.getName()) + 1);
   if (power instanceof PowerHit) {
     powerHit.add((PowerHit) power);
   }
   if (power instanceof PowerLeftClick) {
     powerLeftClick.add((PowerLeftClick) power);
   }
   if (power instanceof PowerRightClick) {
     powerRightClick.add((PowerRightClick) power);
   }
   if (power instanceof PowerProjectileHit) {
     powerProjectileHit.add((PowerProjectileHit) power);
   }
   if (power instanceof PowerTick) {
     powerTick.add((PowerTick) power);
   }
   if (update) rebuild();
 }
Esempio n. 3
0
  public void save(ConfigurationSection s) {
    s.set("name", name);
    s.set("id", id);
    s.set("display", displayName.replaceAll("" + ChatColor.COLOR_CHAR, "&"));
    s.set("quality", quality.toString());
    s.set("damageMin", damageMin);
    s.set("damageMax", damageMax);
    s.set("armour", armour);
    s.set("type", type.replaceAll("" + ChatColor.COLOR_CHAR, "&"));
    s.set("hand", hand.replaceAll("" + ChatColor.COLOR_CHAR, "&"));
    s.set("lore", loreText.replaceAll("" + ChatColor.COLOR_CHAR, "&"));
    ArrayList<String> descriptionConv = new ArrayList<String>(description);
    for (int i = 0; i < descriptionConv.size(); i++) {
      descriptionConv.set(i, descriptionConv.get(i).replaceAll("" + ChatColor.COLOR_CHAR, "&"));
    }
    s.set("description", descriptionConv);
    s.set("item", item.getType().toString());
    s.set("ignoreWorldGuard", ignoreWorldGuard);

    ItemMeta meta = localeMeta.get("en_GB");
    if (meta instanceof LeatherArmorMeta) {
      s.set("item_colour", ((LeatherArmorMeta) meta).getColor().asRGB());
    } else {
      s.set("item_data", item.getDurability());
    }
    ConfigurationSection powerConfigs = s.createSection("powers");
    int i = 0;
    for (Power p : powers) {
      MemoryConfiguration pConfig = new MemoryConfiguration();
      pConfig.set("powerName", p.getName());
      p.save(pConfig);
      powerConfigs.set(Integer.toString(i), pConfig);
      i++;
    }

    // Recipes
    s.set("hasRecipe", hasRecipe);
    if (hasRecipe) {
      s.set("recipe", recipe);
    }

    ConfigurationSection drops = s.createSection("dropChances");
    for (String key : dropChances.keySet()) {
      drops.set(key, dropChances.get(key));
    }

    s.set("maxDurability", maxDurability);
    s.set("forceBar", forceBar);
  }