Class CodingValue<T>

java.lang.Object
ua.mcchickenstudio.opencreative.indev.values.CodingValue<T>
Direct Known Subclasses:
TextCodingValue

public abstract class CodingValue<T> extends Object

CodingValue

This class represents a coding value, that will be used for storing data in variables and event values.
  • Constructor Details

    • CodingValue

      public CodingValue(@NotNull @NotNull String id, @NotNull @NotNull org.bukkit.Material icon, @NotNull @NotNull org.bukkit.Material pane)
      Constructor of coding value.
      Parameters:
      id - short id of coding value that will be used for identifying value.

      It must be lower-snake-cased, for example: "text", "event_value". If some of registered coding values has same ID as new, it will be not added.

      icon - icon of event value that will be displayed in event values list.
      pane - category of event value for event values list.
  • Method Details

    • deserialize

      @Nullable public abstract T deserialize(@NotNull @NotNull Object value, @NotNull @NotNull CodingValue.Saver type)
      Parses object and creates value from it.
      Parameters:
      value - value to parse.
      type - type of saver (yaml or json).
      Returns:
      value, or null - if failed to deserialize.
    • serialize

      @NotNull public abstract @NotNull Object serialize(@NotNull T value, @NotNull @NotNull CodingValue.Saver type)
      Saves value as string or map object to save it in file.
      Parameters:
      value - value to save.
      type - type of saver (yaml or json).
      Returns:
      value, converted to YAML object.