Class ServerProfileManager

java.lang.Object
net.joseplay.allianceutils.api.playerProfile.data.ServerProfileManager

public class ServerProfileManager extends Object
Manages the lifecycle, synchronization, and persistence of a single ServerProfile.

Core rules:

This manager is designed for a single shared server-wide profile.

  • Field Details

    • isLoadded

      public boolean isLoadded
      Indicates whether the profile has been loaded from the database.
  • Constructor Details

    • ServerProfileManager

      public ServerProfileManager()
      Creates the manager and starts async loading from database.
  • Method Details

    • loadFromDataBaseAsync

      public void loadFromDataBaseAsync()
      Loads the profile asynchronously from the database.
    • getSnapshot

      @NotNull public @NotNull ServerProfile getSnapshot()
      Returns a snapshot (safe copy) of the current profile.

      The returned object must NOT be modified outside the manager.

      Returns:
      cloned server profile
    • modifyProfile

      public void modifyProfile(ServerProfileManager.ProfileModifier modifier)
      The ONLY valid entry point to modify the server profile.
      Parameters:
      modifier - logic to apply changes
    • saveIfDirtyAsync

      public void saveIfDirtyAsync()
      Schedules an async save if the profile is marked as dirty.
    • shutdown

      public void shutdown()
      Forces a synchronous save (used on shutdown).
    • applyRemoteProfile

      public void applyRemoteProfile(ServerProfile remoteProfile)
      Applies a remote profile update (e.g., from another server).
      Parameters:
      remoteProfile - incoming profile