Beispiel #1
0
 /**
  * Looks for the flag declaration that has the specified <b>key</b>. If found it will add it
  * automatically to the items structure.
  *
  * @param key the unique flag key
  */
 public void addFlag(String key) {
   try {
     ItemFlag flag = ItemFlag.initFlag(this, key);
     flags.put(flag.getClass(), flag);
   } catch (Exception e) {
     debugMsgClass(key);
   }
 }
Beispiel #2
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");
    }
  }