Class ConfigImpl

java.lang.Object
net.ixdarklord.coolcatcore.internal.config.ConfigImpl
All Implemented Interfaces:
Config

public final class ConfigImpl extends Object implements Config
  • Field Details

  • Constructor Details

  • Method Details

    • id

      public net.minecraft.resources.ResourceLocation id()
      Description copied from interface: Config
      <modid>:<name>.
      Specified by:
      id in interface Config
    • scope

      public ConfigScope scope()
      Specified by:
      scope in interface Config
    • format

      public ConfigFormat format()
      Specified by:
      format in interface Config
    • root

      public ConfigGroupImpl root()
      Specified by:
      root in interface Config
    • title

      public net.minecraft.network.chat.Component title()
      Description copied from interface: Config
      The config's title: config.<modid>.<name>.title, falling back to the mod id and name.
      Specified by:
      title in interface Config
    • theme

      public ConfigTheme theme()
      Description copied from interface: Config
      How the config's screen looks: its own theme, or the mod's.
      Specified by:
      theme in interface Config
    • hasOwnTheme

      public boolean hasOwnTheme()
      Whether this config set a theme of its own, rather than using its mod's.
    • comment

      public List<String> comment()
      Description copied from interface: Config
      The file's comment lines.
      Specified by:
      comment in interface Config
    • version

      public int version()
      Description copied from interface: Config
      The file version values are migrated to; 0 when the config isn't versioned.
      Specified by:
      version in interface Config
    • editPermission

      public int editPermission()
      Description copied from interface: Config
      The permission level (0 to 4) a player needs to change a synced config from a client.
      Specified by:
      editPermission in interface Config
    • hotReload

      public boolean hotReload()
    • fileName

      public String fileName()
      The file name with its extension, relative to the folder the scope stores configs in.
    • filePath

      @Nullable public @Nullable Path filePath()
      Description copied from interface: Config
      The config file, or null while it has none (a ConfigScope.WORLD config with no server running).
      Specified by:
      filePath in interface Config
    • isLoaded

      public boolean isLoaded()
      Description copied from interface: Config
      Whether the values come from the file (or a server) rather than being defaults waiting for a world.
      Specified by:
      isLoaded in interface Config
    • isRemote

      public boolean isRemote()
      Description copied from interface: Config
      Whether this client currently shows a server's values: the config is synced and the client is connected to a remote server. Local changes aren't saved meanwhile, and the client's own values come back on disconnecting.
      Specified by:
      isRemote in interface Config
    • setRemote

      public void setRemote(boolean remote)
    • find

      public Optional<ConfigValue<?>> find(String path)
      Description copied from interface: Config
      The value at a dotted path, like "rendering.particles".
      Specified by:
      find in interface Config
    • value

      @Nullable public @Nullable ConfigValueImpl<?> value(String path)
    • allValues

      public Iterable<ConfigValueImpl<?>> allValues()
    • presets

      public Map<String,ConfigPreset> presets()
      Description copied from interface: Config
      The presets declared on the builder, by name.
      Specified by:
      presets in interface Config
    • applyPreset

      public void applyPreset(ConfigPreset preset)
      Description copied from interface: Config
      Sets a preset's values, in memory; Config.save() writes them.
      Specified by:
      applyPreset in interface Config
    • resetAll

      public void resetAll()
      Description copied from interface: Config
      Sets every value back to its default, in memory; Config.save() writes it.
      Specified by:
      resetAll in interface Config
    • applyChanges

      public Set<ConfigValue<?>> applyChanges(Map<? extends ConfigValueImpl<?>,?> changes)
      Stores already-validated values at once, then notifies value listeners, config listeners and ConfigEvents.CHANGED of the ones that actually changed. Once a startup config is frozen, the values are only stored for the next start instead.
    • applyLive

      public Set<ConfigValue<?>> applyLive(Map<? extends ConfigValueImpl<?>,?> changes)
      Changes the live values even when frozen: the server's values arriving, or the client's own coming back.
    • restartFor

      public static RestartRequirement restartFor(Iterable<? extends ConfigValue<?>> values)
      The strictest restart any of these values needs.
    • addListener

      public void addListener(Config.ChangeListener listener)
      Description copied from interface: Config
      Called with the values that changed, whenever any do, on the thread that changed them.
      Specified by:
      addListener in interface Config
    • removeListener

      public boolean removeListener(Config.ChangeListener listener)
      Specified by:
      removeListener in interface Config
    • reload

      public void reload()
      Description copied from interface: Config
      Reads the file again, notifying listeners of whatever changed.
      Specified by:
      reload in interface Config
    • isFrozen

      public boolean isFrozen()
    • stored

      public Object stored(ConfigValueImpl<?> value)
      The value in the file: the live value, unless a change waits for the next start.
    • save

      public void save()
      Description copied from interface: Config
      Writes the current values to the file. Does nothing while the config has no file or is remote.
      Specified by:
      save in interface Config
    • toDocument

      public ConfigDocument.Section toDocument()
    • syncNote

      @Nullable public static @Nullable net.minecraft.network.chat.Component syncNote(ConfigValueImpl<?> value)
      How the value relates to the server's, when that isn't simply "synced".
    • syncSnapshot

      public com.google.gson.JsonObject syncSnapshot()
      What the server sends in play: its synced values, or for a startup config only those clients take over (StartupSync.USE_SERVER); the rest were checked before joining.
    • snapshot

      public com.google.gson.JsonObject snapshot(boolean syncedOnly)
    • applySnapshot

      public ConfigImpl.SnapshotResult applySnapshot(com.google.gson.JsonObject flat, boolean strict)
      Applies a flat snapshot. Strict application (a player's edit) needs every value valid as is; otherwise corrections are accepted. Unknown paths and invalid values are skipped and reported.
    • applySnapshot

      public ConfigImpl.SnapshotResult applySnapshot(com.google.gson.JsonObject flat, boolean strict, boolean live)
      As applySnapshot(JsonObject, boolean); live changes live values even of a frozen config.
    • toString

      public String toString()
      Overrides:
      toString in class Object