---
description: Making your bot configurable.
---

# Settings

The DefaultUI will automatically generate JavaFX controls and add them to the UI on your behalf, all you have to do is create an interface telling RuneMate about the settings. These settings are stored in the bot StoredProperties automatically, and retrieved from the previous session.

When the bot starts, RuneMate will scan the bot main class for any fields annotated **@SettingsProvider** and inject a reference to an instance of that class, for example:

```java
public class ExampleBot extends LoopingBot {

    @SettingsProvider(updatable = true)
    private ExampleSettings settings;

    @Override
    public void onLoop() {
        if (settings.logsToChop() > 1000) {
            //Do something!
        }
    }
}
```

### The Settings Descriptor

Settings are declared using an interface that extends **Settings**, which must use the following format:

* Must be an interface
* Must be annotating with **@SettingsGroup**
* Each individual settings is:
  * Described using a **default method** where the return value is the default value
  * Annotated with **@Setting** which contains the setting metadata

Here is a basic example:

```java
@SettingsGroup
public interface ExampleSettings extends Settings {
        
    @Setting(key = "logsToChop", title = "Logs to Chop", description = "How many logs the bot should chop")
    default int logsToChop() {
        return 1000;
    }
        
}
```



### @SettingsGroup

This class-level annotation tells RuneMate that this class describes settings. I has an optional parameter `group` will be useful in future, but it's only purpose currently is to provide version control.

### @Setting

This annotation is used to declare various characteristics about the setting:

<table><thead><tr><th width="132">Attribute</th><th>Description</th></tr></thead><tbody><tr><td>key</td><td>unique identifier for saving the value in persistent storage</td></tr><tr><td>title</td><td>the name of the setting as it will appear in the user interface</td></tr><tr><td>order</td><td>the order in which the setting will be displayed in the user interface, ascending</td></tr><tr><td>secret</td><td>only for Strings, whether the value should be treated as a password</td></tr><tr><td>disabled</td><td>whether the UI element should be disabled</td></tr><tr><td>hidden</td><td>whether the UI element should be hidden</td></tr><tr><td>description</td><td>will show as the tooltip when hovering the UI element</td></tr><tr><td>section</td><td>tells RuneMate which section the setting should be included in, by default the "General" section</td></tr><tr><td>converter</td><td>SettingsConverter implementation for un/marshalling for special setting types</td></tr></tbody></table>

### Special Annotations

There are various "special" annotations which are data-type specific.

* **@Range** - for **int** settings, described the maximum, minimum and step values.
* **@Suffix** - for **int** settings, appends a suffix to the value in the ui (eg. "gp")
* **@Multiline** - for **String** settings, uses a TextArea instead of a TextField

### Setting Values Programmatically

Setting values can be assigned programmatically by adding a single-argument setter method to your descriptor interface, with the same **key** as the getter:

```java
@Setting(key = "logsToChop", title = "Logs to Chop", description = "How many logs the bot should chop")
default int logsToChop() {
    return 1000;
}

@Setting(key = "logsToChop", title = "")
void setLogsToChop(int logs);
```
