Interface PlayerStats
Generally there are 2 cached instances per player: One that holds the stats of a game, and the other of the total ones.
Use isGameStats()
and getGameStats()
to differentiate them.
-
Method Summary
Modifier and TypeMethodDescriptiondefault Number
Adds an amount to a stats entry.add
(String key, Number addAmount, AttributeChangeCause cause) Adds an amount to a stats entry.entrySet()
Returns all stored entries of this objectLooks for the stats entry with that key.@Nullable PlayerStats
Will return the stats of the round that the player currently plays.The UUID of the involved playerboolean
Get whether this stats instance holds the stats of a running match, and not the total ones.void
Will reset the game stats.default void
save()
Asynchronously saves these stats.void
Asynchronously saves these stats.default Number
Sets the value of a stats entry.set
(String key, Number value, AttributeChangeCause cause) Sets the value of a stats entry,
-
Method Details
-
getPlayerUUID
UUID getPlayerUUID()The UUID of the involved player- Returns:
- The UUID of the player who owns the stats.
-
isGameStats
boolean isGameStats()Get whether this stats instance holds the stats of a running match, and not the total ones.- Returns:
- Whether these stats are about the round that the player currently plays.
-
getGameStats
Will return the stats of the round that the player currently plays.- Returns:
- Can return
null
whenisGameStats()
returns true or the player isn't playing right now
-
resetGameStats
void resetGameStats()Will reset the game stats.It does not matter if you're calling this with the game stats or the normal stats
-
get
Looks for the stats entry with that key.Will use 0 as default.
- Parameters:
key
- The id/key of the stats entry- Returns:
- The value that this players. 0 if there are no stats with that key
-
set
Sets the value of a stats entry.Keep in mind that the
PlayerStatChangeEvent
is likely being dispatched with this.- Parameters:
key
- The id/key of the stats entryvalue
- The value for that entry- Returns:
- Returns the previous value
- Throws:
IllegalArgumentException
- When key doesn't fit the format
-
set
Sets the value of a stats entry,- Parameters:
key
- The id/key of the stats entryvalue
- The value for that entrycause
- The technical cause for setting this- Returns:
- Returns the previous value
- Throws:
IllegalArgumentException
- When key doesn't fit the format
-
add
Adds an amount to a stats entry.Keep in mind that the
PlayerStatChangeEvent
is likely being dispatched with this.- Parameters:
key
- The id/key of the stats entryaddAmount
- The amount that shall be added- Returns:
- Returns the previous value
- Throws:
IllegalArgumentException
- When key doesn't fit the format
-
add
Adds an amount to a stats entry.- Parameters:
key
- The id/key of the stats entryaddAmount
- The amount that shall be addedcause
- The technical cause for setting this- Returns:
- Returns the previous value
- Throws:
IllegalArgumentException
- When key doesn't fit the format
-
entrySet
Returns all stored entries of this object- Returns:
- Returns a set of all stored stats
-
save
default void save()Asynchronously saves these stats.It's usually not needed to call this method when the player is currently on the server as the plugin will already handle it
-
save
Asynchronously saves these stats.It's usually not needed to call this method when the player is currently on the server as the plugin will already handle it.
Important: The callback doesn't get synced to the main thread.
- Parameters:
callback
- Gets called when the operation was finished
-