Contents
Class Config<T>
java.lang.Object
com.hypixel.hytale.server.core.util.Config<T>
- Type Parameters:
T- The type of the configuration structure that this contains
A helper to load/save configuration files
-
Constructor Summary
ConstructorsConstructorDescriptionConfig(Path path, String name, BuilderCodec<T> codec) Creates a configuration file accessor that will attempt to load the configuration file from the given path and decode it with the given codec. -
Method Summary
Modifier and TypeMethodDescriptionget()Returns the current instance of the config if loaded.load()Loads the config from the given location if it exists, otherwise the default config will be used insteadstatic <T> Config<T> preloadedConfig(Path path, String name, BuilderCodec<T> codec, T config) Deprecated, for removal: This API element is subject to removal in a future version.Exists for backwards compatibility with the old module configsave()Saves the current state of the config to the config path.
-
Constructor Details
-
Config
Creates a configuration file accessor that will attempt to load the configuration file from the given path and decode it with the given codec.- Parameters:
path- The location of the config filecodec- The codec to use to decode the file
-
-
Method Details
-
preloadedConfig
@Nonnull @Deprecated(forRemoval=true) public static <T> Config<T> preloadedConfig(@Nonnull Path path, String name, BuilderCodec<T> codec, T config) Deprecated, for removal: This API element is subject to removal in a future version.Exists for backwards compatibility with the old module config -
load
Loads the config from the given location if it exists, otherwise the default config will be used instead- Returns:
- A future that will return the loaded config.
-
get
Returns the current instance of the config if loaded.If the config has started loading then this will block until it completes.
The value returned from this should not be stored as the value could be reloaded any time
load()is called.- Returns:
- The loaded config
- Throws:
IllegalStateException- If this is called before load is called at least once
-
save
Saves the current state of the config to the config path.If the config is still loading this does nothing.
- Returns:
- A future that will complete when the config is saved
- Throws:
IllegalStateException- If this is called before load is called at least once
-