Settings
Making your bot configurable.
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:
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:
@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:
Attribute | Description |
---|---|
key | unique identifier for saving the value in persistent storage |
title | the name of the setting as it will appear in the user interface |
order | the order in which the setting will be displayed in the user interface, ascending |
secret | only for Strings, whether the value should be treated as a password |
disabled | whether the UI element should be disabled |
hidden | whether the UI element should be hidden |
description | will show as the tooltip when hovering the UI element |
section | tells RuneMate which section the setting should be included in, by default the "General" section |
converter | SettingsConverter implementation for un/marshalling for special setting types |
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:
Last updated