Appearance
Settings
Settings are fields of your module's config class. An annotation decides how they appear in the mod menu. LynxClient builds the page, saves the values (shared by every profile and Minecraft version) and includes them in the search.
java
public static final class Config extends ModuleConfig {
@Switch
public final ConfigProperty<Boolean> showSeconds = ConfigProperty.of(true);
@Slider(min = 1, max = 20, step = 1)
public final ConfigProperty<Integer> samples = ConfigProperty.of(10);
@Dropdown
public final ConfigProperty<SpeedUnit> unit = ConfigProperty.of(SpeedUnit.BLOCKS_PER_SECOND);
@Color(alpha = true)
public final ConfigProperty<Integer> color = ConfigProperty.of(0xFFFFFFFF);
@Keybind
public final ConfigProperty<Integer> resetKey = ConfigProperty.of(Keys.UNKNOWN);
@Text(maxLength = 32)
public final ConfigProperty<String> prefix = ConfigProperty.of("Speed");
@Hidden
public final ConfigProperty<Integer> lastValue = ConfigProperty.of(0);
}Fields must be public final ConfigProperty<…> with a default value.
Annotations
| Annotation | Type | Shown as |
|---|---|---|
@Switch | Boolean | Switch |
@Slider(min, max, step) | Integer, Float, Double | Slider; step = 0 is continuous |
@Dropdown | any enum | Choice between the constants |
@Color(alpha) | Integer (ARGB) | Colour picker, with transparency if alpha = true |
@Keybind | Integer (key code, see Keys) | Key or mouse button |
@Text(maxLength) | String | Text field |
@Hidden | any | Not shown, but saved (for values your code sets) |
Reading and writing
java
int n = config().samples.get();
config().prefix.set("Tempo");
config().prefix.reset(); // back to the default
config().unit.onChange(unit -> recalc()); // after every change: menu, server rule or codeNames and descriptions
Texts come from your translation files, see Translations:
json
{
"module.my_addon_speed.samples.name": "Smoothing",
"module.my_addon_speed.samples.description": "How many ticks are averaged.",
"enum.SpeedUnit.BLOCKS_PER_SECOND": "Blocks per second"
}