Class ConfigKey<T>

java.lang.Object
fr.robie.machineengine.api.config.ConfigKey<T>

public final class ConfigKey<T> extends Object
One setting of a ConfigFile: its path (limits.max-machines-per-chunk), its type, its default, the comment written above it, and whether a reload may change it.

Keys are immutable: comment and restartOnly return a new key. Declare them as constants and read them with ConfigValues.get(ConfigKey).

  • Method Details

    • string

      @NotNull public static @NotNull ConfigKey<String> string(@NotNull @NotNull String path, @NotNull @NotNull String defaultValue)
      Text. Numbers and booleans written without quotes are read as text too.
    • color

      @NotNull public static @NotNull ConfigKey<Integer> color(@NotNull @NotNull String path, int defaultValue)
      A color, written "#RRGGBB" (quoted in YAML); read and written as 0xRRGGBB.
    • bool

      @NotNull public static @NotNull ConfigKey<Boolean> bool(@NotNull @NotNull String path, boolean defaultValue)
    • integer

      @NotNull public static @NotNull ConfigKey<Integer> integer(@NotNull @NotNull String path, int defaultValue, int min, int max)
    • whole

      @NotNull public static @NotNull ConfigKey<Long> whole(@NotNull @NotNull String path, long defaultValue, long min, long max)
    • decimal

      @NotNull public static @NotNull ConfigKey<Double> decimal(@NotNull @NotNull String path, double defaultValue, double min, double max)
    • choice

      @NotNull public static <E extends Enum<E>> @NotNull ConfigKey<E> choice(@NotNull @NotNull String path, @NotNull E defaultValue)
      One of the constants of type, written in lower case with dashes: FAST_MODE is fast-mode.
    • wholes

      @NotNull public static @NotNull ConfigKey<List<Long>> wholes(@NotNull @NotNull String path, @NotNull @NotNull List<Long> defaultValue, int size, long min, long max)
      size whole numbers from min to max (size 0: any number of them).
    • strings

      @NotNull public static @NotNull ConfigKey<List<String>> strings(@NotNull @NotNull String path, @NotNull @NotNull List<String> defaultValue)
      A list of texts.
    • map

      @NotNull public static @NotNull ConfigKey<Map<String,String>> map(@NotNull @NotNull String path, @NotNull @NotNull Map<String,String> defaultValue)
      A section of name: text entries, in file order.
    • comment

      @NotNull public @NotNull ConfigKey<T> comment(@NotNull @NotNull String... lines)
      The comment written above the key when it is added to a file; replaces any earlier comment.
    • restartOnly

      @NotNull public @NotNull ConfigKey<T> restartOnly()
      A reload keeps the value the server started with and reports that a restart is needed.
    • clamped

      @NotNull public @NotNull ConfigKey<T> clamped()
      A number out of range is limited to the nearest bound (with a warning) instead of replaced by the default. Only for integer(String, int, int, int), whole(String, long, long, long) and decimal(String, double, double, double) keys.
    • path

      @NotNull public @NotNull String path()
    • defaultValue

      @NotNull public T defaultValue()
    • comment

      @NotNull public @NotNull List<String> comment()
    • isRestartOnly

      public boolean isRestartOnly()
    • expected

      @NotNull public @NotNull String expected()
      What a valid value looks like, for warnings: "a whole number from 0 to 256".
    • toString

      public String toString()
      Overrides:
      toString in class Object