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 sessions
appliedDefaultSize - the base-chest size currently dictated by the player's enhancedechest.default_size.<size> permission, or 0 when 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 resize reads to know the base chest is permission-managed (so it is left alone even for an offline owner). See com.enhancedechest.service.PermissionChestService.
username - the player's in-game name as last recorded on join, or null if never recorded. Backs offline name→UUID resolution (/ee view and friends); written lazily — only when it differs from the stored value — by PlayerSettingsCache.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:

  1. add a component to this record (and to defaults() / a withX helper);
  2. add the matching column to the players DDL in all three storage dialects (SqliteStorage / MysqlStorage / PostgresStorage) — for an existing install, ship a guarded ALTER TABLE ... ADD COLUMN ... DEFAULT ... step in SchemaMigrator (portable across all four engines);
  3. add the field to EnderChestStorage.RawPlayerRow and map it in AbstractSqlStorage.loadAllPlayers/batchPlayers (bulk load/flush) plus the in-memory PlayerRow + settings methods in CachedStorage.
Defaults live in defaults() so a player with no row behaves identically to a fresh one.
  • Constructor Details

    • PlayerSettings

      public PlayerSettings(boolean editMode, int appliedDefaultSize, @Nullable @Nullable String username)
      Creates an instance of a PlayerSettings record class.
      Parameters:
      editMode - the value for the editMode record component
      appliedDefaultSize - the value for the appliedDefaultSize record component
      username - the value for the username record component
  • Method Details

    • defaults

      public static PlayerSettings defaults()
      Settings for a player who has never saved any — every field at its default.
    • withEditMode

      public PlayerSettings withEditMode(boolean editMode)
      Returns a copy with editMode changed, leaving every other setting untouched.
    • withAppliedDefaultSize

      public PlayerSettings withAppliedDefaultSize(int appliedDefaultSize)
      Returns a copy with appliedDefaultSize changed, leaving every other setting untouched.
    • withUsername

      public PlayerSettings withUsername(String username)
      Returns a copy with username changed, leaving every other setting untouched.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • editMode

      public boolean editMode()
      Returns the value of the editMode record component.
      Returns:
      the value of the editMode record component
    • appliedDefaultSize

      public int appliedDefaultSize()
      Returns the value of the appliedDefaultSize record component.
      Returns:
      the value of the appliedDefaultSize record component
    • username

      @Nullable public @Nullable String username()
      Returns the value of the username record component.
      Returns:
      the value of the username record component