Package stawa.vitalstrike
Class PlayerStats
java.lang.Object
stawa.vitalstrike.PlayerStats
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
- Version:
- 1.5.0
- Author:
- Stawa
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a player's combat statistics. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetPlayerStats(UUID uuid) Gets the player statistics for the specified player.getTopPlayers(int limit, ToDoubleFunction<PlayerStats.PlayerStatistics> valueExtractor) Gets the top players based on the provided value extractor.booleanChecks if statistics exist for a player.voidResets statistics for all players.voidresetPlayerStats(UUID uuid) Resets statistics for a specific player.voidSaves all player statistics to the stats file.voidupdateStats(org.bukkit.entity.Player player, double damage, int combo) Updates the player's statistics with the provided damage and combo.
-
Constructor Details
-
PlayerStats
Creates a new PlayerStats instance.- Parameters:
plugin- the VitalStrike plugin instance- Throws:
Errors.DatabaseException- If there is an error accessing or updating the database
-
-
Method Details
-
saveAllStats
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
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
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 updatedamage- the damage dealtcombo- 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 returnvalueExtractor- 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
Checks if statistics exist for a player.- Parameters:
uuid- the player's UUID- Returns:
- true if the player has statistics
-