Esempio n. 1
0
 /**
  * Constructor for RewardData.
  *
  * @param itemId int
  */
 public RewardData(int itemId) {
   _item = ItemHolder.getInstance().getTemplate(itemId);
   if (_item.isArrow()
       || (Config.NO_RATE_EQUIPMENT && _item.isEquipment())
       || (Config.NO_RATE_KEY_MATERIAL && _item.isKeyMatherial())
       || (Config.NO_RATE_RECIPES && _item.isRecipe())
       || ArrayUtils.contains(Config.NO_RATE_ITEMS, itemId)) {
     _notRate = true;
   }
 }
  /** Method load. */
  private void load() {
    try {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setValidating(false);
      factory.setIgnoringComments(true);
      File file = new File(Config.DATAPACK_ROOT, "data/xml/other/cursed_weapons.xml");

      if (!file.exists()) {
        return;
      }

      Document doc = factory.newDocumentBuilder().parse(file);

      for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) {
        if ("list".equals(n.getNodeName())) {
          for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) {
            if ("item".equals(d.getNodeName())) {
              NamedNodeMap attrs = d.getAttributes();
              int id = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
              int skillId = Integer.parseInt(attrs.getNamedItem("skillId").getNodeValue());
              String name = "Unknown cursed weapon";

              if (attrs.getNamedItem("name") != null) {
                name = attrs.getNamedItem("name").getNodeValue();
              } else if (ItemHolder.getInstance().getTemplate(id) != null) {
                name = ItemHolder.getInstance().getTemplate(id).getName();
              }

              if (id == 0) {
                continue;
              }

              CursedWeapon cw = new CursedWeapon(id, skillId, name);

              for (Node cd = d.getFirstChild(); cd != null; cd = cd.getNextSibling()) {
                if ("dropRate".equals(cd.getNodeName())) {
                  cw.setDropRate(
                      Integer.parseInt(cd.getAttributes().getNamedItem("val").getNodeValue()));
                } else if ("duration".equals(cd.getNodeName())) {
                  attrs = cd.getAttributes();
                  cw.setDurationMin(Integer.parseInt(attrs.getNamedItem("min").getNodeValue()));
                  cw.setDurationMax(Integer.parseInt(attrs.getNamedItem("max").getNodeValue()));
                } else if ("durationLost".equals(cd.getNodeName())) {
                  cw.setDurationLost(
                      Integer.parseInt(cd.getAttributes().getNamedItem("val").getNodeValue()));
                } else if ("disapearChance".equals(cd.getNodeName())) {
                  cw.setDisapearChance(
                      Integer.parseInt(cd.getAttributes().getNamedItem("val").getNodeValue()));
                } else if ("stageKills".equals(cd.getNodeName())) {
                  cw.setStageKills(
                      Integer.parseInt(cd.getAttributes().getNamedItem("val").getNodeValue()));
                } else if ("transformationId".equals(cd.getNodeName())) {
                  cw.setTransformationId(
                      Integer.parseInt(cd.getAttributes().getNamedItem("val").getNodeValue()));
                } else if ("transformationTemplateId".equals(cd.getNodeName())) {
                  cw.setTransformationTemplateId(
                      Integer.parseInt(cd.getAttributes().getNamedItem("val").getNodeValue()));
                } else if ("transformationName".equals(cd.getNodeName())) {
                  cw.setTransformationName(cd.getAttributes().getNamedItem("val").getNodeValue());
                }
              }

              _cursedWeaponsMap.put(id, cw);
            }
          }
        }
      }

      _cursedWeapons = _cursedWeaponsMap.values(new CursedWeapon[_cursedWeaponsMap.size()]);
    } catch (Exception e) {
      _log.error("CursedWeaponsManager: Error parsing cursed_weapons file. " + e);
    }
  }
Esempio n. 3
0
 /** Constructor for WeaponItemParser. */
 protected WeaponItemParser() {
   super(ItemHolder.getInstance());
 }