Interface Config
- All Known Implementing Classes:
BaseConfig, JsonConfig, YamlConfig
public interface Config
Represents a plugin configuration file.
Config provides methods to read and write configuration values with type safety. Supports nested sections, lists, and various data types.
Example Usage:
Config config = plugin.getConfig();
// Get values with defaults
String name = config.getString("server.name", "Default Server");
int maxPlayers = config.getInt("server.max-players", 20);
// Set values
config.set("server.name", "My Server");
config.set("server.enabled", true);
// Save changes
config.save();
- Since:
- 1.0.4
- Version:
- 1.0.4
- Author:
- HytaleLoader
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddDefault(String path, Object value) Adds default values to the config.booleanChecks if a path exists in the config.Gets a value from the config.Gets a value with a default fallback.booleangetBoolean(String path) Gets a boolean value.booleangetBoolean(String path, boolean def) Gets a boolean value with default.doubleGets a double value.doubleGets a double value with default.getFile()Gets the file this config is bound to.intGets an integer value.intGets an integer value with default.getKeys(boolean deep) Gets all keys in the config.List<?> Gets a list value.List<?> Gets a list value with default.getSection(String path) Gets a config section.Gets a string value.Gets a string value with default.getStringList(String path) Gets a string list.Gets all values as a map.voidreload()Reloads the config from file.voidsave()Saves the config to file.voidSets a value in the config.voidsetDefaults(Map<String, Object> defaults) Sets the default values for this config.
-
Method Details
-
get
-
get
-
set
-
getString
-
getString
-
getInt
Gets an integer value.- Parameters:
path- the path to the value- Returns:
- the integer value, or 0 if not found
-
getInt
Gets an integer value with default.- Parameters:
path- the path to the valuedef- the default value- Returns:
- the integer value, or default if not found
-
getDouble
Gets a double value.- Parameters:
path- the path to the value- Returns:
- the double value, or 0.0 if not found
-
getDouble
Gets a double value with default.- Parameters:
path- the path to the valuedef- the default value- Returns:
- the double value, or default if not found
-
getBoolean
Gets a boolean value.- Parameters:
path- the path to the value- Returns:
- the boolean value, or false if not found
-
getBoolean
Gets a boolean value with default.- Parameters:
path- the path to the valuedef- the default value- Returns:
- the boolean value, or default if not found
-
getList
-
getList
-
getStringList
-
getSection
Gets a config section.- Parameters:
path- the path to the section- Returns:
- the config section, or null if not found
-
contains
Checks if a path exists in the config.- Parameters:
path- the path to check- Returns:
- true if the path exists
-
getKeys
-
getValues
-
save
-
reload
Reloads the config from file.- Throws:
IOException- if reload fails
-
getFile
-
setDefaults
-
addDefault
-