Package dev.crafty.core.config
Class SectionWrapper
java.lang.Object
dev.crafty.core.config.SectionWrapper
Wrapper class for ConfigurationSection that provides Optional-based access to configuration values.
This class wraps all ConfigurationSection methods to return Optional values instead of null,
providing safer access to configuration data.
-
Constructor Summary
ConstructorsConstructorDescriptionSectionWrapper
(org.bukkit.configuration.ConfigurationSection section) Create a new SectionWrapper. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check if a path exists in this section.boolean
exists()
Check if the wrapped section exists and is not null.Get an object value.Get an object value with a default.getBoolean
(String path) Get a boolean value.boolean
getBoolean
(String path, boolean defaultValue) Get a boolean value with a default.getBooleanList
(String path) Get a boolean list value.getByteList
(String path) Get a byte list value.getCharacterList
(String path) Get a character list value.Optional
<org.bukkit.Color> Get a color value.org.bukkit.Color
Get a color value with a default.Get the current path of this section.Get a double value.double
Get a double value with a default.getDoubleList
(String path) Get a double list value.getFloatList
(String path) Get a float list value.Get an integer value.int
Get an integer value with a default.getIntegerList
(String path) Get an integer list value.Optional
<org.bukkit.inventory.ItemStack> getItemStack
(String path) Get an item stack value.org.bukkit.inventory.ItemStack
getItemStack
(String path, org.bukkit.inventory.ItemStack defaultValue) Get an item stack value with a default.getKeys
(boolean deep) Get all keys in this section.Get a list value.List
<?> Get a list value with a default.Optional
<org.bukkit.Location> getLocation
(String path) Get a location value.org.bukkit.Location
getLocation
(String path, org.bukkit.Location defaultValue) Get a location value with a default.Get a long value.long
Get a long value with a default.getLongList
(String path) Get a long list value.getMapList
(String path) Get a map list value.getName()
Get the name of this section.Optional
<org.bukkit.OfflinePlayer> getOfflinePlayer
(String path) Get an offline player value.org.bukkit.OfflinePlayer
getOfflinePlayer
(String path, org.bukkit.OfflinePlayer defaultValue) Get an offline player value with a default.Optional
<org.bukkit.configuration.ConfigurationSection> Get the underlying ConfigurationSection.getSection
(String path) Get a nested configuration section.getShortList
(String path) Get a short list value.Get a string value.Get a string value with a default.getStringList
(String path) Get a string list value.getValues
(boolean deep) Get all values in this section.Optional
<org.bukkit.util.Vector> Get a vector value.org.bukkit.util.Vector
Get a vector value with a default.boolean
Check if a path exists and is of the specified type.
-
Constructor Details
-
SectionWrapper
public SectionWrapper(org.bukkit.configuration.ConfigurationSection section) Create a new SectionWrapper.- Parameters:
section
- The ConfigurationSection to wrap, can be null
-
-
Method Details
-
exists
public boolean exists()Check if the wrapped section exists and is not null.- Returns:
- true if the section exists, false otherwise
-
getSection
Get the underlying ConfigurationSection.- Returns:
- Optional containing the section, or empty if null
-
getSection
Get a nested configuration section.- Parameters:
path
- The path to the section- Returns:
- SectionWrapper for the nested section
-
getKeys
Get all keys in this section.- Parameters:
deep
- Whether to get keys from nested sections- Returns:
- Optional containing the set of keys
-
getValues
Get all values in this section.- Parameters:
deep
- Whether to get values from nested sections- Returns:
- Optional containing the map of values
-
contains
Check if a path exists in this section.- Parameters:
path
- The path to check- Returns:
- true if the path exists, false otherwise
-
isSet
Check if a path exists and is of the specified type.- Parameters:
path
- The path to checkclazz
- The expected type- Returns:
- true if the path exists and is of the specified type
-
getCurrentPath
Get the current path of this section.- Returns:
- Optional containing the current path
-
getName
Get the name of this section.- Returns:
- Optional containing the section name
-
get
Get an object value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the object value
-
get
Get an object value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-
getString
Get a string value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the string value
-
getString
Get a string value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-
getBoolean
Get a boolean value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the boolean value
-
getBoolean
Get a boolean value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-
getInt
Get an integer value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the integer value
-
getInt
Get an integer value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-
getLong
Get a long value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the long value
-
getLong
Get a long value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-
getDouble
Get a double value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the double value
-
getDouble
Get a double value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-
getList
Get a list value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the list value
-
getList
Get a list value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-
getStringList
Get a string list value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the string list value
-
getIntegerList
Get an integer list value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the integer list value
-
getBooleanList
Get a boolean list value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the boolean list value
-
getDoubleList
Get a double list value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the double list value
-
getFloatList
Get a float list value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the float list value
-
getLongList
Get a long list value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the long list value
-
getByteList
Get a byte list value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the byte list value
-
getCharacterList
Get a character list value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the character list value
-
getShortList
Get a short list value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the short list value
-
getMapList
Get a map list value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the map list value
-
getVector
Get a vector value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the vector value
-
getVector
Get a vector value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-
getOfflinePlayer
Get an offline player value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the offline player value
-
getOfflinePlayer
public org.bukkit.OfflinePlayer getOfflinePlayer(String path, org.bukkit.OfflinePlayer defaultValue) Get an offline player value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-
getItemStack
Get an item stack value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the item stack value
-
getItemStack
public org.bukkit.inventory.ItemStack getItemStack(String path, org.bukkit.inventory.ItemStack defaultValue) Get an item stack value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-
getColor
Get a color value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the color value
-
getColor
Get a color value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-
getLocation
Get a location value.- Parameters:
path
- The path to the value- Returns:
- Optional containing the location value
-
getLocation
Get a location value with a default.- Parameters:
path
- The path to the valuedefaultValue
- The default value if not found- Returns:
- The value or default
-