コード例 #1
0
 @Override
 protected EntityData deserialize(final Fields fields)
     throws StreamCorruptedException, NotSerializableException {
   final String codeName = fields.getAndRemoveObject("codeName", String.class);
   if (codeName == null) throw new StreamCorruptedException();
   final EntityDataInfo<?> info = getInfo(codeName);
   if (info == null)
     throw new StreamCorruptedException("Invalid EntityData code name " + codeName);
   try {
     final EntityData<?> d = info.c.newInstance();
     d.deserialize(fields);
     return d;
   } catch (final InstantiationException e) {
     Skript.exception(e);
   } catch (final IllegalAccessException e) {
     Skript.exception(e);
   }
   throw new StreamCorruptedException();
 }
コード例 #2
0
 @Override
 public Fields serialize(final EntityData o) throws NotSerializableException {
   final Fields f = o.serialize();
   f.putObject("codeName", o.info.codeName);
   return f;
 }
コード例 #3
0
 @Override
 public void deserialize(final Fields fields)
     throws StreamCorruptedException, NotSerializableException {
   fields.setFields(this);
 }