public class TaskAdvancement extends BaseAdvancement
The TaskAdvancement class represents a task. It can be used by any AbstractMultiTasksAdvancement subclass to separate an advancement progression into different progression (one per task).

For example, the advancement "mine 5 blocks of every plank" can be made using a TaskAdvancement for every plank (with a progression of 5) and registering them into an AbstractMultiTasksAdvancement.

TaskAdvancements are saved into the database, but they are never sent to players. For this reason they cannot be registered in tabs either.

  • Constructor Details

  • Method Details

    • getAnnounceMessage

      @Nullable @Contract(pure=true, value="_ -> null") public final @Nullable BaseComponent[] getAnnounceMessage(@NotNull @NotNull Player player)
      Gets the chat message to be sent when an advancement is completed.

      The message is sent to everybody online on the server. This method returns null by default.

      Overrides:
      getAnnounceMessage in class Advancement
      Parameters:
      player - The player who has completed the advancement.
      Returns:
      Always null.
    • setProgression

      protected void setProgression(@NotNull @NotNull TeamProgression pro, @Nullable @Nullable Player player, @Range(from=0, to=Integer.MAX_VALUE) int progression, boolean giveRewards)
      Sets a new progression for the provided team.

      The provided player must be an online member of the team. If no members are online or no particular player is to be preferred, it can be put to null. In this case, rewards will be given to a pseudorandom online member if there are any or the advancement will be set unredeemed.

      Overrides:
      setProgression in class Advancement
      Parameters:
      pro - The TeamProgression that belongs to the team.
      player - The team member responsible for the update. May be null.
      progression - The new non-negative progression to set.
      giveRewards - Whether to give rewards if the advancement gets completed.
    • isVisible

      @Contract("_ -> false") public final boolean isVisible(@NotNull @NotNull Player player)
      Returns whether the advancement is visible to the provided player.

      An advancement is visible to a player if and only if it is visible to all the players in the player's team. By default, every advancement is visible to every player, but this behavior can be changed overriding Advancement.isVisible(TeamProgression) or implementing a suitable interface for the Advancement Visibility System (see IVisibility for more information). Since TaskAdvancements are not sent to players, this method always returns false.

      Overrides:
      isVisible in class Advancement
      Parameters:
      player - The player.
      Returns:
      Always false.
    • isVisible

      @Contract("_ -> false") public final boolean isVisible(@NotNull @NotNull UUID uuid)
      Returns whether the advancement is visible to the provided player.

      An advancement is visible to a player if and only if it is visible to all the players in the player's team. By default, every advancement is visible to every player, but this behavior can be changed overriding Advancement.isVisible(TeamProgression) or implementing a suitable interface for the Advancement Visibility System (see IVisibility for more information). Since TaskAdvancements are not sent to players, this method always returns false.

      Overrides:
      isVisible in class Advancement
      Parameters:
      uuid - The UUID of the player.
      Returns:
      Always false.
    • isVisible

      @Contract("_ -> false") public final boolean isVisible(@NotNull @NotNull TeamProgression progression)
      Returns whether the advancement is visible to the provided team.

      An advancement is visible to a team if and only if it is visible to all the players in the team. By default, every advancement is visible to every player, but this behavior can be changed overriding this method or implementing a suitable interface for the Advancement Visibility System. Since TaskAdvancements are not sent to players, this method always returns false.

      Overrides:
      isVisible in class Advancement
      Parameters:
      progression - TheTeamProgression of the team.
      Returns:
      Always false.
    • onGrant

      public void onGrant(@NotNull @NotNull Player player, boolean giveRewards)
      Called when the advancement is completed by a player. It handles the chat message, the toast notification, and the advancement rewards (see Advancement.giveReward(Player) for more information).

      Since TaskAdvancements are not sent to players, this method doesn't send toast notifications and chat messages.

      Overrides:
      onGrant in class Advancement
      Parameters:
      player - The player who completed the advancement.
      giveRewards - Whether to give rewards.
    • isValid

      public boolean isValid()
      Returns whether the advancement is valid.

      An advancement is valid if and only if it belongs to its advancement tab and that tab is active.

      Overrides:
      isValid in class Advancement
      Returns:
      Whether the advancement is valid.
    • getMultiTasksAdvancement

      @NotNull public @NotNull AbstractMultiTasksAdvancement getMultiTasksAdvancement()
      Returns:
      The task's AbstractMultiTasksAdvancement.
    • validateRegister

      public void validateRegister() throws InvalidAdvancementException
      Validate the advancement after it has been registered by the advancement tab.

      Since TaskAdvancements cannot be registered in tabs, this method always fails.

      Overrides:
      validateRegister in class BaseAdvancement
      Throws:
      InvalidAdvancementException - Every time this method is called.
    • getNMSWrapper

      @NotNull public final @NotNull AdvancementWrapper getNMSWrapper()
      Returns the NMS wrapper of this advancement. Should craft the NMS wrapper once and returns it henceforth.

      Since TaskAdvancements cannot be registered in tabs, this method always throws UnsupportedOperationException.

      Overrides:
      getNMSWrapper in class BaseAdvancement
      Returns:
      The NMS wrapper of this advancement.
      Throws:
      UnsupportedOperationException - Every time this method is called.
    • displayToastToPlayer

      public final void displayToastToPlayer(@NotNull @NotNull Player player)
      Display the toast of this advancement to a player.

      Since TaskAdvancements cannot be registered in tabs, this method always throws UnsupportedOperationException.

      Overrides:
      displayToastToPlayer in class Advancement
      Parameters:
      player - The player the toast will be shown to.
      Throws:
      UnsupportedOperationException - Every time this method is called.
    • onUpdate

      public void onUpdate(@NotNull @NotNull TeamProgression teamProgression, @NotNull @NotNull Map<AdvancementWrapper,Integer> addedAdvancements)
      Handles the serialisation of the advancement into the update packet.

      Advancement(s) to be sent have to be added to the provided Map, which contains the AdvancementWrappers paired with the progression of the provided team.

      Since TaskAdvancements cannot be registered in tabs, this method always throws UnsupportedOperationException.

      Overrides:
      onUpdate in class Advancement
      Parameters:
      teamProgression - The TeamProgression of the team of the player(s).
      addedAdvancements - The Map in which the advancements to be sent are added as keys. The values are the current progressions of the team.
      Throws:
      UnsupportedOperationException - Every time this method is called.