Package preponderous.ponder.misc
Class ConfigurationFile
java.lang.Object
preponderous.ponder.misc.ConfigurationFile
The ConfigurationFile class stands for one Configuration File.
The default operation of this class is a bridge between BukkitAPI and this API.
The default values of this class are 'config.yml' and 'load from jar'.
- Since:
- 14/06/2021 - 09:34
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
Constant which can be used throughout the creation of a Configuration File.static boolean
Constant which can be used throughout the creation of a Configuration File. -
Constructor Summary
ConstructorDescriptionConstructor to generate the default ConfigurationFile.ConfigurationFile(@NotNull String name, boolean preloadedResource)
Constructor to generate a ConfigurationFile.ConfigurationFile(@NotNull String name, boolean preloadedResource, org.bukkit.plugin.java.JavaPlugin plugin)
Constructor to generate a ConfigurationFile and initialize it with a java plugin.ConfigurationFile(@NotNull String name, @NotNull String extension, boolean preloadedResource)
Constructor to generate a ConfigurationFile. -
Method Summary
Modifier and TypeMethodDescription@NotNull Object
Method to get something at the specified path.boolean
getBoolean(@NotNull String path)
Method to obtain a boolean at the given path.getBooleanList(@NotNull String path)
Method to obtain a boolean-list at the given path.boolean
getBooleanOrDefault(@NotNull String path, boolean defaultValue)
Method to obtain a boolean at the given path or a default value if not found.double
Method to obtain a double at the given path.getDoubleList(@NotNull String path)
Method to obtain a double-list at the given path.double
getDoubleOrDefault(@NotNull String path, double defaultValue)
Method to obtain a double at the given path or a default value if not found.float
Method to obtain a float at the given path.getFloatList(@NotNull String path)
Method to obtain a float-list at the given path.float
getFloatOrDefault(@NotNull String path, float defaultValue)
Method to obtain a float at the given path or a default value if not found.int
Method to obtain an integer at the given path.getIntList(@NotNull String path)
Method to obtain a int-list at the given path.int
getIntOrDefault(@NotNull String path, int defaultValue)
Method to obtain an integer at the given path or a default value if not found.@NotNull List<?>
Method to obtain a list at the given path.long
Method to obtain a long at the given path.getLongList(@NotNull String path)
Method to obtain a long-list at the given path.long
getLongOrDefault(@NotNull String path, long defaultValue)
Method to obtain a long at the given path or a default value if not found.@NotNull Object
getOrDefault(@NotNull String path, @NotNull Object defaultValue)
Method to get something at the specified path.org.bukkit.plugin.java.JavaPlugin
Method to get the plugin associated with the configuration file.@Nullable org.bukkit.configuration.ConfigurationSection
getSection(@NotNull String path)
Method to obtain aConfigurationSection
from path.@NotNull String
Method to obtain a String from the Configuration using Yaml Methods.getStringList(@NotNull String path)
Method to obtain a string-list at the given path.@NotNull String
getStringOrDefault(@NotNull String path, @NotNull String defaultValue)
Method to obtain a String or return a Default Value if not found.boolean
hasSection(@NotNull String path)
Method to determine if the Configuration File has the specified ConfigurationSection.void
initializePlugin(org.bukkit.plugin.java.JavaPlugin plugin)
Method to initialize the plugin for the configuration file.void
Method to save the Configuration File.void
Method to set the value at a given path.void
Method to set the value at a given path and optionally save it, when done.
-
Field Details
-
LOAD_FROM_JAR
public static final boolean LOAD_FROM_JARConstant which can be used throughout the creation of a Configuration File.- See Also:
- Constant Field Values
-
CREATE_EMPTY_FILE
public static final boolean CREATE_EMPTY_FILEConstant which can be used throughout the creation of a Configuration File.- See Also:
- Constant Field Values
-
-
Constructor Details
-
ConfigurationFile
public ConfigurationFile()Constructor to generate the default ConfigurationFile.The default name is 'config.yml' and it loads it from the Jar.
-
ConfigurationFile
public ConfigurationFile(@NotNull @NotNull String name, boolean preloadedResource, org.bukkit.plugin.java.JavaPlugin plugin)Constructor to generate a ConfigurationFile and initialize it with a java plugin.- Parameters:
name
- of the file.preloadedResource
- or not.true
if the Jar contains a default version of this file.plugin
-JavaPlugin
used to initialize the configuration file.- Since:
- 10/27/2021
-
ConfigurationFile
Constructor to generate a ConfigurationFile.- Parameters:
name
- of the file.preloadedResource
- or not.true
if the Jar contains a default version of this file.
-
ConfigurationFile
public ConfigurationFile(@NotNull @NotNull String name, @NotNull @NotNull String extension, boolean preloadedResource)Constructor to generate a ConfigurationFile.- Parameters:
name
- of the file.extension
- of the file.preloadedResource
- or not.true
if the Jar contains a default version of this file.
-
-
Method Details
-
saveConfig
public void saveConfig()Method to save the Configuration File.- See Also:
FileConfiguration.save(File)
-
getSection
@Nullable public @Nullable org.bukkit.configuration.ConfigurationSection getSection(@NotNull @NotNull String path)Method to obtain aConfigurationSection
from path.- Parameters:
path
- to obtain the section from.- Returns:
ConfigurationSection
ornull
(If not found).- See Also:
hasSection(String)
-
hasSection
Method to determine if the Configuration File has the specified ConfigurationSection.- Parameters:
path
- to determine existence.- Returns:
true
if it does.
-
get
Method to get something at the specified path.- Parameters:
path
- of the data.- Returns:
Object
never,null
.
-
getOrDefault
@NotNull public @NotNull Object getOrDefault(@NotNull @NotNull String path, @NotNull @NotNull Object defaultValue)Method to get something at the specified path.- Parameters:
path
- of the data.defaultValue
- to send back if there is no data found.- Returns:
Object
never,null
.
-
getString
Method to obtain a String from the Configuration using Yaml Methods.If the String isn't found at the path specified, it defaults to 'path is missing' to help with development.
- Parameters:
path
- to obtain the value at.- Returns:
- String regardless of existence.
- See Also:
getStringOrDefault(String, String)
-
getStringOrDefault
@NotNull public @NotNull String getStringOrDefault(@NotNull @NotNull String path, @NotNull @NotNull String defaultValue)Method to obtain a String or return a Default Value if not found.- Parameters:
path
- to obtain the value at.defaultValue
- if the value isn't found.- Returns:
- String regardless of existence.
-
getInt
Method to obtain an integer at the given path.- Parameters:
path
- to get the value at.- Returns:
Integer
or0
-
getIntOrDefault
Method to obtain an integer at the given path or a default value if not found.- Parameters:
path
- to get the value at.defaultValue
- to return if not found.- Returns:
Integer
or the defaultValue.
-
getDouble
Method to obtain a double at the given path.- Parameters:
path
- to get the value at.- Returns:
Double
or0.0D
-
getDoubleOrDefault
Method to obtain a double at the given path or a default value if not found.- Parameters:
path
- to get the value at.defaultValue
- to return if not found.- Returns:
Double
or the defaultValue.
-
getFloat
Method to obtain a float at the given path.- Parameters:
path
- to get the value at.- Returns:
Float
or0.0F
-
getFloatOrDefault
Method to obtain a float at the given path or a default value if not found.- Parameters:
path
- to get the value at.defaultValue
- to return if not found.- Returns:
Float
or the defaultValue.
-
getLong
Method to obtain a long at the given path.- Parameters:
path
- to get the value at.- Returns:
Long
or0L
-
getLongOrDefault
Method to obtain a long at the given path or a default value if not found.- Parameters:
path
- to get the value at.defaultValue
- to return if not found.- Returns:
Long
or the defaultValue.
-
getBoolean
Method to obtain a boolean at the given path.- Parameters:
path
- to get the value at.- Returns:
Boolean
orfalse
-
getBooleanOrDefault
Method to obtain a boolean at the given path or a default value if not found.- Parameters:
path
- to get the value at.defaultValue
- to return if not found.- Returns:
Boolean
or the defaultValue.
-
getList
Method to obtain a list at the given path.- Parameters:
path
- to get the value at.- Returns:
List
-
getStringList
Method to obtain a string-list at the given path. -
getIntList
Method to obtain a int-list at the given path. -
getLongList
Method to obtain a long-list at the given path. -
getDoubleList
Method to obtain a double-list at the given path. -
getFloatList
Method to obtain a float-list at the given path. -
getBooleanList
Method to obtain a boolean-list at the given path. -
set
Method to set the value at a given path.This method calls
set(String, Object, boolean)
with a default offalse
.- Parameters:
path
- to set as value.value
- to set at the location of the path.- See Also:
set(String, Object, boolean)
-
set
Method to set the value at a given path and optionally save it, when done.- Parameters:
path
- to set as value.value
- to set at the location of the path.save
- to determine if the plugin should save after the value has been set.- See Also:
saveConfig()
-
initializePlugin
public void initializePlugin(org.bukkit.plugin.java.JavaPlugin plugin)Method to initialize the plugin for the configuration file.- Since:
- 10/27/2021
-
getPlugin
public org.bukkit.plugin.java.JavaPlugin getPlugin()Method to get the plugin associated with the configuration file.- Since:
- 10/27/2021
-