Class StandaloneConfig
java.lang.Object
com.kamikazejam.kamicommon.configuration.standalone.AbstractConfig<YamlConfigurationStandalone>
com.kamikazejam.kamicommon.configuration.standalone.StandaloneConfig
- All Implemented Interfaces:
ConfigurationMethods<ConfigurationSectionStandalone>
,ConfigurationSectionStandalone
- Direct Known Subclasses:
StandaloneConfigExt
public class StandaloneConfig
extends AbstractConfig<YamlConfigurationStandalone>
implements ConfigurationSectionStandalone
A class that represents a configuration file (Meant for implementations WITHOUT a JavaPlugin object available)
If you have a JavaPlugin object, it is recommended to use @KamiConfig instead
This is an extension of a YamlConfiguration, so all get, set, and put methods are available.
IF 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
If you have a JavaPlugin object, it is recommended to use @KamiConfig instead
This is an extension of a YamlConfiguration, so all get, set, and put methods are available.
IF 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
AbstractConfig.save()
and reload()
-
Constructor Summary
ConstructorsConstructorDescriptionStandaloneConfig
(@NotNull LoggerService logger, @NotNull File file) Creates a new config instance with the given logger 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.
- SeegetDefaultIS(LoggerService, File)
StandaloneConfig
(@NotNull LoggerService logger, @NotNull File file, @Nullable Supplier<InputStream> defaultsStream) Creates a new config instance with the given logger 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 TypeMethodDescriptionvoid
addDefault
(String key, Object o) boolean
getBigDecimal
(String key) getBigDecimal
(String key, BigDecimal def) boolean
getBoolean
(String key) boolean
getBoolean
(String key, boolean def) byte
byte
getByteList
(String key) getByteList
(String key, List<Byte> def) @NotNull MemorySectionStandalone
@NotNull ConfigurationSequenceStandalone
static @UnknownNullability InputStream
getDefaultIS
(@NotNull LoggerService logger, File configFile) double
double
protected @NotNull File
getFile()
float
float
int
int
getIntegerList
(String key) getIntegerList
(String key, List<Integer> 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<?>
long
long
short
short
getStringList
(String key) getStringList
(String key, List<String> def) protected YamlConfigurationStandalone
boolean
boolean
boolean
boolean
boolean
isEmpty()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
void
void
putBoolean
(String key, boolean value) void
void
void
void
void
putInteger
(String key, int value) void
void
void
void
reload()
Reloads the config from the filevoid
void
setBoolean
(String key, boolean value) void
void
void
void
void
setInteger
(String key, int value) void
void
void
Methods inherited from class com.kamikazejam.kamicommon.configuration.standalone.AbstractConfig
isChanged, save, save, setChanged
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.kamikazejam.kamicommon.yaml.base.ConfigurationMethods
isChanged, setChanged
-
Constructor Details
-
StandaloneConfig
Creates a new config instance with the given logger 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.
- SeegetDefaultIS(LoggerService, File)
-
StandaloneConfig
public StandaloneConfig(@NotNull @NotNull LoggerService logger, @NotNull @NotNull File file, @Nullable @Nullable Supplier<InputStream> defaultsStream) Creates a new config instance with the given logger 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.
-
-
Method Details
-
reload
public void reload()Description copied from class:AbstractConfig
Reloads the config from the file- Specified by:
reload
in classAbstractConfig<YamlConfigurationStandalone>
-
getYamlConfiguration
- Specified by:
getYamlConfiguration
in classAbstractConfig<YamlConfigurationStandalone>
- Returns:
- The YamlConfiguration associated with this config
-
getFile
- Specified by:
getFile
in classAbstractConfig<YamlConfigurationStandalone>
- Returns:
- The file associated with this config
-
set
- Specified by:
set
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
put
- Specified by:
put
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
putString
- Specified by:
putString
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
putBoolean
- Specified by:
putBoolean
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
putByte
- Specified by:
putByte
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
putShort
- Specified by:
putShort
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
putInteger
- Specified by:
putInteger
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
putInt
- Specified by:
putInt
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
putLong
- Specified by:
putLong
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
putDouble
- Specified by:
putDouble
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
putFloat
- Specified by:
putFloat
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
setString
- Specified by:
setString
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
setBoolean
- Specified by:
setBoolean
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
setByte
- Specified by:
setByte
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
setShort
- Specified by:
setShort
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
setInteger
- Specified by:
setInteger
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
setInt
- Specified by:
setInt
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
setLong
- Specified by:
setLong
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
setDouble
- Specified by:
setDouble
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
setFloat
- Specified by:
setFloat
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
get
- Specified by:
get
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
get
- Specified by:
get
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getConfigurationSection
- Specified by:
getConfigurationSection
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getConfigurationSequence
- Specified by:
getConfigurationSequence
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getString
- Specified by:
getString
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getString
- Specified by:
getString
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isString
- Specified by:
isString
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getInt
- Specified by:
getInt
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getInt
- Specified by:
getInt
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isInt
- Specified by:
isInt
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getLong
- Specified by:
getLong
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getLong
- Specified by:
getLong
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isLong
- Specified by:
isLong
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getList
- Specified by:
getList
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getList
- Specified by:
getList
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isList
- Specified by:
isList
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getBoolean
- Specified by:
getBoolean
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getBoolean
- Specified by:
getBoolean
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isBoolean
- Specified by:
isBoolean
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getStringList
- Specified by:
getStringList
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getStringList
- Specified by:
getStringList
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getIntegerList
- Specified by:
getIntegerList
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getIntegerList
- Specified by:
getIntegerList
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getByteList
- Specified by:
getByteList
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getByteList
- Specified by:
getByteList
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getDouble
- Specified by:
getDouble
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getDouble
- Specified by:
getDouble
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isDouble
- Specified by:
isDouble
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getByte
- Specified by:
getByte
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getByte
- Specified by:
getByte
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isByte
- Specified by:
isByte
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getShort
- Specified by:
getShort
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getShort
- Specified by:
getShort
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isShort
- Specified by:
isShort
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getFloat
- Specified by:
getFloat
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getFloat
- Specified by:
getFloat
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isFloat
- Specified by:
isFloat
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getBigDecimal
- Specified by:
getBigDecimal
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getBigDecimal
- Specified by:
getBigDecimal
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isNumber
- Specified by:
isNumber
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
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:
getKeys
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
- Parameters:
deep
- Whether to search for all sub-keys- Returns:
- The list of keys found
-
isConfigurationSection
- Specified by:
isConfigurationSection
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
contains
- Specified by:
contains
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isSet
- Specified by:
isSet
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
addDefault
- Specified by:
addDefault
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getCurrentPath
- Specified by:
getCurrentPath
in interfaceConfigurationMethods<ConfigurationSectionStandalone>
-
getDefaultIS
public static @UnknownNullability InputStream getDefaultIS(@NotNull @NotNull LoggerService logger, File configFile)
-