Example #1
0
  public String generateItemTemplateEffects(int id) {
    if (!itemsEffects.containsKey(id)) {
      ItemTemplate template = DAOFactory.item().getById(id);

      if (template == null) return "";

      StringBuilder strEffects = new StringBuilder();

      for (String effect : Utils.split(template.statsTemplate, ",")) {
        if (effect.isEmpty()) continue;

        try {
          short effectID = Short.parseShort(Utils.split(effect, "#")[0], 16);

          if (EffectsHandler.instance().getEffect(effectID) != null)
            strEffects.append(effect).append(',');
        } catch (Exception e) {
          Loggin.warning("cannot generate effects string %s for template %d", effect, id);
        }
      }

      itemsEffects.put(id, strEffects.toString());
    }

    return itemsEffects.get(id);
  }
Example #2
0
  public static Stats getBaseStats(String strStats) {
    Stats stats = new Stats();

    if (strStats == null || strStats.isEmpty()) return stats;

    for (String data : Utils.split(strStats, "|")) {
      if (data.isEmpty()) continue;
      String[] arr = Utils.split(data, ";");

      if (arr.length < 2) continue;

      try {
        int elemID = Integer.parseInt(arr[0]);
        int qu = Integer.parseInt(arr[1]);
        stats.add(elemID, qu);
      } catch (Exception e) {
        Loggin.error("Cannot parse stats '" + data + "'", e);
      }
    }

    return stats;
  }