Package de.marcely.bedwars.api.player
Interface PlayerStatSet
public interface PlayerStatSet
Represents a handler for a data set
Data sets might be the kills, rank or the play time of the player
It has been built to be fully modular
There's only one global instance that's handling all players
Data sets might be the kills, rank or the play time of the player
It has been built to be fully modular
There's only one global instance that's handling all players
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
addValue
(PlayerStats stats, Number amount) Will add value to the current valuedefault String
formatDouble
(Number num) Helper method forgetDisplayedValue(PlayerStats)
default String
Helper method forgetDisplayedValue(PlayerStats)
default String
formatValue
(Number number) Returns what would be displayed as the value for a certian number.getDisplayedValue
(PlayerStats stats) Returns what essentially will be displayed as the valuegetId()
Returns the unique id of this data set
This is being used for other plugins that might want to modify the data set and to make it easier for them
It'll also be used for the %mbedwars_stats-<id>% PAPI placeholder
And it'll also get stored inside the SQL database includinggetValue(PlayerStats)
but with lower priority.getName
(@Nullable CommandSender sender) Returns the name that shall be displayed everywhere
Tip: UseMessage.buildByKey(String, String)
when you're saving the message in the messages fileReturns the plugin that's providing this data setgetValue
(PlayerStats stats) Similar togetDisplayedValue(PlayerStats)
, but as a direct number
Will amongst other things be used for the leaderboarddefault void
setValue
(PlayerStats stats, Number value) Stat can implement this for easier use for others wanting to modify it
-
Method Details
-
getId
String getId()Returns the unique id of this data set
This is being used for other plugins that might want to modify the data set and to make it easier for them
It'll also be used for the %mbedwars_stats-<id>% PAPI placeholder
And it'll also get stored inside the SQL database includinggetValue(PlayerStats)
but with lower priority. Meaning they can get replaced by entries with the same key ofPlayerStats
. The reason why it's getting stored in the database as well is that it's being used for e.g. the ranking an webinterface- Returns:
- The unique id of this data set
-
getPlugin
Plugin getPlugin()Returns the plugin that's providing this data set- Returns:
- The plugin behind the data set
-
getName
Returns the name that shall be displayed everywhere
Tip: UseMessage.buildByKey(String, String)
when you're saving the message in the messages file- Parameters:
sender
- Shall return the name in the language of him. Can be null- Returns:
- The name of this data set that'll be displayed to the users
-
getDisplayedValue
Returns what essentially will be displayed as the value- Parameters:
stats
- The stats from which it should pick its info- Returns:
- The displayed value
-
formatValue
Returns what would be displayed as the value for a certian number.Useful if you want to format a value similar to how stats are being displayed. Note: This method is not required to override, but it's recommended to do so. If its not overriden it'll return
formatInt(Number)
- Parameters:
number
- the number to format- Returns:
- the formated version of the number
-
getValue
Similar togetDisplayedValue(PlayerStats)
, but as a direct number
Will amongst other things be used for the leaderboard- Parameters:
stats
- The stats from which it should pick its info- Returns:
- The value of this prop set
- Throws:
IllegalStateException
- When this hasn't been implemented/not being supported or other reasons
-
setValue
Stat can implement this for easier use for others wanting to modify it- Parameters:
stats
- The stats from which it should pick its infovalue
- The new value- Throws:
IllegalStateException
- When this hasn't been implemented/not being supported or other reasons
-
addValue
Will add value to the current value- Parameters:
stats
- The stats from which it should pick its infoamount
- How much it should add to the value- Throws:
IllegalStateException
- When this hasn't been implemented/not being supported or other reasons
-
formatDouble
Helper method forgetDisplayedValue(PlayerStats)
- Parameters:
num
- A number- Returns:
- Returns the number with only two decimal places
-
formatInt
Helper method forgetDisplayedValue(PlayerStats)
- Parameters:
num
- A number- Returns:
- Returns the number without any decimal places
-