Interface YggdrasilSerializable.YggdrasilExtendedSerializable

All Superinterfaces:
YggdrasilSerializable
All Known Subinterfaces:
Color
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:
YggdrasilSerializable

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.

      Returns:
      A Fields object containing all fields that should be written to stream
      Throws:
      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.

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