Exemplo n.º 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();
 }
Exemplo n.º 2
0
 @Override
 public Fields serialize(final EntityData o) throws NotSerializableException {
   final Fields f = o.serialize();
   f.putObject("codeName", o.info.codeName);
   return f;
 }
Exemplo n.º 3
0
 @Override
 public void deserialize(final Fields fields)
     throws StreamCorruptedException, NotSerializableException {
   fields.setFields(this);
 }