Package me.deecaad.core.file
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 TypeMethodDescriptiondefault booleanReturnstrueif the serializer allows path-to.default @Nullable StringReturns the unique identifier to this serializer.default @NotNull StringgetName()Allows using this serializer under other serializers if the current path ends with any given string in this list.default @Nullable StringReturns a link to the page on the wiki that describes this serializer.default booleanletPassThrough(@NotNull String key) Returnstruewhen 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 booleanshouldSerialize(@NotNull me.deecaad.core.file.SerializeData data) After thegetKeyword()check andgetParentKeywords()check, this final check can be customized by the serializer in order to "fine tune" when a serializer should be automatically serialized.default voidThis should be used in new iteration of serialization for all serializers which had Path_To used.default @Nullable StringBasically if this is not null then all other serializers will be used except these which have useLater() returning not null.
-
Method Details
-
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 whennull.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
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 thegetKeyword()check andgetParentKeywords()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 sectionpath- 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 mappathWhereToStore- 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
Returns a link to the page on the wiki that describes this serializer. This method is called fromSerializeData, and is used to help the user find potential solutions to their problem.- Returns:
- The nullable link to the wiki.
-
canUsePathTo
default boolean canUsePathTo()Returnstrueif the serializer allows path-to. You should override this method to returnfalseif your serializer accepts aStringin the main path of the serializer. For example, theVectorSerializershould override this method to returnfalse.- Returns:
- true if the serializer is complicated enough for path-to.
-
letPassThrough
Returnstruewhen the given key can be "added" to this serializer, and should be saved to the main configuration map. This is useful when usingSerializeData.step(Serializer)with path-to.- Parameters:
key- The non-null key to check- Returns:
- true if the key should be saved.
-
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 ofSerializeData.getConfig(). If there is any misconfiguration (or any other issue preventing the construction of an object), then this method should throw aSerializerException. 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.
-