Exemplo n.º 1
0
  /**
   * Tries to factorize the given item getting all possible data out of it. The factorizing methods
   * will create flags and attributes for the item.
   *
   * @param item item to factorize
   */
  public void factorize(ItemStack item) {
    // debug low
    dB.low("Factorizing item: ", item.getType().name().toLowerCase());

    for (ItemAttr iAttr : ItemAttr.getAllAttributes()) {
      try {
        iAttr.onFactorize(item);
        attr.put(iAttr.getClass(), iAttr);
      } catch (AttributeValueNotFoundException e) {
        this.debugMsgValue(iAttr.getInfo(), "factorized");
      }
    }

    // factorize flags
    for (ItemFlag iFlag : ItemFlag.getAllFlags()) {
      try {
        iFlag.onFactorize(item);
        flags.put(iFlag.getClass(), iFlag);
      } catch (AttributeValueNotFoundException e) {
        this.debugMsgValue(iFlag.getInfo(), "factorized");
      }
    }

    // if the lore was already managed don't load it anymore
    if (loreManaged) return;

    Lore lore = null;
    try {
      lore = (Lore) ItemFlag.initFlag(this, ".lore");
      lore.onFactorize(item);
      flags.put(lore.getClass(), lore);
    } catch (AttributeValueNotFoundException e) {
      this.debugMsgValue(lore != null ? lore.getInfo() : null, "factorized");
    } catch (AttributeInvalidClassException e) {
      this.debugMsgClass(".lore");
    }
  }