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
  • Dependency management
  • Hiding your options
  • What's the difference?
Export as PDF
  1. Configuration
  2. Creating your config

Option dependencies & hiding options

Dependency management

public MyConfig() {
    addDependency("myOptionName", "myOtherOptionName"); // Disables myOptionName when myOtherOptionName = false
    // The above obviously only works when myOtherOptionName is a boolean-typed option.
    
    addDependency("myOtherOtherOptionName", () -> Property.Display.HIDDEN); // Hides myOtherOtherOptionName
    
    addDependency("myOtherOtherOtherOptionName", "myOptionName", true); // Hides myOtherOtherOtherOptionName when myOptionName is false
}
init {
    addDependency("myOptionName", "myOtherOptionName") // Disables myOptionName when myOtherOptionName = false
    // The above obviously only works when myOtherOptionName is a boolean-typed option.
    
    addDependency("myOtherOtherOptionName") { Property.Display.HIDDEN } // Hides myOtherOtherOptionName
    
    addDependency("myOtherOtherOtherOptionName", "myOptionName", true) // Hides myOtherOtherOtherOptionName when myOptionName is false
}

Hiding your options

public MyConfig() {
    hideIf("myOptionName", () -> true); // Hides myOptionName
    
    hideIf("myOptionName", "myOtherOptionName"); // Hides myOptionName if myOtherOptionName is false
    // The above obviously only works when myOtherOptionName is a boolean-typed option.
}
init {
    hideIf("myOptionName") { true } // Hides myOptionName
    
    hideIf("myOptionName", "myOtherOptionName") // Hides myOptionName if myOtherOptionName is false
    // The above obviously only works when myOtherOptionName is a boolean-typed option.
}

What's the difference?

You can use addDependency to fine-tune the display status of your options based on your own conditions or other options. By default, simply using addDependency and passing the options of your choosing will cause the dependant to be disabled rather than hidden.

hideIf will ALWAYS completely hide the option passed to it based on the condition(s) provided as opposed to having to pick a display status.

PreviousCreating your configNextListening for option changes

Last updated 5 months ago