Interface ServerProperty<T>

Type Parameters:
T - the value type
All Superinterfaces:
Supplier<T>

public sealed interface ServerProperty<T> extends Supplier<T>
A named server setting, initialized from the system property it is named after.

A property starts at its default value, or at the parsed value of the system property named name() when one is set. get() returns the current value.

A property is immutable unless <name>.mutable says otherwise, defaulting to the minestom.properties.mutable system property. An immutable property fixes its value when it is built, which lets the compiler fold reads away to a constant, and throws IllegalStateException from set(Object). Configure one through its system property instead, or make that one property writable and leave the rest foldable.

A written value is visible to other threads, but a write racing a read may or may not be seen.

  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the value this property falls back to when its system property is unset.
    get()
    Gets the current value.
    Gets the system property this property reads at startup, which also names it in error messages.
    void
    set(T value)
    Replaces the current value.
    boolean
    Reports whether set(Object) would currently be accepted.
  • Method Details

    • name

      String name()
      Gets the system property this property reads at startup, which also names it in error messages.
      Returns:
      the system property name
    • defaultValue

      T defaultValue()
      Gets the value this property falls back to when its system property is unset.
      Returns:
      the default value
    • get

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

      void set(T value)
      Replaces the current value.
      Parameters:
      value - the new value
      Throws:
      IllegalStateException - if the property is immutable
      IllegalArgumentException - if the value is outside the accepted range
    • writable

      boolean writable()
      Reports whether set(Object) would currently be accepted.
      Returns:
      true if the property still accepts writes