Skip to content

Serializables

Leonhard edited this page Nov 30, 2020 · 5 revisions

The serialization-system from LightningStorage is designed to be as simple & intuitive as possible. Also, it is easy to port on different API's because the classes that should be serialized don't need to extend any interfaces. This makes it possible to serialize classes that you don't have access to because they are provided by an third-party API.

Examples of this are the Bukkit&Bungeecord-API.

You can register classes as serializable using our LightningSerializer. After the registration, you can use your serializable's by calling the method

    LightningSerializer.registerSerializable(new LightningSerializable<TypeHere>() {
      @Override
      // The object can for example be a map or a String. 
      public TypeHere deserialize(@NonNull Object obj) throws ClassCastException {
        // TODO: Implement this method for your needs
      }

      @Override
      public TypeHere serialize(@NonNull Object o) throws ClassCastException {
        // TODO: Implement this method for your needs
      }

      @Override
      public Class<TypeHere> getClazz() {
        // TODO: Implement this method for your needs
      }
    });
  }
getSerializable(KEY, CLASS)

Clone this wiki locally