Interface PlayerAchievements
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
earn
(PlayerAchievement achievement) Will give the achievement to the player.boolean
earn
(PlayerAchievement achievement, boolean silent) Will give the achievement to the player.@Nullable OffsetDateTime
getEarnDate
(PlayerAchievement achievement) Returns the date when he earned the achievement.Returns the ids of all achievements that he earned.Returns the UUID of the player.boolean
has
(PlayerAchievement achievement) Returns if the player has a specific achievement.boolean
Any changes made to this instance will not be saved, even if tried.boolean
remove
(PlayerAchievement achievement) Removes the achievement from the earned list.default void
save()
Asynchronously saves these achievements.void
Asynchronously saves these achievements.boolean
setEarnDate
(PlayerAchievement achievement, OffsetDateTime date) Sets the earn date of the achievement.
-
Method Details
-
getPlayerUUID
UUID getPlayerUUID()Returns the UUID of the player.- Returns:
- The UUID of the player who earned these achievements
-
has
Returns if the player has a specific achievement.- Parameters:
achievement
- The achievement that we want to check- Returns:
true
if he has earned the achievement
-
earn
Will give the achievement to the player. Also displays a chat message that he earned if he's online.The operation might fail when the player already has the achievement or a plugin cancelled it via the
PlayerEarnAchievementEvent
. Additionally, prizers may be disabled within an arena (Arena.isPrizeForMatchEnabled()
).- Parameters:
achievement
- The achievmeent that he shall earn- Returns:
true
when the operation was successful- Throws:
IllegalArgumentException
- When the id of the achievement doesn't fit the format
-
earn
Will give the achievement to the player. Also displays a chat message that he earned if he's online and whensilent
is true.The operation might fail when the player already has the achievement or a plugin cancelled it via the
PlayerEarnAchievementEvent
. Additionally, prizers may be disabled within an arena (Arena.isPrizeForMatchEnabled()
).- Parameters:
achievement
- The achievmeent that he shall earnsilent
- If it should notify the player or not- Returns:
true
when the operation was successful- Throws:
IllegalArgumentException
- When the id of the achievement doesn't fit the format
-
remove
Removes the achievement from the earned list.- Parameters:
achievement
- The achievement that he once earned- Returns:
false
if he hasn't earned it. Otherwisetrue
-
getEarnDate
Returns the date when he earned the achievement.- Parameters:
achievement
- The achievement- Returns:
- The date when he earned it. Null if he never earned it before
-
setEarnDate
Sets the earn date of the achievement.- Parameters:
achievement
- The achievementdate
- The new date- Returns:
false
if he never earned the achievement before
-
getEarnedIds
Returns the ids of all achievements that he earned.- Returns:
- The id of all earned achievements
-
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 achievements.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 achievements.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
-