Class ScriptConfig

java.lang.Object
net.botwithus.rs3.script.config.ScriptConfig
All Implemented Interfaces:
ImmutableConfig, MutableConfig

public final class ScriptConfig extends Object implements MutableConfig, ImmutableConfig
The ScriptConfiguration manages the persistence of configurations between the scripts.
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 Details

    • ScriptConfig

      public ScriptConfig(String name, boolean isActive)
  • Method Details

    • containsKey

      public boolean containsKey(String key)
      Checks if the properties map contains the specified key.
      Specified by:
      containsKey in interface ImmutableConfig
      Parameters:
      key - The key to check for
      Returns:
      true if the key is present in the map, false otherwise
    • getProperty

      public String getProperty(String name)
      Gets a value from the properties by a name
      Specified by:
      getProperty in interface ImmutableConfig
      Parameters:
      name - The name of the property
      Example:
                               
                                ScriptConfiguration config = ...;
                                String myValue = config.getProperty("my_property");
                                System.out.println(myValue);
                               
                               
    • addProperty

      public void addProperty(String name, String value)
      Adds a key value pair of strings to the configuration
      Specified by:
      addProperty in interface MutableConfig
      Parameters:
      name - The name of the property
      value - The value of the property
      Example:
                                 
                                  ScriptConfiguration config = ...;
                                  config.addProperty("my_property", "the_value");
                                 
                                 
    • removeProperty

      public void removeProperty(String name)
      Removes a key from the configuration
      Specified by:
      removeProperty in interface MutableConfig
      Parameters:
      name - The name of the property
      Example:
                               
                                ScriptConfiguration config = ...;
                                config.removeProperty("my_property");
                               
                               
    • save

      public void save() throws IOException
      Saves the configuration to a file.
      Specified by:
      save in interface ImmutableConfig
      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 interface MutableConfig