Interface ConfigTag

All Known Subinterfaces:
ConfigCategory, ConfigValue, ConfigValueList
All Known Implementing Classes:
AbstractConfigTag, ConfigCategoryImpl, ConfigValueImpl, ConfigValueListImpl

public interface ConfigTag
Created by covers1624 on 17/4/22.
  • Method Details

    • getName

      String getName()
      Gets the name of this tag.
      Returns:
      The name.
    • getDesc

      default String getDesc()
      Gets a descriptive name for this tag. some.tag.name
      Returns:
      The descriptive name.
    • getParent

      @Nullable @Nullable ConfigCategory getParent()
      Get the parent tag.

      This will be null for the root tag.

      Returns:
      The parent or null.
    • setComment

      ConfigTag setComment(String comment)
      Sets the comment for this tag.
      Will be split on \n.
      Parameters:
      comment - The comment line.
      Returns:
      The same config tag.
    • setComment

      ConfigTag setComment(String... comment)
      Sets the comment for this tag.
      Parameters:
      comment - The comment lines.
      Returns:
      The same config tag.
    • setComment

      ConfigTag setComment(List<String> comment)
      Sets the comment for this tag.
      Parameters:
      comment - The comment lines.
      Returns:
      The same config tag.
    • getComment

      List<String> getComment()
      Gets the comment for the tag.
      Returns:
      The comment.
    • syncTagToClient

      ConfigTag syncTagToClient()
      Sets this tag as requiring syncing to the client.

      Register your root tag via ConfigSyncManager.registerSync(ResourceLocation, ConfigTag).

    • requiresClientSync

      boolean requiresClientSync()
      Checks if this tag or any of its children require client sync.
      Returns:
      If client sync is required.
    • forceSync

      default void forceSync()
      Manually trigger all registered ConfigCallback's in the tree.
      See Also:
    • runSync

      void runSync(ConfigCallback.Reason reason)
      Triggers all registered ConfigCallback's in the tree with the specified reason.

      This method should probably not be called by anyone else.

      Parameters:
      reason - The reason.
    • isNetworkTag

      boolean isNetworkTag()
      Checks if this tags is a synthetic network tag.

      Synthetic network tags will exist on the client when some form of dynamic config structure is synced to the client.

      Returns:
      If the tag is synthetic.
    • save

      default void save()
      Saves the config to disk if any values have changed.

      This does not save a specific ConfigTag this gets propagated all the way up the tree to the root ConfigTag and saves the entire config, if any branches are dirty.

    • isDirty

      boolean isDirty()
      If this ConfigTag or any of its children are dirty and requires flushing to disk.
      Returns:
      If the branch is dirty.
    • delete

      default void delete()
      Delete this tag from the parent.
    • reset

      void reset()
      Reset this tag back to the default.

      In the event that this is a ConfigCategory sets all descendant values to their default.

    • copy

      ConfigTag copy()
      Creates a deep clone of this ConfigTag.

      If this is called on a child tag, it will split from its parent.

      Does not keep callbacks.

      Returns:
      The deep copied tag.
    • write

      void write(MCDataOutput out)
      Write this tag to a MCDataOutput. Only categories and/or tags which have syncTagToClient() set will be written.
      Parameters:
      out - The output stream.
    • read

      void read(MCDataInput in)
      Read this tag from a MCDataInput. All tags and values will be read and inserted into the tree.

      If a tag does not already exist in the tree, one will be added and marked as a 'network tag', isNetworkTag().

      All tags with a network value will be reset to default when resetFromNetwork() is called, whilst any 'network only' tags will be deleted.

      Parameters:
      in - The input stream.
    • resetFromNetwork

      void resetFromNetwork()
      Resets all network tags back to their original value.

      Whilst a tag is set from the network, it is effectively immutable and may not be set.

      Any tags which are 'network only' are deleted during this operation.