Class ConfigImpl
java.lang.Object
net.ixdarklord.coolcatcore.internal.config.ConfigImpl
- All Implemented Interfaces:
Config
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface net.ixdarklord.coolcatcore.api.config.Config
Config.ChangeListener -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConfigImpl(net.minecraft.resources.ResourceLocation id, ConfigScope scope, ConfigFormat format, ConfigGroupImpl root, List<String> comment, int version, Map<Integer, ConfigMigration> migrations, int editPermission, boolean hotReload, String fileName, Map<String, ConfigPreset> presets, @Nullable ConfigTheme theme) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(Config.ChangeListener listener) Called with the values that changed, whenever any do, on the thread that changed them.Set<ConfigValue<?>> applyChanges(Map<? extends ConfigValueImpl<?>, ?> changes) Stores already-validated values at once, then notifies value listeners, config listeners andConfigEvents.CHANGEDof the ones that actually changed.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.voidapplyPreset(ConfigPreset preset) Sets a preset's values, in memory;Config.save()writes them.applySnapshot(com.google.gson.JsonObject flat, boolean strict) Applies a flat snapshot.applySnapshot(com.google.gson.JsonObject flat, boolean strict, boolean live) AsapplySnapshot(JsonObject, boolean);livechanges live values even of a frozen config.comment()The file's comment lines.intWho may change a synced config from a client: the permission level (0-4) they need.fileName()The file name with its extension, relative to the folder the scope stores configs in.@Nullable PathfilePath()The config file, or null while it has none (aConfigScope.WORLDconfig with no server running).Optional<ConfigValue<?>> The value at a dotted path, like"rendering.particles".format()booleanWhether this config set a theme of its own, rather than using its mod's.booleannet.minecraft.resources.ResourceLocationid()<modid>:<name>.booleanisFrozen()booleanisLoaded()Whether the values come from the file (or a server) rather than being defaults waiting for a world.booleanisRemote()Whether this client currently shows a server's values: the config is synced and the client is connected to a remote server.presets()The presets declared on the builder, by name.voidreload()Reads the file again, notifying listeners of whatever changed.booleanremoveListener(Config.ChangeListener listener) voidresetAll()Sets every value back to its default, in memory;Config.save()writes it.static RestartRequirementrestartFor(Iterable<? extends ConfigValue<?>> values) The strictest restart any of these values needs.root()voidsave()Writes the current values to the file.scope()voidsetRemote(boolean remote) com.google.gson.JsonObjectsnapshot(boolean syncedOnly) stored(ConfigValueImpl<?> value) The value in the file: the live value, unless a change waits for the next start.static @Nullable net.minecraft.network.chat.ComponentsyncNote(ConfigValueImpl<?> value) How the value relates to the server's, when that isn't simply "synced".com.google.gson.JsonObjectWhat 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.theme()How the config's screen looks: its own theme, or the mod's.net.minecraft.network.chat.Componenttitle()The config's title:config.<modid>.<name>.title, falling back to the mod id and name.toString()@Nullable ConfigValueImpl<?> intversion()The file version values are migrated to; 0 when the config isn't versioned.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.ixdarklord.coolcatcore.api.config.Config
isRestartPending, modId, name, values
-
Field Details
-
VERSION_KEY
- See Also:
-
-
Constructor Details
-
ConfigImpl
public ConfigImpl(net.minecraft.resources.ResourceLocation id, ConfigScope scope, ConfigFormat format, ConfigGroupImpl root, List<String> comment, int version, Map<Integer, ConfigMigration> migrations, int editPermission, boolean hotReload, String fileName, Map<String, ConfigPreset> presets, @Nullable @Nullable ConfigTheme theme)
-
-
Method Details
-
id
public net.minecraft.resources.ResourceLocation id()Description copied from interface:Config<modid>:<name>. -
scope
-
format
-
root
-
title
public net.minecraft.network.chat.Component title()Description copied from interface:ConfigThe config's title:config.<modid>.<name>.title, falling back to the mod id and name. -
theme
Description copied from interface:ConfigHow the config's screen looks: its own theme, or the mod's. -
hasOwnTheme
public boolean hasOwnTheme()Whether this config set a theme of its own, rather than using its mod's. -
comment
Description copied from interface:ConfigThe file's comment lines. -
version
public int version()Description copied from interface:ConfigThe file version values are migrated to; 0 when the config isn't versioned. -
editPermission
public int editPermission()Description copied from interface:ConfigWho may change a synced config from a client: the permission level (0-4) they need.- Specified by:
editPermissionin interfaceConfig
-
hotReload
public boolean hotReload() -
fileName
The file name with its extension, relative to the folder the scope stores configs in. -
filePath
Description copied from interface:ConfigThe config file, or null while it has none (aConfigScope.WORLDconfig with no server running). -
isLoaded
public boolean isLoaded()Description copied from interface:ConfigWhether the values come from the file (or a server) rather than being defaults waiting for a world. -
isRemote
public boolean isRemote()Description copied from interface:ConfigWhether 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. -
setRemote
public void setRemote(boolean remote) -
find
Description copied from interface:ConfigThe value at a dotted path, like"rendering.particles". -
value
-
allValues
-
presets
Description copied from interface:ConfigThe presets declared on the builder, by name. -
applyPreset
Description copied from interface:ConfigSets a preset's values, in memory;Config.save()writes them.- Specified by:
applyPresetin interfaceConfig
-
resetAll
public void resetAll()Description copied from interface:ConfigSets every value back to its default, in memory;Config.save()writes it. -
applyChanges
Stores already-validated values at once, then notifies value listeners, config listeners andConfigEvents.CHANGEDof the ones that actually changed. Once a startup config is frozen, the values are only stored for the next start instead. -
applyLive
Changes the live values even when frozen: the server's values arriving, or the client's own coming back. -
restartFor
The strictest restart any of these values needs. -
addListener
Description copied from interface:ConfigCalled with the values that changed, whenever any do, on the thread that changed them.- Specified by:
addListenerin interfaceConfig
-
removeListener
- Specified by:
removeListenerin interfaceConfig
-
reload
public void reload()Description copied from interface:ConfigReads the file again, notifying listeners of whatever changed. -
isFrozen
public boolean isFrozen() -
stored
The value in the file: the live value, unless a change waits for the next start. -
save
public void save()Description copied from interface:ConfigWrites the current values to the file. Does nothing while the config has no file or is remote. -
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
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) AsapplySnapshot(JsonObject, boolean);livechanges live values even of a frozen config. -
toString
-