예제 #1
0
 @Override
 protected void save(final StorageKey key) {
   if (block != null) {
     key.setString("block", SerUtils.serializeItem(block, blockData));
   }
   if (inHand != null) {
     key.setString("hand", SerUtils.serializeItem(inHand, inHandData));
   }
   if (click > 0 && click < 4) {
     key.setInt("click", click);
   }
   if (location != null) {
     key.setString("location", SerUtils.serializeLocString(location));
     if (range > 0) {
       key.setInt("range", range);
     }
   }
 }
예제 #2
0
  protected static Objective load(final StorageKey key) {
    Material mat = null, hnd = null;
    Location loc = null;
    int dat = -1, hdat = -1, rng = 0, clck = 0;
    int[] itm;
    try {
      itm = SerUtils.parseItem(key.getString("block", ""));
      mat = Material.getMaterial(itm[0]);
      dat = itm[1];
    } catch (final IllegalArgumentException ignore) {
    }
    try {
      itm = SerUtils.parseItem(key.getString("hand", ""));
      hnd = Material.getMaterial(itm[0]);
      hdat = itm[1];
    } catch (final IllegalArgumentException ignore) {
    }
    clck = key.getInt("click", 0);
    loc = SerUtils.deserializeLocString(key.getString("location", ""));
    rng = key.getInt("range", 0);

    return new ActionObjective(mat, dat, hnd, hdat, clck, loc, rng);
  }