Interface PlayerAchievements


public interface PlayerAchievements
  • Method Details

    • getPlayerUUID

      UUID getPlayerUUID()
      Returns the UUID of the player.
      Returns:
      The UUID of the player who earned these achievements
    • has

      boolean has(PlayerAchievement achievement)
      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

      default boolean earn(PlayerAchievement achievement)
      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

      boolean earn(PlayerAchievement achievement, boolean silent)
      Will give the achievement to the player. Also displays a chat message that he earned if he's online and when silent 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 earn
      silent - 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

      boolean remove(PlayerAchievement achievement)
      Removes the achievement from the earned list.
      Parameters:
      achievement - The achievement that he once earned
      Returns:
      false if he hasn't earned it. Otherwise true
    • getEarnDate

      @Nullable @Nullable OffsetDateTime getEarnDate(PlayerAchievement achievement)
      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

      boolean setEarnDate(PlayerAchievement achievement, OffsetDateTime date)
      Sets the earn date of the achievement.
      Parameters:
      achievement - The achievement
      date - The new date
      Returns:
      false if he never earned the achievement before
    • getEarnedIds

      Set<String> 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

      void save(@Nullable @Nullable Runnable callback)
      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