Interface PlayerAchievements
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanearn(PlayerAchievement achievement) Will give the achievement to the player.booleanearn(PlayerAchievement achievement, boolean silent) Will give the achievement to the player.@Nullable OffsetDateTimegetEarnDate(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.booleanhas(PlayerAchievement achievement) Returns if the player has a specific achievement.booleanAny changes made to this instance will not be saved, even if tried.booleanremove(PlayerAchievement achievement) Removes the achievement from the earned list.default voidsave()Asynchronously saves these achievements.voidAsynchronously saves these achievements.booleansetEarnDate(PlayerAchievement achievement, OffsetDateTime date) Sets the earn date of the achievement.voidsetReadOnly(boolean readOnly) Sets whether this instance is read-only.
-
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:
trueif 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:
truewhen 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 whensilentis 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:
truewhen 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:
falseif 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:
falseif 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
-
setReadOnly
void setReadOnly(boolean readOnly) Sets whether this instance is read-only.This mechanism exists to prevent desyncs between multiple servers. Use it with caution! Read
isReadOnly()for more info.- Parameters:
readOnly- Whether this instance should be read-only
-
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
-