Package com.enhancedechest.model
Record Class PlayerSettings
java.lang.Object
java.lang.Record
com.enhancedechest.model.PlayerSettings
- Record Components:
editMode- whether the management list opens in edit mode (clicking a chest opens its detail dialog rather than the chest itself); remembered across sessionsappliedDefaultSize- the base-chest size currently dictated by the player'senhancedechest.default_size.<size>permission, or0when the base chest is not permission-managed (its size is the config default or an admin resize). This is the persisted baseline the reconcile compares against to detect a permission being granted, changed or revoked, and that/ee resizereads to know the base chest is permission-managed (so it is left alone even for an offline owner). Seecom.enhancedechest.service.PermissionChestService.username- the player's in-game name as last recorded on join, ornullif never recorded. Backs offline name→UUID resolution (/ee viewand friends); written lazily — only when it differs from the stored value — byPlayerSettingsCache.preloadSettings, not on every join.
public record PlayerSettings(boolean editMode, int appliedDefaultSize, @Nullable String username)
extends Record
Per-player state, persisted one row per player in
players.
This is the general settings container: it is loaded whole and saved whole, so callers never deal with individual columns. To add a new setting:
- add a component to this record (and to
defaults()/ awithXhelper); - add the matching column to the
playersDDL in all three storage dialects (SqliteStorage / MysqlStorage / PostgresStorage) — for an existing install, ship a guardedALTER TABLE ... ADD COLUMN ... DEFAULT ...step inSchemaMigrator(portable across all four engines); - add the field to
EnderChestStorage.RawPlayerRowand map it inAbstractSqlStorage.loadAllPlayers/batchPlayers(bulk load/flush) plus the in-memoryPlayerRow+ settings methods inCachedStorage.
defaults() so a player with no row behaves identically to a fresh one.-
Constructor Summary
ConstructorsConstructorDescriptionPlayerSettings(boolean editMode, int appliedDefaultSize, @Nullable String username) Creates an instance of aPlayerSettingsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of theappliedDefaultSizerecord component.static PlayerSettingsdefaults()Settings for a player who has never saved any — every field at its default.booleaneditMode()Returns the value of theeditModerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.@Nullable Stringusername()Returns the value of theusernamerecord component.withAppliedDefaultSize(int appliedDefaultSize) Returns a copy withappliedDefaultSizechanged, leaving every other setting untouched.withEditMode(boolean editMode) Returns a copy witheditModechanged, leaving every other setting untouched.withUsername(String username) Returns a copy withusernamechanged, leaving every other setting untouched.
-
Constructor Details
-
PlayerSettings
public PlayerSettings(boolean editMode, int appliedDefaultSize, @Nullable @Nullable String username) Creates an instance of aPlayerSettingsrecord class.- Parameters:
editMode- the value for theeditModerecord componentappliedDefaultSize- the value for theappliedDefaultSizerecord componentusername- the value for theusernamerecord component
-
-
Method Details
-
defaults
Settings for a player who has never saved any — every field at its default. -
withEditMode
Returns a copy witheditModechanged, leaving every other setting untouched. -
withAppliedDefaultSize
Returns a copy withappliedDefaultSizechanged, leaving every other setting untouched. -
withUsername
Returns a copy withusernamechanged, leaving every other setting untouched. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
editMode
public boolean editMode()Returns the value of theeditModerecord component.- Returns:
- the value of the
editModerecord component
-
appliedDefaultSize
public int appliedDefaultSize()Returns the value of theappliedDefaultSizerecord component.- Returns:
- the value of the
appliedDefaultSizerecord component
-
username
Returns the value of theusernamerecord component.- Returns:
- the value of the
usernamerecord component
-