Class PlayerStats

java.lang.Object
stawa.vitalstrike.PlayerStats

public class PlayerStats extends Object
Manages player statistics for the VitalStrike plugin. This class handles the storage and retrieval of player combat statistics including:
  • Highest combo achieved
  • Total damage dealt
  • Total hits landed
  • Average damage per hit
Statistics are persisted to a YAML file and loaded on plugin startup.
Version:
1.5.0
Author:
Stawa
  • Constructor Details

  • Method Details

    • saveAllStats

      public void saveAllStats() throws Errors.DatabaseException
      Saves all player statistics to the stats file.
      Throws:
      Errors.DatabaseException - If there is an error accessing or updating the database if there's an error saving the stats file
    • resetPlayerStats

      public void resetPlayerStats(UUID uuid)
      Resets statistics for a specific player.
      Parameters:
      uuid - the UUID of the player to reset
    • resetAllStats

      public void resetAllStats()
      Resets statistics for all players. This will clear all statistics from memory and remove them from the configuration. Note: Changes are not saved to disk until saveAllStats() is called.
    • getPlayerStats

      public PlayerStats.PlayerStatistics getPlayerStats(UUID uuid)
      Gets the player statistics for the specified player.
      Parameters:
      uuid - the player's UUID
      Returns:
      the player statistics
    • updateStats

      public void updateStats(org.bukkit.entity.Player player, double damage, int combo)
      Updates the player's statistics with the provided damage and combo. Note: Changes are not saved to disk until saveAllStats() is called.
      Parameters:
      player - the player to update
      damage - the damage dealt
      combo - the combo achieved
    • getTopPlayers

      public List<Map.Entry<UUID,PlayerStats.PlayerStatistics>> getTopPlayers(int limit, ToDoubleFunction<PlayerStats.PlayerStatistics> valueExtractor)
      Gets the top players based on the provided value extractor.
      Parameters:
      limit - the maximum number of players to return
      valueExtractor - the function to extract the sorting value from PlayerStatistics (e.g., PlayerStatistics::getTotalDamageDealt)
      Returns:
      a list of player entries sorted by the extracted value in descending order, limited to the specified number of entries
    • hasStats

      public boolean hasStats(UUID uuid)
      Checks if statistics exist for a player.
      Parameters:
      uuid - the player's UUID
      Returns:
      true if the player has statistics