Example #1
0
 /**
  * Gets the henna list.
  *
  * @param classId the player's class Id.
  * @return the list with all the allowed dyes.
  */
 public List<L2Henna> getHennaList(ClassId classId) {
   final List<L2Henna> list = new ArrayList<>();
   for (L2Henna henna : _hennaList.values()) {
     if (henna.isAllowedClass(classId)) {
       list.add(henna);
     }
   }
   return list;
 }
Example #2
0
  /**
   * Parses the henna.
   *
   * @param d the d
   */
  private void parseHenna(Node d) {
    final StatsSet set = new StatsSet();
    final List<ClassId> wearClassIds = new ArrayList<>();
    final List<SkillHolder> skills = new ArrayList<>();
    NamedNodeMap attrs = d.getAttributes();
    Node attr;
    for (int i = 0; i < attrs.getLength(); i++) {
      attr = attrs.item(i);
      set.set(attr.getNodeName(), attr.getNodeValue());
    }

    for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling()) {
      final String name = c.getNodeName();
      attrs = c.getAttributes();
      switch (name) {
        case "stats":
          {
            for (int i = 0; i < attrs.getLength(); i++) {
              attr = attrs.item(i);
              set.set(attr.getNodeName(), attr.getNodeValue());
            }
            break;
          }
        case "wear":
          {
            attr = attrs.getNamedItem("count");
            set.set("wear_count", attr.getNodeValue());
            attr = attrs.getNamedItem("fee");
            set.set("wear_fee", attr.getNodeValue());
            break;
          }
        case "cancel":
          {
            attr = attrs.getNamedItem("count");
            set.set("cancel_count", attr.getNodeValue());
            attr = attrs.getNamedItem("fee");
            set.set("cancel_fee", attr.getNodeValue());
            break;
          }
        case "skills":
          {
            for (Node i = c.getFirstChild(); i != null; i = i.getNextSibling()) {
              if ("skill".equals(i.getNodeName())) {
                final int skillId =
                    Integer.parseInt(i.getAttributes().getNamedItem("id").getNodeValue());
                final int skillLevel =
                    Integer.parseInt(i.getAttributes().getNamedItem("level").getNodeValue());
                skills.add(new SkillHolder(skillId, skillLevel));
              }
            }
            break;
          }
        case "classId":
          {
            wearClassIds.add(ClassId.getClassId(Integer.parseInt(c.getTextContent())));
            break;
          }
      }
    }
    final L2Henna henna = new L2Henna(set);
    henna.setWearClassIds(wearClassIds);
    henna.setSkills(skills);
    _hennaList.put(henna.getDyeId(), henna);
  }