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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProperty(String name, String value) Adds a key value pair of strings to the configurationbooleancontainsKey(String key) Checks if the properties map contains the specified key.getProperty(String name) Gets a value from the properties by a namevoidload()Loads the properties from the local configs folder.voidremoveProperty(String name) Removes a key from the configurationvoidsave()Saves the configuration to a file.
-
Constructor Details
-
ScriptConfig
-
-
Method Details
-
containsKey
Checks if the properties map contains the specified key.- Specified by:
containsKeyin 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:
getPropertyin 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:
addPropertyin 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:
removePropertyin interfaceMutableConfig- Parameters:
name- The name of the property
Example:ScriptConfiguration config = ...; config.removeProperty("my_property");
-
save
Saves the configuration to a file.- Specified by:
savein 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:
loadin interfaceMutableConfig
-