Class AbstractEntryBuilder<T, B extends AbstractEntryBuilder<T,B>>

java.lang.Object
net.ixdarklord.coolcatcore.api.config.AbstractEntryBuilder<T,B>
Type Parameters:
T - the value's type
B - the builder's own type, for chaining
Direct Known Subclasses:
EntryBuilder, ListEntryBuilder, NumberEntryBuilder, StringEntryBuilder

public abstract class AbstractEntryBuilder<T, B extends AbstractEntryBuilder<T,B>> extends Object
The options every entry has. Finish with build(), which adds the value to the group that was current when the entry was started.
  • Method Details

    • type

      protected abstract ConfigType<T> type()
      The type the entry is built with, once every option is set.
    • comment

      public B comment(String... lines)
      Lines written above the value in the file; also its tooltip when there's no .tooltip translation.
    • translation

      public B translation(String translationKey)
      A translation key for the name, instead of config.<modid>.<config>.<path>.
    • hidden

      public B hidden()
      Keeps the value out of the config screen; it's still in the file and commands.
    • requiresRestart

      public B requiresRestart(RestartRequirement restart)
    • requiresGameRestart

      public B requiresGameRestart()
      Changes take effect after restarting the game.
    • requiresWorldRestart

      public B requiresWorldRestart()
      Changes take effect after rejoining the world.
    • serverOnly

      public B serverOnly()
      In a synced config, keeps the value on the server: it isn't sent to players, who can't see or change it (only the host of a singleplayer world can). For secrets like tokens and passwords.
    • localOnly

      public B localOnly()
      In a ConfigScope.STARTUP config, lets each side keep its own value: it isn't compared with the server's. For client-side details, like a texture variant. (The same as serverOnly().)
    • useServerValue

      public B useServerValue()
      In a ConfigScope.STARTUP config, lets a client whose value differs join, and uses the server's value while connected; see StartupSync.USE_SERVER. By default the values must match.
    • aliases

      public B aliases(String... oldKeys)
      Keys this value had before: a bare key is looked up in the same group, a dotted path from the root. The file is rewritten with the current key.
    • validator

      public B validator(Predicate<? super T> check, net.minecraft.network.chat.Component errorMessage)
      An extra check beyond the type's constraints.
    • validator

      public B validator(Function<? super T, net.minecraft.network.chat.Component> check)
      An extra check returning an error message, or null for a valid value.
    • enabledWhen

      public B enabledWhen(ConfigValue<Boolean> other)
      Greys the value out in the config screen while other is off.
    • enabledWhen

      public <V> B enabledWhen(ConfigValue<V> other, Predicate<? super V> condition)
      Greys the value out in the config screen while other's value doesn't meet the condition.
    • listener

      public B listener(ConfigValue.ChangeListener<T> listener)
      Called whenever the value changes; see ConfigValue.addListener(ConfigValue.ChangeListener).
    • build

      public ConfigValue<T> build()
      Adds the value to the config.
      Throws:
      IllegalArgumentException - when the default value isn't valid, or the key is taken
      IllegalStateException - when the entry or the config was already built
    • self

      protected final B self()