OneConfig V1
  • Welcome
  • Documentation license
  • Introduction
    • Getting started
  • Configuration
    • Creating your config
      • Option dependencies & hiding options
      • Listening for option changes
    • Available options
      • Boolean options
        • Switch option
        • Checkbox option
      • Number options
        • Slider option
        • Number option
      • Selector options
        • Dropdown option
        • Radio button option
      • Text option
      • Color option
      • Keybind option
      • Buttons
      • Accordions
      • Decorations
    • Creating your own options
  • Commands
    • Annotation-based commands
    • Tree-based commands
  • Events
    • Using the events system
      • Callback events
      • Subscriber events
  • Utilities Module
    • Hypixel utilities
    • IO utilities
    • Networking utilities
    • JSON utilities
    • Multithreading
    • Platform-specific utilities
  • Migration
    • Temporary V0 -> V1 migration guide
    • Migrating your configs from Vigilance
Powered by GitBook
On this page
Export as PDF
  1. Configuration
  2. Creating your config

Listening for option changes

Monitoring changes to options for any reason is simple, thanks to the convenient methods provided by OneConfig. You can use them like so:

public MyConfig() {
    addCallback("myOptionName", () -> {
        System.out.println("myOptionName changed!");
    });
}
init {
    addCallback("myOptionName") {
        println("myOptionName changed!");
    }
}

Easy enough, eh? But what if we want to know the new value at the time of the change?

public MyConfig() {
    addCallback<Boolean>("myOptionName", (value) -> {
        System.out.println("myOptionName value: " + value);
    });
}
init {
    addCallback<Boolean>("myOptionName") { value ->
        println("myOptionName value: $value")
    }
}
PreviousOption dependencies & hiding optionsNextAvailable options

Last updated 5 months ago