Package com.welcome234.pluginsystem
Class Configuration
java.lang.Object
com.welcome234.pluginsystem.Configuration
Configurations are provided as a simple way to store plugin data
This provided configuration system is basic, but plugins can use a more complex configuration library
Default configurations can also be provided
-
Method Summary
Modifier and TypeMethodDescriptionbooleangetBoolean(String key)Gets the boolean value at the keydoubleGets the double value at the keyfloatGets the float value at the keyintgetInteger(String key)Gets the integer value at the keyString[]getKeys()Gets all keys set in this configurationlongGets the long value at the keyGets the string value at the keybooleanChecks if the key is setvoidreload()Reloads this configuration from the diskvoidsave()Saves this configuration to the diskvoidSaves the default configuration to the diskvoidSets the key to the specified boolean valuevoidSets the key to the specified double valuevoidSets the key to the specified float valuevoidSets the key to the specified integer valuevoidSets the key to the specified long valuevoidSets the key to the specified string value
-
Method Details
-
saveDefault
public void saveDefault()Saves the default configuration to the disk- Throws:
IllegalStateException- if the default configuration does not exist or is unreadableIllegalStateException- if the plugin is disabled or is not loaded
-
save
public void save()Saves this configuration to the disk- Throws:
IllegalStateException- if the plugin is disabled or is not loaded
-
reload
public void reload()Reloads this configuration from the disk- Throws:
IllegalStateException- if the plugin is disabled or is not loaded
-
set
Sets the key to the specified string valueIf the value is set to null, the key will be removed or reset to the default value
- Parameters:
key- Key namevalue- String value- Throws:
IllegalArgumentException- if key is null
-
set
Sets the key to the specified boolean value- Parameters:
key- Key namevalue- Boolean value- Throws:
IllegalArgumentException- if key is null
-
set
Sets the key to the specified integer value- Parameters:
key- Key namevalue- Integer value- Throws:
IllegalArgumentException- if key is null
-
set
Sets the key to the specified long value- Parameters:
key- Key namevalue- Long value- Throws:
IllegalArgumentException- if key is null
-
set
Sets the key to the specified float value- Parameters:
key- Key namevalue- Float value- Throws:
IllegalArgumentException- if key is null
-
set
Sets the key to the specified double value- Parameters:
key- Key namevalue- Double value- Throws:
IllegalArgumentException- if key is null
-
getString
Gets the string value at the key- Parameters:
key- Key name- Returns:
- String value
- Throws:
IllegalArgumentException- if key is null
-
getBoolean
Gets the boolean value at the key- Parameters:
key- Key name- Returns:
- Boolean value, or false if not a valid boolean
- Throws:
IllegalArgumentException- if key is null
-
getInteger
Gets the integer value at the key- Parameters:
key- Key name- Returns:
- Integer value, or 0 if not a valid integer
- Throws:
IllegalArgumentException- if key is null
-
getLong
Gets the long value at the key- Parameters:
key- Key name- Returns:
- Long value, or 0 if not a valid long
- Throws:
IllegalArgumentException- if key is null
-
getFloat
Gets the float value at the key- Parameters:
key- Key name- Returns:
- Float value, or 0 if not a valid float
- Throws:
IllegalArgumentException- if key is null
-
getDouble
Gets the double value at the key- Parameters:
key- Key name- Returns:
- Double value, or 0 if not a valid double
- Throws:
IllegalArgumentException- if key is null
-
getKeys
Gets all keys set in this configuration- Returns:
- Keys names in this configuration
-
isSet
Checks if the key is set- Parameters:
key- Key name- Returns:
- Whether set
- Throws:
IllegalArgumentException- if key is null
-