Class KamiConfig
java.lang.Object
com.kamikazejam.kamicommon.configuration.standalone.AbstractConfig<YamlConfiguration>
com.kamikazejam.kamicommon.configuration.spigot.KamiConfig
- All Implemented Interfaces:
ObservableConfig,ConfigurationMethods<ConfigurationSection>,ConfigurationSection
- Direct Known Subclasses:
KamiConfigExt
public class KamiConfig
extends AbstractConfig<YamlConfiguration>
implements ConfigurationSection, ObservableConfig
A class that represents a configuration file (Meant for implementations WITH a JavaPlugin object available)
If you DO NOT have a JavaPlugin object, it is recommended to use
This is an extension of a YamlConfiguration, so all get, set, and put methods are available.
When extending this class, provide the File to the config in the super, and then add all desired comments
Then you can use this object just like a YamlConfiguration, it has all the same methods plus a few others like
If you DO NOT have a JavaPlugin object, it is recommended to use
StandaloneConfig instead This is an extension of a YamlConfiguration, so all get, set, and put methods are available.
When extending this class, provide the File to the config in the super, and then add all desired comments
Then you can use this object just like a YamlConfiguration, it has all the same methods plus a few others like
reload() -
Constructor Summary
ConstructorsConstructorDescriptionKamiConfig(@NotNull AbstractSubsystem<?, ?> subsystem, @NotNull ConfigSource source) Creates a new config instance with the given subsystem and config source.
This constructor enables defaults using the following resource file method:
- Fetches the resource file using the provided source, fromAbstractSubsystem.getSupplementalConfigResource(ConfigSource)KamiConfig(@NotNull AbstractSubsystem<?, ?> subsystem, @NotNull ConfigSource source, @Nullable Supplier<InputStream> defaultsStream) Creates a new config instance with the given subsystem and config source.
This constructor uses defaults if and only if the provided supplier is NOT null:
- Providing a non-null supplier will enable defaults using the provided InputStream - Providing a null supplier will disable defaultsKamiConfig(@NotNull AbstractSubsystem<?, ?> subsystem, @NotNull File file) Creates a new config instance with the given subsystem and destination file.
This constructor enables defaults using the following resource file method:
- Fetches the resource file using the provided file name, fromAbstractSubsystem.getSupplementalConfigResource(File)KamiConfig(@NotNull AbstractSubsystem<?, ?> subsystem, @NotNull File file, @Nullable Supplier<InputStream> defaultsStream) Creates a new config instance with the given subsystem and destination file.
This constructor uses defaults if and only if the provided supplier is NOT null:
- Providing a non-null supplier will enable defaults using the provided InputStream - Providing a null supplier will disable defaultsKamiConfig(@NotNull JavaPlugin plugin, @NotNull ConfigSource source) Creates a new config instance with the given plugin and config source.
This constructor enables defaults using the following resource file method:
- Fetches the resource file.KamiConfig(@NotNull JavaPlugin plugin, @NotNull ConfigSource source, @Nullable Supplier<InputStream> defaultsStream) Creates a new config instance with the given plugin and config source.
This constructor uses defaults if and only if the provided supplier is NOT null:
- Providing a non-null supplier will enable defaults using the provided InputStream - Providing a null supplier will disable defaultsKamiConfig(@NotNull JavaPlugin plugin, @NotNull File file) Creates a new config instance with the given plugin and destination file.
This constructor enables defaults using the following resource file method:
- Assumes a resource file with the same name as the provided file, exists in the current jar.KamiConfig(@NotNull JavaPlugin plugin, @NotNull File file, @Nullable Supplier<InputStream> defaultsStream) Creates a new config instance with the given plugin and destination file.
This constructor uses defaults if and only if the provided supplier is NOT null:
- Providing a non-null supplier will enable defaults using the provided InputStream - Providing a null supplier will disable defaults -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDefault(String key, Object o) booleangetBigDecimal(String key) getBigDecimal(String key, BigDecimal def) booleangetBoolean(String key) booleangetBoolean(String key, boolean def) bytebytegetByteList(String key) getByteList(String key, List<Byte> def) @NotNull MemorySection@NotNull ConfigurationSequenceSpigotdoubledoublefloatfloatintintgetIntegerList(String key) getIntegerList(String key, List<Integer> def) getItemStack(String key) getItemStack(String key, ItemStack def) getKeys(boolean deep) Returns the keys of the config If Deep is enabled, it will dig and find all valid keys that resolve to a valueList<?> List<?> longlongshortshort@NotNull ConfigSourcegetStringList(String key) getStringList(String key, List<String> def) protected YamlConfigurationbooleanbooleanbooleanbooleanbooleanisEmpty()booleanbooleanbooleanisItemStack(String key) booleanbooleanbooleanbooleanbooleanboolean@NotNull ItemBuilderparseItemBuilder(@NotNull String key) Parses the subsection at the given key into anItemBuilder.voidvoidputBoolean(String key, boolean value) voidvoidvoidvoidvoidputInteger(String key, int value) voidvoidvoidbooleanregisterConfigObserver(@NotNull ConfigObserver observer) Registers an observer to this config (if not already registered)
Refer to theConfigObserverdocs for information on its lifecycle.voidreload()Reloads the config from the filevoidReload the backing config for this observable, notifying all registered observers of the change.
Equivalent to callingreload()voidvoidsetBoolean(String key, boolean value) voidvoidvoidvoidvoidsetInteger(String key, int value) voidsetItemStack(String key, ItemStack item) voidvoidvoidvoidunregisterConfigObserver(@NotNull ConfigObserver observer) Unregisters an observer from this configvoidUnregisters ALL observers from this config.
Intended for shutdown logic, but can be used at any time.Methods inherited from class com.kamikazejam.kamicommon.configuration.standalone.AbstractConfig
isChanged, save, save, setChangedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.kamikazejam.kamicommon.yaml.base.ConfigurationMethods
isChanged, setChanged
-
Constructor Details
-
KamiConfig
Creates a new config instance with the given plugin and destination file.
This constructor enables defaults using the following resource file method:
- Assumes a resource file with the same name as the provided file, exists in the current jar. -
KamiConfig
public KamiConfig(@NotNull @NotNull JavaPlugin plugin, @NotNull @NotNull File file, @Nullable @Nullable Supplier<InputStream> defaultsStream) Creates a new config instance with the given plugin and destination file.
This constructor uses defaults if and only if the provided supplier is NOT null:
- Providing a non-null supplier will enable defaults using the provided InputStream - Providing a null supplier will disable defaults- Parameters:
defaultsStream- The optional supplier to load defaults from.
-
KamiConfig
Creates a new config instance with the given plugin and config source.
This constructor enables defaults using the following resource file method:
- Fetches the resource file. Its path is determined byConfigSource.getResourceStreamPath()- Parameters:
source- The source to load and save the config from.
-
KamiConfig
public KamiConfig(@NotNull @NotNull JavaPlugin plugin, @NotNull @NotNull ConfigSource source, @Nullable @Nullable Supplier<InputStream> defaultsStream) Creates a new config instance with the given plugin and config source.
This constructor uses defaults if and only if the provided supplier is NOT null:
- Providing a non-null supplier will enable defaults using the provided InputStream - Providing a null supplier will disable defaults- Parameters:
source- The source to load and save the config from.defaultsStream- The optional supplier to load defaults from.
-
KamiConfig
Creates a new config instance with the given subsystem and destination file.
This constructor enables defaults using the following resource file method:
- Fetches the resource file using the provided file name, fromAbstractSubsystem.getSupplementalConfigResource(File) -
KamiConfig
public KamiConfig(@NotNull @NotNull AbstractSubsystem<?, ?> subsystem, @NotNull @NotNull File file, @Nullable @Nullable Supplier<InputStream> defaultsStream) Creates a new config instance with the given subsystem and destination file.
This constructor uses defaults if and only if the provided supplier is NOT null:
- Providing a non-null supplier will enable defaults using the provided InputStream - Providing a null supplier will disable defaults -
KamiConfig
public KamiConfig(@NotNull @NotNull AbstractSubsystem<?, ?> subsystem, @NotNull @NotNull ConfigSource source) Creates a new config instance with the given subsystem and config source.
This constructor enables defaults using the following resource file method:
- Fetches the resource file using the provided source, fromAbstractSubsystem.getSupplementalConfigResource(ConfigSource)- Parameters:
source- The source to load and save the config from.
-
KamiConfig
public KamiConfig(@NotNull @NotNull AbstractSubsystem<?, ?> subsystem, @NotNull @NotNull ConfigSource source, @Nullable @Nullable Supplier<InputStream> defaultsStream) Creates a new config instance with the given subsystem and config source.
This constructor uses defaults if and only if the provided supplier is NOT null:
- Providing a non-null supplier will enable defaults using the provided InputStream - Providing a null supplier will disable defaults- Parameters:
source- The source to load and save the config from.defaultsStream- The optional supplier to load defaults from.
-
-
Method Details
-
reload
public void reload()Description copied from class:AbstractConfigReloads the config from the file- Specified by:
reloadin classAbstractConfig<YamlConfiguration>
-
getSource
- Specified by:
getSourcein classAbstractConfig<YamlConfiguration>- Returns:
- The file associated with this config
-
getYamlConfiguration
- Specified by:
getYamlConfigurationin classAbstractConfig<YamlConfiguration>- Returns:
- The YamlConfiguration associated with this config
-
registerConfigObserver
Description copied from interface:ObservableConfigRegisters an observer to this config (if not already registered)
Refer to theConfigObserverdocs for information on its lifecycle.- Specified by:
registerConfigObserverin interfaceObservableConfig- Returns:
- If the observer was successfully registered from this call (false if already registered)
-
unregisterConfigObserver
Description copied from interface:ObservableConfigUnregisters an observer from this config- Specified by:
unregisterConfigObserverin interfaceObservableConfig
-
unregisterConfigObservers
public void unregisterConfigObservers()Description copied from interface:ObservableConfigUnregisters ALL observers from this config.
Intended for shutdown logic, but can be used at any time.- Specified by:
unregisterConfigObserversin interfaceObservableConfig
-
reloadObservableConfig
public void reloadObservableConfig()Reload the backing config for this observable, notifying all registered observers of the change.
Equivalent to callingreload()- Specified by:
reloadObservableConfigin interfaceObservableConfig
-
set
- Specified by:
setin interfaceConfigurationMethods<ConfigurationSection>
-
put
- Specified by:
putin interfaceConfigurationMethods<ConfigurationSection>
-
putString
- Specified by:
putStringin interfaceConfigurationMethods<ConfigurationSection>
-
putBoolean
- Specified by:
putBooleanin interfaceConfigurationMethods<ConfigurationSection>
-
putByte
- Specified by:
putBytein interfaceConfigurationMethods<ConfigurationSection>
-
putShort
- Specified by:
putShortin interfaceConfigurationMethods<ConfigurationSection>
-
putInteger
- Specified by:
putIntegerin interfaceConfigurationMethods<ConfigurationSection>
-
putInt
- Specified by:
putIntin interfaceConfigurationMethods<ConfigurationSection>
-
putLong
- Specified by:
putLongin interfaceConfigurationMethods<ConfigurationSection>
-
putDouble
- Specified by:
putDoublein interfaceConfigurationMethods<ConfigurationSection>
-
putFloat
- Specified by:
putFloatin interfaceConfigurationMethods<ConfigurationSection>
-
setString
- Specified by:
setStringin interfaceConfigurationMethods<ConfigurationSection>
-
setBoolean
- Specified by:
setBooleanin interfaceConfigurationMethods<ConfigurationSection>
-
setByte
- Specified by:
setBytein interfaceConfigurationMethods<ConfigurationSection>
-
setShort
- Specified by:
setShortin interfaceConfigurationMethods<ConfigurationSection>
-
setInteger
- Specified by:
setIntegerin interfaceConfigurationMethods<ConfigurationSection>
-
setInt
- Specified by:
setIntin interfaceConfigurationMethods<ConfigurationSection>
-
setLong
- Specified by:
setLongin interfaceConfigurationMethods<ConfigurationSection>
-
setDouble
- Specified by:
setDoublein interfaceConfigurationMethods<ConfigurationSection>
-
setFloat
- Specified by:
setFloatin interfaceConfigurationMethods<ConfigurationSection>
-
get
- Specified by:
getin interfaceConfigurationMethods<ConfigurationSection>
-
get
- Specified by:
getin interfaceConfigurationMethods<ConfigurationSection>
-
getConfigurationSection
- Specified by:
getConfigurationSectionin interfaceConfigurationMethods<ConfigurationSection>
-
getConfigurationSequence
- Specified by:
getConfigurationSequencein interfaceConfigurationMethods<ConfigurationSection>
-
getString
- Specified by:
getStringin interfaceConfigurationMethods<ConfigurationSection>
-
getString
- Specified by:
getStringin interfaceConfigurationMethods<ConfigurationSection>
-
isString
- Specified by:
isStringin interfaceConfigurationMethods<ConfigurationSection>
-
getInt
- Specified by:
getIntin interfaceConfigurationMethods<ConfigurationSection>
-
getInt
- Specified by:
getIntin interfaceConfigurationMethods<ConfigurationSection>
-
isInt
- Specified by:
isIntin interfaceConfigurationMethods<ConfigurationSection>
-
getLong
- Specified by:
getLongin interfaceConfigurationMethods<ConfigurationSection>
-
getLong
- Specified by:
getLongin interfaceConfigurationMethods<ConfigurationSection>
-
isLong
- Specified by:
isLongin interfaceConfigurationMethods<ConfigurationSection>
-
getList
- Specified by:
getListin interfaceConfigurationMethods<ConfigurationSection>
-
getList
- Specified by:
getListin interfaceConfigurationMethods<ConfigurationSection>
-
isList
- Specified by:
isListin interfaceConfigurationMethods<ConfigurationSection>
-
getBoolean
- Specified by:
getBooleanin interfaceConfigurationMethods<ConfigurationSection>
-
getBoolean
- Specified by:
getBooleanin interfaceConfigurationMethods<ConfigurationSection>
-
isBoolean
- Specified by:
isBooleanin interfaceConfigurationMethods<ConfigurationSection>
-
getStringList
- Specified by:
getStringListin interfaceConfigurationMethods<ConfigurationSection>
-
getStringList
- Specified by:
getStringListin interfaceConfigurationMethods<ConfigurationSection>
-
getIntegerList
- Specified by:
getIntegerListin interfaceConfigurationMethods<ConfigurationSection>
-
getIntegerList
- Specified by:
getIntegerListin interfaceConfigurationMethods<ConfigurationSection>
-
getByteList
- Specified by:
getByteListin interfaceConfigurationMethods<ConfigurationSection>
-
getByteList
- Specified by:
getByteListin interfaceConfigurationMethods<ConfigurationSection>
-
getDouble
- Specified by:
getDoublein interfaceConfigurationMethods<ConfigurationSection>
-
getDouble
- Specified by:
getDoublein interfaceConfigurationMethods<ConfigurationSection>
-
isDouble
- Specified by:
isDoublein interfaceConfigurationMethods<ConfigurationSection>
-
getByte
- Specified by:
getBytein interfaceConfigurationMethods<ConfigurationSection>
-
getByte
- Specified by:
getBytein interfaceConfigurationMethods<ConfigurationSection>
-
isByte
- Specified by:
isBytein interfaceConfigurationMethods<ConfigurationSection>
-
getShort
- Specified by:
getShortin interfaceConfigurationMethods<ConfigurationSection>
-
getShort
- Specified by:
getShortin interfaceConfigurationMethods<ConfigurationSection>
-
isShort
- Specified by:
isShortin interfaceConfigurationMethods<ConfigurationSection>
-
getFloat
- Specified by:
getFloatin interfaceConfigurationMethods<ConfigurationSection>
-
getFloat
- Specified by:
getFloatin interfaceConfigurationMethods<ConfigurationSection>
-
isFloat
- Specified by:
isFloatin interfaceConfigurationMethods<ConfigurationSection>
-
getBigDecimal
- Specified by:
getBigDecimalin interfaceConfigurationMethods<ConfigurationSection>
-
getBigDecimal
- Specified by:
getBigDecimalin interfaceConfigurationMethods<ConfigurationSection>
-
isNumber
- Specified by:
isNumberin interfaceConfigurationMethods<ConfigurationSection>
-
getKeys
Returns the keys of the config If Deep is enabled, it will dig and find all valid keys that resolve to a value- Specified by:
getKeysin interfaceConfigurationMethods<ConfigurationSection>- Parameters:
deep- Whether to search for all sub-keys- Returns:
- The list of keys found
-
isConfigurationSection
- Specified by:
isConfigurationSectionin interfaceConfigurationMethods<ConfigurationSection>
-
contains
- Specified by:
containsin interfaceConfigurationMethods<ConfigurationSection>
-
isSet
- Specified by:
isSetin interfaceConfigurationMethods<ConfigurationSection>
-
addDefault
- Specified by:
addDefaultin interfaceConfigurationMethods<ConfigurationSection>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceConfigurationMethods<ConfigurationSection>
-
getItemStack
- Specified by:
getItemStackin interfaceConfigurationSection
-
getItemStack
- Specified by:
getItemStackin interfaceConfigurationSection
-
setItemStack
- Specified by:
setItemStackin interfaceConfigurationSection
-
isItemStack
- Specified by:
isItemStackin interfaceConfigurationSection
-
parseItemBuilder
Description copied from interface:ConfigurationSectionParses the subsection at the given key into anItemBuilder. This is equivalent to using:
-ItemBuilderLoader.load(ConfigurationSection)with the subsection at the given key as the argument.- Specified by:
parseItemBuilderin interfaceConfigurationSection- Parameters:
key- The key of the subsection to parse.- Returns:
- The parsed
ItemBuilder.
-
getCurrentPath
- Specified by:
getCurrentPathin interfaceConfigurationMethods<ConfigurationSection>- Specified by:
getCurrentPathin interfaceConfigurationSection
-