Interface ConfigValue<T>

Type Parameters:
T - the value's type; values are never null
All Superinterfaces:
ConfigNode, Supplier<T>
All Known Implementing Classes:
ConfigValueImpl

@NonExtendable public interface ConfigValue<T> extends ConfigNode, Supplier<T>
One typed setting. Reading is cheap and thread-safe, so keep the handle and call get() where the value is used instead of caching it: the value can change through the config screen, a command, the file being edited, or the server syncing its own.
  • Method Details

    • get

      T get()
      The current value.
      Specified by:
      get in interface Supplier<T>
    • set

      void set(T value)
      Changes the value in memory and notifies listeners; Config.save() writes it. A value the type corrects (a number out of range, say) is stored corrected. A ConfigScope.STARTUP value only changes its stored value, for the next start.
      Throws:
      IllegalArgumentException - when the value isn't valid and can't be corrected
    • getStored

      T getStored()
      The value in the file. It equals get() except for a ConfigScope.STARTUP value changed since the game started: get() keeps the value the game started with, and this one applies after a restart.
    • isRestartPending

      default boolean isRestartPending()
      Whether a changed ConfigScope.STARTUP value is waiting for a restart.
    • validate

      ValidationResult<T> validate(T value)
      Checks a value against the type and the entry's own validators, without setting it.
    • getDefault

      T getDefault()
    • reset

      default void reset()
      Sets the default value back.
    • isDefault

      default boolean isDefault()
    • type

      ConfigType<T> type()
    • restartRequirement

      RestartRequirement restartRequirement()
    • isSynced

      boolean isSynced()
      Whether a synced config sends this value to clients. Off for server secrets (a webhook URL, a password), which stay on the server and can't be edited from a client.
    • startupSync

      StartupSync startupSync()
      How a synced ConfigScope.STARTUP value is reconciled with the server's; ignored by other scopes.
    • aliases

      List<String> aliases()
      The old keys (or dotted paths from the root) this value is still read from, for renamed or moved settings.
    • dependency

      Optional<ConfigDependency<?>> dependency()
      The value this one depends on, if it was built with enabledWhen.
    • isActive

      default boolean isActive()
      Whether the dependency, if any, is currently met. The config screen greys the value out when it isn't.
    • addListener

      void addListener(ConfigValue.ChangeListener<T> listener)
      Called on the thread that changed the value, after it changed.
    • removeListener

      boolean removeListener(ConfigValue.ChangeListener<T> listener)