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 Config
Config.ChangeListener -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConfigImpl(net.minecraft.resources.Identifier id, ConfigScope scope, ConfigFormat format, ConfigGroupImpl root, List<String> comment, int version, Map<Integer, ConfigMigration> migrations, net.minecraft.server.permissions.Permission 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.net.minecraft.server.permissions.PermissionWho may change a synced config from a client.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 (a client config on a dedicated server).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.Identifierid()<modid>:<name>.booleanisFrozen()booleanisLoaded()Whether the values come from the file (or a server) rather than being defaults with no file.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(ConfigValue<?> 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Config
isRestartPending, modId, name, values
-
Field Details
-
VERSION_KEY
- See Also:
-
-
Constructor Details
-
ConfigImpl
public ConfigImpl(net.minecraft.resources.Identifier id, ConfigScope scope, ConfigFormat format, ConfigGroupImpl root, List<String> comment, int version, Map<Integer, ConfigMigration> migrations, net.minecraft.server.permissions.Permission editPermission, boolean hotReload, String fileName, Map<String, ConfigPreset> presets, @Nullable @Nullable ConfigTheme theme)
-
-
Method Details
-
id
-
scope
-
format
-
root
-
title
-
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
-
version
-
editPermission
public net.minecraft.server.permissions.Permission editPermission()Description copied from interface:ConfigWho may change a synced config from a client.- 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
-
isLoaded
-
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
-
value
-
allValues
-
presets
-
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
-
isFrozen
public boolean isFrozen() -
stored
The value in the file: the live value, unless a change waits for the next start. -
save
-
toDocument
-
syncNote
@Nullable public static @Nullable net.minecraft.network.chat.Component syncNote(ConfigValue<?> 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
-