Interface Serializer<T>

All Known Subinterfaces:
InlineSerializer<T>, SimpleSerializer<T>
All Known Implementing Classes:
ActionBarMechanic, ActivateBlockMechanic, BiomeCondition, BossBarMechanic, ChanceSerializer, ColorSerializer, CommandMechanic, Condition, CustomSoundMechanic, DamageMechanic, DropItemMechanic, EntityTypeCondition, FireworkMechanic, FireworkMechanic.FireworkData, GlidingCondition, HasPermissionCondition, IgniteMechanic, InConeCondition, ItemSerializer, LeapMechanic, LightLevelCondition, LightningMechanic, MaterialCategoryCondition, Mechanic, MechanicManager, MessageMechanic, OnGroundCondition, PlayerEffectMechanic, PlayerEffectMechanicList, PotionMechanic, PushMechanic, RangeCondition, RelativeTargeter, RidingCondition, ScatterTargeter, SculkBloomMechanic, SculkShriekMechanic, ServerPlayersTargeter, ShapeTargeter, SneakingCondition, SoundMechanic, SourceTargeter, SprintingCondition, Targeter, TargetTargeter, TitleMechanic, VectorSerializer, WorldPlayersTargeter, WorldTargeter

public interface Serializer<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Returns true if the serializer allows path-to.
    default @Nullable String
    Returns the unique identifier to this serializer.
    default @NotNull String
     
    default @Nullable List<String>
    Allows using this serializer under other serializers if the current path ends with any given string in this list.
    default @Nullable String
    Returns a link to the page on the wiki that describes this serializer.
    default boolean
    letPassThrough(@NotNull String key)
    Returns true when the given key can be "added" to this serializer, and should be saved to the main configuration map.
    serialize(@NotNull me.deecaad.core.file.SerializeData data)
    Instantiates a new Object to be added into the finalized configuration.
    default boolean
    shouldSerialize(@NotNull me.deecaad.core.file.SerializeData data)
    After the getKeyword() check and getParentKeywords() check, this final check can be customized by the serializer in order to "fine tune" when a serializer should be automatically serialized.
    default void
    tryPathTo(me.deecaad.core.file.Configuration filledMap, String pathWhereToStore, String pathTo)
    This should be used in new iteration of serialization for all serializers which had Path_To used.
    default @Nullable String
    useLater(org.bukkit.configuration.ConfigurationSection configurationSection, String path)
    Basically if this is not null then all other serializers will be used except these which have useLater() returning not null.
  • Method Details

    • getKeyword

      @Nullable default @Nullable String getKeyword()
      Returns the unique identifier to this serializer. This identifier is used to determine when to apply the serializer to a config section. The identifier is case-sensitive, and it is ignored when null.

      Generally speaking, you should always override this method. When you do not need automatic serializer handling, you may return null.

      Returns:
      The nullable unique identifier.
    • getParentKeywords

      @Nullable default @Nullable List<String> getParentKeywords()
      Allows using this serializer under other serializers if the current path ends with any given string in this list.

      Example values here could be Arrays.asList("Spread.Spread_Image", "Recoil_Pattern"). Which would allow this serializer to be used under Spread.Spread_Image and Recoil_Patten parent keywords.

      Returns:
      The nullable parent paths
    • shouldSerialize

      default boolean shouldSerialize(@NotNull @NotNull me.deecaad.core.file.SerializeData data)
      After the getKeyword() check and getParentKeywords() check, this final check can be customized by the serializer in order to "fine tune" when a serializer should be automatically serialized.
      Parameters:
      data - The config information.
      Returns:
      true if the serializer should serialize.
    • useLater

      @Nullable default @Nullable String useLater(org.bukkit.configuration.ConfigurationSection configurationSection, String path)
      Basically if this is not null then all other serializers will be used except these which have useLater() returning not null. useLater() should only return something else than null if path to configuration option is used.

      Path to should not be never used multiple times inside one serializer!

      Parameters:
      configurationSection - the configuration section
      path - the path to this serializer's path (path to keyword like path.keyword)
      Returns:
      nonnull if this serializer should be used later
    • tryPathTo

      default void tryPathTo(me.deecaad.core.file.Configuration filledMap, String pathWhereToStore, String pathTo)
      This should be used in new iteration of serialization for all serializers which had Path_To used.
      Parameters:
      filledMap - the already filled map
      pathWhereToStore - the path where the SAME object at filledMap should also be stored (just under different key)
      pathTo - the path where to try to find object from filledMap
    • getWikiLink

      @Nullable default @Nullable String getWikiLink()
      Returns a link to the page on the wiki that describes this serializer. This method is called from SerializeData, and is used to help the user find potential solutions to their problem.
      Returns:
      The nullable link to the wiki.
    • canUsePathTo

      default boolean canUsePathTo()
      Returns true if the serializer allows path-to. You should override this method to return false if your serializer accepts a String in the main path of the serializer. For example, the VectorSerializer should override this method to return false.
      Returns:
      true if the serializer is complicated enough for path-to.
    • letPassThrough

      default boolean letPassThrough(@NotNull @NotNull String key)
      Returns true when the given key can be "added" to this serializer, and should be saved to the main configuration map. This is useful when using SerializeData.step(Serializer) with path-to.
      Parameters:
      key - The non-null key to check
      Returns:
      true if the key should be saved.
    • getName

      @NotNull default @NotNull String getName()
    • serialize

      @NotNull T serialize(@NotNull @NotNull me.deecaad.core.file.SerializeData data) throws me.deecaad.core.file.SerializerException
      Instantiates a new Object to be added into the finalized configuration. The object should be built off of SerializeData.getConfig(). If there is any misconfiguration (or any other issue preventing the construction of an object), then this method should throw a SerializerException. This method may not return null.
      Parameters:
      data - The non-null data containing config
      Returns:
      The non-null serialized data.
      Throws:
      me.deecaad.core.file.SerializerException - If there is an error in config.