Class FPlayerRepository

java.lang.Object
net.flectone.pulse.data.repository.FPlayerRepository

public class FPlayerRepository extends Object
Repository for managing player data in FlectonePulse. Provides caching and retrieval of player information from various sources.
Since:
0.8.1
  • Constructor Details

    • FPlayerRepository

      @Inject public FPlayerRepository(com.google.common.cache.Cache<UUID,FPlayer> offlinePlayersCache, FPlayerDAO fPlayerDAO)
  • Method Details

    • invalid

      public void invalid(@NonNull UUID uuid)
      Invalidates a player from all caches.
      Parameters:
      uuid - the player UUID to invalidate
    • get

      public FPlayer get(int id)
      Gets a player by database ID with caching.
      Parameters:
      id - the player database ID
      Returns:
      the player
    • get

      public FPlayer get(@NonNull InetAddress inetAddress)
      Gets a player by IP address with caching.
      Parameters:
      inetAddress - the IP address
      Returns:
      the player
    • get

      public FPlayer get(@NonNull UUID uuid)
      Gets a player by UUID with caching.
      Parameters:
      uuid - the player UUID
      Returns:
      the player
    • get

      public FPlayer get(@NonNull String playerName)
      Gets a player by name with caching.
      Parameters:
      playerName - the player name
      Returns:
      the player
    • getFromDatabase

      public @NonNull FPlayer getFromDatabase(UUID uuid)
    • getFromCache

      public @Nullable FPlayer getFromCache(@Nullable UUID uuid)
    • removeOffline

      public void removeOffline(@NonNull UUID uuid)
      Removes a player from the offline cache.
      Parameters:
      uuid - the player UUID
    • removeOnline

      public void removeOnline(@NonNull UUID uuid)
      Moves a player from online to offline cache.
      Parameters:
      uuid - the player UUID
    • removeOnline

      public void removeOnline(@NonNull FPlayer fPlayer)
      Moves a player from online to offline cache.
      Parameters:
      fPlayer - the player
    • add

      public void add(@NonNull FPlayer fPlayer)
      Adds a player to the online cache.
      Parameters:
      fPlayer - the player to add
    • updateCache

      public void updateCache(FPlayer fPlayer)
      Updates the cache with the latest player data
      Parameters:
      fPlayer - the player data to update in cache
    • clearCache

      public void clearCache()
      Clears all caches
    • saveOrUpdate

      public FPlayer saveOrUpdate(@NonNull UUID uuid, @NonNull String name, @Nullable String ip, boolean online)
      Saves or updates a player in the database.
      Parameters:
      uuid - the player's UUID
      name - the player's name
      ip - the player's IP address, can be null
      online - whether the player is currently online
      Returns:
      the created or updated FPlayer object with assigned database ID
    • update

      public void update(@NonNull FPlayer fPlayer)
      Updates a player in the database.
      Parameters:
      fPlayer - the player to update
    • setOfflineByServer

      public void setOfflineByServer(@NonNull String server)
      Sets all players associated with the specified server to offline status.
      Parameters:
      server - the server identifier to match against player server settings
    • saveOrIgnore

      public void saveOrIgnore(@NonNull FPlayer fPlayer)
      Saves a player or ignores if already exists.
      Parameters:
      fPlayer - the player to save
    • getTotalPlayersCountByIp

      public int getTotalPlayersCountByIp(@NonNull String ip)
      Gets the total count of players with the specified IP address.
      Parameters:
      ip - the IP address to count players for
      Returns:
      the total number of players with the given IP
    • getPlayersByIp

      public List<FPlayer> getPlayersByIp(@NonNull String ip, int limit, int offset)
      Gets a paginated list of players with the specified IP address.
      Parameters:
      ip - the IP address to filter players by
      limit - the maximum number of players to return
      offset - the number of players to skip
      Returns:
      list of players matching the IP, ordered by ID descending
    • getAllPlayersDatabase

      public List<FPlayer> getAllPlayersDatabase()
      Gets all players from the database.
      Returns:
      list of all players
    • getOnlinePlayersDatabase

      public List<FPlayer> getOnlinePlayersDatabase()
      Gets all online players from the database.
      Returns:
      list of online players
    • getOnlinePlayers

      public List<FPlayer> getOnlinePlayers()
      Gets all online players from the cache.
      Returns:
      list of online players
    • getOnlineFPlayersWithConsole

      public List<FPlayer> getOnlineFPlayersWithConsole()
      Gets all online players plus the console.
      Returns:
      list of online players and console