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.boolean
Any changes made to this instance will not be saved, even if tried.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
-
isReadOnly
boolean isReadOnly()Any changes made to this instance will not be saved, even if tried.While it is possible to change the values, MBedwars' auto-saving and
save()
will not actually do anything and any changes will be lost with the next loading.Reasons for read-only are:
- We failed to load it fully (due to an error). Reasons for that may include e.g. a disconnection to the storage server.
- The player might be online on another server and we don't want to intercept with whatever the other server is doing. Although cross-server support can be obtained using the ProxySync addon and making sure that player-data-syncing is enabled within it, in which case this instance won't be set as read-only.
- Returns:
- Whether this instance is read-only and changes won't be saved
-
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
-