Exemple #1
0
 protected static Objective load(final StorageKey key) {
   Material mat;
   int dat, amt;
   Location loc = null;
   double rng = 2.0;
   try {
     final int[] itm = SerUtils.parseItem(key.getString("item", ""));
     mat = Material.getMaterial(itm[0]);
     dat = itm[1];
   } catch (final IllegalArgumentException e) {
     return null;
   }
   amt = key.getInt("amount", 0);
   if (amt < 1) {
     return null;
   }
   loc = SerUtils.deserializeLocString(key.getString("location", ""));
   if (loc != null) {
     rng = key.getDouble("range", 2.0);
     if (rng < 0) {
       rng = 2.0;
     }
   }
   return new DropObjective(amt, mat, dat, loc, rng, key.getBoolean("questitem", false));
 }
Exemple #2
0
 @Override
 protected void save(final StorageKey key) {
   key.setString("item", SerUtils.serializeItem(material, data));
   key.setInt("amount", amount);
   if (location != null) {
     key.setString("location", SerUtils.serializeLocString(location));
     key.setDouble("range", range);
   }
   if (questItem) {
     key.setBoolean("questitem", questItem);
   }
 }