Class Confabricate

  • All Implemented Interfaces:
    net.fabricmc.api.ModInitializer

    public class Confabricate
    extends Object
    implements net.fabricmc.api.ModInitializer
    Configurate integration holder, providing access to configuration loaders pre-configured to work with Minecraft types.

    This class has static utility methods for usage by other mods -- it should not be instantiated by anyone but the mod loader.

    Since:
    1.0.0
    • Method Detail

      • id

        public static Identifier id​(String item)
        Internal API to get a mod Identifier.
        Parameters:
        item - path value
        Returns:
        new identifier
        Since:
        2.0.0
      • onInitialize

        public void onInitialize()
        Specified by:
        onInitialize in interface net.fabricmc.api.ModInitializer
      • loaderFor

        public static ConfigurationLoader<CommentedConfigurationNodeloaderFor​(net.fabricmc.loader.api.ModContainer mod,
                                                                                boolean ownDirectory)
        Get a configuration loader for a mod. The configuration will be in Hocon format.

        If the configuration is in its own directory, the path will be

        <config root>/<modid>/<modid>.conf
        . Otherwise, the path will be
        <config root>/<modid>.conf
        .

        The returned ConfigurationLoaders will be pre-configured to use the type serializers from MinecraftSerializers.collection(), but will otherwise use default settings.

        Parameters:
        mod - the mod to get the configuration loader for
        ownDirectory - whether the configuration should be in a directory just for the mod, or a file in the config root
        Returns:
        the newly created configuration loader
        Since:
        1.0.0
      • loaderFor

        public static ConfigurationLoader<CommentedConfigurationNodeloaderFor​(net.fabricmc.loader.api.ModContainer mod,
                                                                                boolean ownDirectory,
                                                                                ConfigurationOptions options)
        Get a configuration loader for a mod. The configuration will be in Hocon format.

        If the configuration is in its own directory, the path will be

        <config root>/<modid>/<modid>.conf
        . Otherwise, the path will be
        <config root>/<modid>.conf
        .

        The returned ConfigurationLoaders will be pre-configured to use the type serializers from MinecraftSerializers.collection(), but will otherwise use default settings.

        Parameters:
        mod - the mod to get the configuration loader for
        ownDirectory - whether the configuration should be in a directory just for the mod, or a file in the config root
        options - the options to use by default when loading
        Returns:
        the newly created configuration loader
        Since:
        2.0.0
      • configurationFor

        public static ConfigurationReference<CommentedConfigurationNodeconfigurationFor​(net.fabricmc.loader.api.ModContainer mod,
                                                                                          boolean ownDirectory)
                                                                                   throws ConfigurateException
        Get a configuration reference for a mod. The configuration will be in Hocon format.

        If the configuration is in its own directory, the path will be

        <config root>/<modid>/<modid>.conf
        Otherwise, the path will be
        <config root>/<modid>.conf
        .

        The reference's ConfigurationLoader will be pre-configured to use the type serializers from MinecraftSerializers.collection() but will otherwise use default settings.

        Parameters:
        mod - the mod to get the configuration loader for
        ownDirectory - whether the configuration should be in a directory just for the mod
        Returns:
        the newly created and loaded configuration reference
        Throws:
        ConfigurateException - if a listener could not be established or the configuration failed to load.
        Since:
        1.1.0
      • configurationFor

        public static ConfigurationReference<CommentedConfigurationNodeconfigurationFor​(net.fabricmc.loader.api.ModContainer mod,
                                                                                          boolean ownDirectory,
                                                                                          ConfigurationOptions options)
                                                                                   throws ConfigurateException
        Get a configuration reference for a mod. The configuration will be in Hocon format.

        If the configuration is in its own directory, the path will be

        <config root>/<modid>/<modid>.conf
        Otherwise, the path will be
        <config root>/<modid>.conf
        .

        The reference's ConfigurationLoader will be pre-configured to use the type serializers from MinecraftSerializers.collection() but will otherwise use default settings.

        Parameters:
        mod - the mod to get the configuration loader for
        ownDirectory - whether the configuration should be in a directory just for the mod
        options - the options to use by default when loading
        Returns:
        the newly created and loaded configuration reference
        Throws:
        ConfigurateException - if a listener could not be established or the configuration failed to load.
        Since:
        2.0.0
      • configurationFile

        public static Path configurationFile​(net.fabricmc.loader.api.ModContainer mod,
                                             boolean ownDirectory)
        Get the path to a configuration file in HOCON format for mod.

        HOCON uses the .conf file extension.

        Parameters:
        mod - container of the mod
        ownDirectory - whether the configuration should be in its own directory, or in the main configuration directory
        Returns:
        path to a configuration file
        Since:
        1.1.0
      • createTransformation

        public static ConfigurationTransformation createTransformation​(com.mojang.datafixers.DataFixer fixer,
                                                                       com.mojang.datafixers.DSL.TypeReference reference,
                                                                       int targetVersion,
                                                                       Object... versionKey)
        Create a ConfigurationTransformation that applies a DataFixer to a Configurate node. The current version of the node is provided by the path versionKey. The transformation is executed from the provided node.
        Parameters:
        fixer - the fixer containing DFU transformations to apply
        reference - the reference to the DFU DSL type representing this node
        targetVersion - the version to convert to
        versionKey - the location of the data version in nodes provided to the transformer
        Returns:
        a transformation that executes a data fixer.
        Since:
        1.1.0
      • createTransformAction

        public static TransformAction createTransformAction​(com.mojang.datafixers.DataFixer fixer,
                                                            com.mojang.datafixers.DSL.TypeReference reference,
                                                            int targetVersion,
                                                            Object... versionKey)
        Create a TransformAction applying a DataFixer to a Configurate node. This can be used within ConfigurationTransformation when some values are controlled by DFUs and some aren't.
        Parameters:
        fixer - the fixer containing DFU transformations to apply
        reference - the reference to the DFU DSL type representing this node
        targetVersion - the version to convert to
        versionKey - the location of the data version in nodes seen by this action.
        Returns:
        the created action
        Since:
        1.1.0
      • fileWatcher

        public static WatchServiceListener fileWatcher()
        Access the shared watch service for listening to files in this game on the default filesystem.
        Returns:
        watcher
        Since:
        1.1.0