Interface ConfigRef<T>

Type Parameters:
T - the config type
All Superinterfaces:
Supplier<T>
All Known Implementing Classes:
DefaultConfigRef

public interface ConfigRef<T> extends Supplier<T>
A live reference to a config value that updates on reload.

Thread-safe wrapper using volatile + copy-on-write.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addListener(@NotNull Consumer<T> listener)
    Adds a listener for config changes.
    get()
    Gets the current config value.
    @NotNull Class<T>
    Gets the config class this ref wraps.
    boolean
    Checks if the config has been loaded at least once.
    void
    Forces a reload of this config.
    void
    removeListener(@NotNull Consumer<T> listener)
    Removes a previously added listener.
  • Method Details

    • get

      @NotNull T get()
      Gets the current config value.
      Specified by:
      get in interface Supplier<T>
      Returns:
      the current value
    • addListener

      void addListener(@NotNull @NotNull Consumer<T> listener)
      Adds a listener for config changes.
      Parameters:
      listener - the listener to add
    • removeListener

      void removeListener(@NotNull @NotNull Consumer<T> listener)
      Removes a previously added listener.
      Parameters:
      listener - the listener to remove
    • isLoaded

      boolean isLoaded()
      Checks if the config has been loaded at least once.
      Returns:
      true if loaded
    • reload

      void reload()
      Forces a reload of this config.
    • getConfigClass

      @NotNull @NotNull Class<T> getConfigClass()
      Gets the config class this ref wraps.
      Returns:
      the config class