Пример #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));
 }
Пример #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);
   }
 }
Пример #3
0
 @QCommand(min = 2, max = 4, usage = "{<item>} <amount> {[location]} [range] (-q)")
 public static Objective fromCommand(final QCommandContext context) throws QCommandException {
   final int[] itm = SerUtils.parseItem(context.getString(0));
   final Material mat = Material.getMaterial(itm[0]);
   final int dat = itm[1];
   final int amt = context.getInt(1);
   if (amt < 1 || dat < -1) {
     throw new QCommandException(context.getSenderLang().get("ERROR_CMD_ITEM_NUMBERS"));
   }
   Location loc = null;
   double rng = 2.0;
   if (context.length() > 2) {
     loc = SerUtils.getLoc(context.getPlayer(), context.getString(2));
     if (context.length() > 3) {
       rng = context.getDouble(3);
       if (rng < 0) {
         throw new QCommandException(context.getSenderLang().get("ERROR_CMD_RANGE_INVALID"));
       }
     }
   }
   return new DropObjective(amt, mat, dat, loc, rng, context.hasFlag('q'));
 }
Пример #4
0
 @Override
 protected String info() {
   final String dataStr = data < 0 ? "" : ":" + data;
   final String locStr =
       location == null ? "" : "; LOC: " + SerUtils.displayLocation(location) + "; RNG: " + range;
   final String flags = questItem ? " (-q)" : "";
   return material.name()
       + "["
       + material.getId()
       + dataStr
       + "]; AMT: "
       + amount
       + locStr
       + flags;
 }
Пример #5
0
 @Override
 protected String show(final int progress) {
   final String datStr = data < 0 ? "" : " (data" + data + ")";
   final String spec = questItem ? " special" : "";
   final String locStr = location == null ? "" : " at " + SerUtils.displayLocation(location);
   return "Drop "
       + spec
       + material.name().toLowerCase().replace('_', ' ')
       + datStr
       + locStr
       + " - "
       + progress
       + "/"
       + amount
       + ".";
 }