Interface YggdrasilSerializable.YggdrasilExtendedSerializable

All Superinterfaces:
All Known Subinterfaces:
All Known Implementing Classes:
AxolotlData, BeeData, BlockValues, BoatChestData, BoatData, CatData, ColorRGB, CreeperData, DroppedItemData, EndermanData, EntityData, FallingBlockData, FishData, FoxData, FrogData, GoatData, ItemData, ItemType, LlamaData, MinecartData, MooshroomData, OcelotData, PandaData, ParrotData, PigData, RabbitData, SheepData, SimpleEntityData, SkriptColor, ThrownPotionData, TropicalFishData, VillagerData, WolfData, XpOrbData, ZombieVillagerData
Enclosing interface:

public static interface YggdrasilSerializable.YggdrasilExtendedSerializable extends YggdrasilSerializable
A class that has transient fields or more generally wants to exactly define which fields to write to/read from stream should implement this interface. It provides two methods similar to Java's writeObject and readObject methods.

If a class implements this interface implementing YggdrasilSerializable.YggdrasilRobustSerializable as well is pointless since its methods won't get called.

  • Method Details

    • serialize

      Fields serialize() throws NotSerializableException
      Serialises this object. Only fields contained in the returned Fields object will be written to stream.

      You can use return new Fields(this); to emulate the default behaviour.

      A Fields object containing all fields that should be written to stream
      NotSerializableException - If this object or one of its fields is not serialisable
    • deserialize

      void deserialize(@NonNull Fields fields) throws StreamCorruptedException, NotSerializableException
      Deserialises this object. No fields have been set when this method is called, use fields.setFields(this, yggdrasil) to set all compatible non-transient and non-static fields (and call incompatible/missing field handlers if applicable – this implies that errors will be thrown if the fields object is invalid).

      You can use fields.setFields(this); to emulate the default behaviour.

      fields - A Fields object containing all fields read from stream
      StreamCorruptedException - If the Fields object is invalid, i.e. was not written by serialize() or Yggrdasil's default serialisation.