Class ConfigManager<T>
java.lang.Object
net.darkhax.pricklemc.common.api.config.ConfigManager<T>
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionget()Gets the object being managed.static <T> ConfigManager<T> Initializes a config manager with the default plugins.static <T> ConfigManager<T> init(String name, T defaultValue, @Nullable Consumer<ConfigManager.Builder<T>> configure) Initializes a config manager with the default plugins and extra user configurations applied.voidload()Loads the config file from disk.static <T> TCreates and loads a configuration file.static <T> Tload(String name, T defaultValue, @Nullable Consumer<ConfigManager.Builder<T>> configure) Creates and loads a configuration file.voidsave()Saves the config object to the specified file path.
-
Method Details
-
load
Creates and loads a configuration file.- Type Parameters:
T- The type of the config object.- Parameters:
name- The name of the config file. This file will use the platforms config directory.defaultValue- The default config value.- Returns:
- The config object that was loaded.
-
load
public static <T> T load(String name, T defaultValue, @Nullable @Nullable Consumer<ConfigManager.Builder<T>> configure) Creates and loads a configuration file.- Type Parameters:
T- The type of the config object.- Parameters:
name- The name of the config file. This file will use the platforms config directory.defaultValue- The default config value.configure- An optional consumer used to configure the builder before it is built.- Returns:
- The config object that was loaded.
-
init
Initializes a config manager with the default plugins.- Type Parameters:
T- The type of object held by the config manager.- Parameters:
name- The name of the config file. This file will use the platforms config directory.defaultValue- The default config value.- Returns:
- A new config manager.
-
init
public static <T> ConfigManager<T> init(String name, T defaultValue, @Nullable @Nullable Consumer<ConfigManager.Builder<T>> configure) Initializes a config manager with the default plugins and extra user configurations applied.- Type Parameters:
T- The type of object held by the config manager.- Parameters:
name- The name of the config file. This file will use the platforms config directory.defaultValue- The default config value.configure- An optional consumer used to configure the builder before it is built.- Returns:
- A new config manager.
-
load
public void load()Loads the config file from disk. If the file does not exist it will try to generate one using the schema that was mapped out when building the config manager. -
save
public void save()Saves the config object to the specified file path. If the file does not exist one will be created. -
get
Gets the object being managed.- Returns:
- The config object being managed.
-