Class JacksonConfig<T>
- Type Parameters:
T- type of main configuration
- All Implemented Interfaces:
DebugDataProvider
Each file is associated with a ConfigKey, which provides a name, path and a default value.
-
Constructor Summary
ConstructorsConstructorDescriptionJacksonConfig(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull ConfigKey<T> mainKey) Creates a new Jackson Configuration -
Method Summary
Modifier and TypeMethodDescriptionAllows to register additional modules to the mapper.configureDefault(MapperBuilder<?, ?> builder) protected final <V> VcreateAndLoad(ConfigKey<V> key) Load a file defined in the configuration key.protected ObjectMapperCreate a general mapper for read and write.protected ObjectMapperCreate a mapper for reading files.protected ObjectMapperCreate a mapper for writing files.<V> booleanChecks whether the config file was created alreadyprotected de.eldoria.jacksonbukkit.JacksonBukkitCreate the module used for spigot/bukkit server.Get debug information for the current object instance.protected de.eldoria.jacksonbukkit.JacksonPaperCreate the module used for paper server.final ModuleGet the module for the current platform.protected final <V> VLoad a file defined in the configuration key.<V> booleanChecks whether the config file was already loadedmain()Get the primary configuration.Get the primary configuration wrapper.final ObjectMappermapper()Get the object mapper used to read and write objectsorg.bukkit.plugin.Pluginplugin()Plugin associated with this configurationfinal ObjectMapperreader()Get the object mapper used to read filesvoidreload()Reloads all files loaded via this instance including the main configuration.voidReloads a single file associated with the config key<V> voidReplace the configuration currently associated with this key with a new configuration.voidsave()Saves all files loaded via this instance.voidSaves the file associated with the config key<V> VGet a configuration file.<V> Wrapper<V>secondaryWrapped(ConfigKey<V> key) Get a configuration file.final ObjectMapperwriter()Get the mapper used to write objectsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.eldoria.eldoutilities.debug.DebugDataProvider
getDebugProviders
-
Constructor Details
-
Method Details
-
plugin
public org.bukkit.plugin.Plugin plugin()Plugin associated with this configuration- Returns:
- plugin instance
-
main
Get the primary configuration.This will be the config.yml in most cases.
If the config was not yet created, it will be created.
- Returns:
- configuration
-
secondary
Get a configuration file.If this file was not yet created, it will be created.
- Type Parameters:
V- type of configuration- Parameters:
key- configuration key- Returns:
- configuration file
-
mainWrapped
Get the primary configuration wrapper.This wrapper can be used to save the config using the closable. It is also safe to be stored since it does not store the file itself.
This will be the config.yml in most cases.
If the config was not yet created, it will be created.
- Returns:
- configuration
-
secondaryWrapped
Get a configuration file.This wrapper can be used to save the config using the closable. It is also safe to be stored since it does not store the file itself.
If this file was not yet created, it will be created.
- Type Parameters:
V- type of configuration- Parameters:
key- configuration key- Returns:
- configuration file
-
exists
Checks whether the config file was created already- Type Parameters:
V- type- Parameters:
key- key- Returns:
- true when exists
-
loaded
Checks whether the config file was already loaded- Type Parameters:
V- type- Parameters:
key- key- Returns:
- true when loaded
-
replace
Replace the configuration currently associated with this key with a new configuration.- Type Parameters:
V- type of key- Parameters:
key- configuration keynewValue- new value of key
-
save
public void save()Saves all files loaded via this instance. -
save
Saves the file associated with the config key- Parameters:
key- configuration key
-
reload
public void reload()Reloads all files loaded via this instance including the main configuration. -
reload
Reloads a single file associated with the config key- Parameters:
key- configuration key
-
reader
Get the object mapper used to read files- Returns:
- object mapper instance
-
writer
Get the mapper used to write objects- Returns:
- object mapper instance
-
mapper
Get the object mapper used to read and write objects- Returns:
- object mapper instance
-
createReadMapper
Create a mapper for reading files.- Returns:
- mapper instance
-
createWriteMapper
Create a mapper for writing files.- Returns:
- mapper instance
-
load
Load a file defined in the configuration key.Will fail if the file is not present.
Use
createAndLoad(ConfigKey)if you want the file to be created.- Type Parameters:
V- type of file- Parameters:
key- configuration key- Returns:
- instance of file
-
createAndLoad
Load a file defined in the configuration key.If this file was not yet created, it will be created.
- Type Parameters:
V- type of file- Parameters:
key- configuration key- Returns:
- instance of file
-
createMapper
Create a general mapper for read and write.You can define different wrapper for read and write operations by overwriting
createReadMapper()andcreateWriteMapper()- Returns:
- mapper instance
-
configureDefault
-
getPlatformModule
Get the module for the current platform.- Returns:
- module
-
additionalModules
Allows to register additional modules to the mapper.- Returns:
- list of modules.
-
getPaperModule
protected de.eldoria.jacksonbukkit.JacksonPaper getPaperModule()Create the module used for paper server.This should be a
JacksonPapermodule.- Returns:
- paper module
-
getBukkitModule
protected de.eldoria.jacksonbukkit.JacksonBukkit getBukkitModule()Create the module used for spigot/bukkit server.This should be a
JacksonBukkitmodule.- Returns:
- spigot/bukkit module
-
getDebugInformations
Description copied from interface:DebugDataProviderGet debug information for the current object instance.- Specified by:
getDebugInformationsin interfaceDebugDataProvider- Returns:
- array of entry data.
-