java.lang.Object
net.botwithus.rs3.script.config.ScriptConfig
- All Implemented Interfaces:
ImmutableConfig
,MutableConfig
The ScriptConfiguration manages the persistence of configurations between the scripts.
Examples:
Examples:
//Getting Properties
ScriptConfiguration config = ...;
String myValue = config.getProperty("my_property");
System.out.println(myValue);
//Adding Properties
ScriptConfiguration config = ...;
config.addProperty("my_property", "the_value");
//Removing Properties
ScriptConfiguration config = ...;
config.removeProperty("my_property");
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addProperty
(String name, String value) Adds a key value pair of strings to the configurationboolean
containsKey
(String key) Checks if the properties map contains the specified key.getProperty
(String name) Gets a value from the properties by a namevoid
load()
Loads the properties from the local configs folder.void
removeProperty
(String name) Removes a key from the configurationvoid
save()
Saves the configuration to a file.
-
Constructor Details
-
ScriptConfig
-
-
Method Details
-
containsKey
Checks if the properties map contains the specified key.- Specified by:
containsKey
in interfaceImmutableConfig
- Parameters:
key
- The key to check for- Returns:
- true if the key is present in the map, false otherwise
-
getProperty
Gets a value from the properties by a name- Specified by:
getProperty
in interfaceImmutableConfig
- Parameters:
name
- The name of the property
Example:ScriptConfiguration config = ...; String myValue = config.getProperty("my_property"); System.out.println(myValue);
-
addProperty
Adds a key value pair of strings to the configuration- Specified by:
addProperty
in interfaceMutableConfig
- Parameters:
name
- The name of the propertyvalue
- The value of the property
Example:ScriptConfiguration config = ...; config.addProperty("my_property", "the_value");
-
removeProperty
Removes a key from the configuration- Specified by:
removeProperty
in interfaceMutableConfig
- Parameters:
name
- The name of the property
Example:ScriptConfiguration config = ...; config.removeProperty("my_property");
-
save
Saves the configuration to a file.- Specified by:
save
in interfaceImmutableConfig
- Throws:
IOException
- if an I/O error occurs while saving the configuration
-
load
public void load()Loads the properties from the local configs folder.- Specified by:
load
in interfaceMutableConfig
-