Interface YamlSerializable

All Known Implementing Classes:
BlockPosition, Point, Position, Vector3d

public interface YamlSerializable
An object that can be serialized to a YAML configuration section. Implementing classes should implement a public static deserialize(ConfigurationSection) method.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends YamlSerializable>
    T
    deserialize(@NotNull Class<T> clazz, @NotNull org.bukkit.configuration.ConfigurationSection section)
    Deserializes a ConfigurationSection to a YamlSerializable object.
    static @NotNull YamlSerializable
    deserializeRaw(@NotNull Class<?> clazz, @NotNull org.bukkit.configuration.ConfigurationSection section)
    Deserializes a ConfigurationSection to a YamlSerializable object.
    static @Nullable Method
    getDeserializeMethod(@NotNull Class<?> clazz)
    Gets the deserialization method for a given class.
    void
    serialize(@NotNull org.bukkit.configuration.ConfigurationSection section)
    Serializes the object into the configuration section.
  • Method Details

    • deserialize

      @NotNull static <T extends YamlSerializable> T deserialize(@NotNull @NotNull Class<T> clazz, @NotNull @NotNull org.bukkit.configuration.ConfigurationSection section)
      Deserializes a ConfigurationSection to a YamlSerializable object.
      Type Parameters:
      T - The YamlSerializable type
      Parameters:
      clazz - The YamlSerializable class
      section - The configuration section to deserialize
      Returns:
      The deserialized object
      Throws:
      IllegalStateException - If the class does not have a deserialization method
    • deserializeRaw

      @NotNull static @NotNull YamlSerializable deserializeRaw(@NotNull @NotNull Class<?> clazz, @NotNull @NotNull org.bukkit.configuration.ConfigurationSection section)
      Deserializes a ConfigurationSection to a YamlSerializable object.
      Parameters:
      clazz - The YamlSerializable class
      section - The configuration section to deserialize
      Returns:
      The deserialized object
      Throws:
      IllegalStateException - If the clazz does not have a deserialization method
    • getDeserializeMethod

      @Nullable static @Nullable Method getDeserializeMethod(@NotNull @NotNull Class<?> clazz)
      Gets the deserialization method for a given class.
      Parameters:
      clazz - the class
      Returns:
      The deserialization method, if the class has one
    • serialize

      void serialize(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection section)
      Serializes the object into the configuration section. The configuration file is not saved after serialization.
      Parameters:
      section - The section the object will be serialized into