Class FakeAdvancement


public final class FakeAdvancement extends BaseAdvancement
The FakeAdvancement class is a non-saved and non-registrable invisible advancement.

This means that FakeAdvancements are not saved into the database and that they cannot be registered in any tab.

They are also not displayed by clients, but the connection to their parent is still visible. Thus, they can be sent in packets to display a connection.

Since FakeAdvancements are not saved, many methods are not supported.

  • Constructor Details

    • FakeAdvancement

      public FakeAdvancement(@NotNull @NotNull Advancement parent, float x, float y)
      Creates a new FakeAdvancement.
      Parameters:
      parent - The parent of the advancement.
      x - The x coordinate of the advancement.
      y - The y coordinate of the advancement.
    • FakeAdvancement

      Creates a new FakeAdvancement.
      Parameters:
      parent - The parent of the advancement.
      display - The display information of this advancement.
  • Method Details

    • getDisplay

      Gets the AdvancementDisplay of this advancement.
      Overrides:
      getDisplay in class Advancement
      Returns:
      The AdvancementDisplay of this advancement.
    • getNMSWrapper

      @NotNull public @NotNull AdvancementWrapper getNMSWrapper()
      Returns the NMS wrapper of this advancement. Should craft the NMS wrapper once and returns it henceforth.
      Overrides:
      getNMSWrapper in class BaseAdvancement
      Returns:
      The NMS wrapper of this advancement.
    • getProgression

      public int getProgression(@NotNull @NotNull Player player)
      Gets the current progression of the provided player's team. Since FakeAdvancements are not saved, this method returns always 0.
      Overrides:
      getProgression in class Advancement
      Parameters:
      player - The player.
      Returns:
      Always 0.
    • getProgression

      public int getProgression(@NotNull @NotNull UUID uuid)
      Gets the current progression of the provided player's team. Since FakeAdvancements are not saved, this method returns always 0.
      Overrides:
      getProgression in class Advancement
      Parameters:
      uuid - The UUID of the player.
      Returns:
      Always 0.
    • getProgression

      public int getProgression(@NotNull @NotNull TeamProgression progression)
      Gets the current progression of the provided team. Since FakeAdvancements are not saved, this method returns always 0.
      Overrides:
      getProgression in class Advancement
      Parameters:
      progression - The TeamProgression of the team.
      Returns:
      Always 0.
    • isVisible

      @Contract("_ -> true") public 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 FakeAdvancements are not saved, this method returns always true.

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

      @Contract("_ -> true") public 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 FakeAdvancements are not saved, this method returns always true.

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

      @Contract("_ -> true") public 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 FakeAdvancements are not saved, this method returns always true.

      Overrides:
      isVisible in class Advancement
      Parameters:
      progression - TheTeamProgression of the team.
      Returns:
      Always true.
    • 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.

      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.
    • isGranted

      public boolean isGranted(@NotNull @NotNull Player player)
      Returns whether the advancement has been completed by the provided player's team. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      isGranted in class Advancement
      Parameters:
      player - The player.
      Returns:
      Whether the advancement has been completed by the provided player's team.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • isGranted

      public boolean isGranted(@NotNull @NotNull UUID uuid)
      Returns whether the advancement has been completed by the provided player's team. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      isGranted in class Advancement
      Parameters:
      uuid - The UUID of the player.
      Returns:
      Whether the advancement has been completed by the provided player's team.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • isGranted

      public boolean isGranted(@NotNull @NotNull TeamProgression progression)
      Returns whether the advancement has been completed by the provided team. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      isGranted in class Advancement
      Parameters:
      progression - The TeamProgression of the team.
      Returns:
      Whether the advancement has been completed by the provided team.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • getAnnounceMessage

      @Nullable public @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. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.

      Overrides:
      getAnnounceMessage in class Advancement
      Parameters:
      player - The player who has completed the advancement.
      Returns:
      The message to be displayed, or null if no message should be displayed.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • incrementProgression

      public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull UUID uuid)
      Increases the progression of the provided player's team by one.

      If the advancement gets completed, advancement rewards will be given. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.

      Overrides:
      incrementProgression in class Advancement
      Parameters:
      uuid - The UUID of the player responsible for the increment. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.
      Returns:
      The new progression. It is always less or equal to Advancement.maxProgression.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • incrementProgression

      public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull UUID uuid, boolean giveReward)
      Increases the progression of the provided player's team by one. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      incrementProgression in class Advancement
      Parameters:
      uuid - The UUID of the player responsible for the increment. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.
      giveReward - Whether to give rewards if the advancement gets completed.
      Returns:
      The new progression. It is always less or equal to Advancement.maxProgression.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • incrementProgression

      public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull UUID uuid, @Range(from=0, to=Integer.MAX_VALUE) int increment)
      Increases the progression of the provided player's team.

      If the advancement gets completed, advancement rewards will be given. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.

      Overrides:
      incrementProgression in class Advancement
      Parameters:
      uuid - The UUID of the player responsible for the increment. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.
      increment - The progression increment. Must be greater than 0.
      Returns:
      The new progression. It is always less or equal to Advancement.maxProgression.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • incrementProgression

      public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull UUID uuid, @Range(from=0, to=Integer.MAX_VALUE) int increment, boolean giveReward)
      Increases the progression of the provided player's team. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      incrementProgression in class Advancement
      Parameters:
      uuid - The UUID of the player responsible for the increment. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.
      increment - The progression increment. Must be greater than 0.
      giveReward - Whether to give rewards if the advancement gets completed.
      Returns:
      The new progression. It is always less or equal to Advancement.maxProgression.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • incrementProgression

      public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull Player player)
      Increases the progression of the provided player's team by one.

      If the advancement gets completed, advancement rewards will be given. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.

      Overrides:
      incrementProgression in class Advancement
      Parameters:
      player - The player who is responsible for the increment.
      Returns:
      The new progression. It is always less or equal to Advancement.maxProgression.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • incrementProgression

      public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull Player player, boolean giveReward)
      Increases the progression of the provided player's team by one. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      incrementProgression in class Advancement
      Parameters:
      player - The player who is responsible for the increment.
      giveReward - Whether to give rewards if the advancement gets completed.
      Returns:
      The new progression. It is always less or equal to Advancement.maxProgression.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • incrementProgression

      public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull Player player, @Range(from=0, to=Integer.MAX_VALUE) int increment)
      Increases the progression of the provided player's team.

      If the advancement gets completed, advancement rewards will be given. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.

      Overrides:
      incrementProgression in class Advancement
      Parameters:
      player - The player who is responsible for the increment.
      increment - The progression increment. Must be greater than 0.
      Returns:
      The new progression. It is always less or equal to Advancement.maxProgression.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • incrementProgression

      public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull Player player, @Range(from=0, to=Integer.MAX_VALUE) int increment, boolean giveReward)
      Increases the progression of the provided player's team. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      incrementProgression in class Advancement
      Parameters:
      player - The player who is responsible for the increment.
      increment - The progression increment. Must be greater than 0.
      giveReward - Whether to give rewards if the advancement gets completed.
      Returns:
      The new progression. It is always less or equal to Advancement.maxProgression.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • incrementProgression

      protected @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull TeamProgression pro, @Nullable @Nullable Player player, @Range(from=0, to=Integer.MAX_VALUE) int increment, boolean giveRewards)
      Increases the progression of 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. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.

      Overrides:
      incrementProgression in class Advancement
      Parameters:
      pro - The TeamProgression of the team.
      player - The team member responsible for the increment. May be null.
      increment - The progression increment. Must be greater than 0.
      giveRewards - Whether to give rewards if the advancement gets completed.
      Returns:
      The new progression. It is always less or equal to Advancement.maxProgression.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • setProgression

      public void setProgression(@NotNull @NotNull UUID uuid, @Range(from=0, to=Integer.MAX_VALUE) int progression)
      Sets a progression for the provided player's team.

      If the advancement gets completed, advancement rewards will be given. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.

      Overrides:
      setProgression in class Advancement
      Parameters:
      uuid - The UUID of the player responsible for the update. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.
      progression - The new non-negative progression to set.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • setProgression

      public void setProgression(@NotNull @NotNull UUID uuid, @Range(from=0, to=Integer.MAX_VALUE) int progression, boolean giveReward)
      Sets a progression for the provided player's team. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      setProgression in class Advancement
      Parameters:
      uuid - The UUID of the player responsible for the update. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.
      progression - The new non-negative progression to set.
      giveReward - Whether to give rewards if the advancement gets completed.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • setProgression

      public void setProgression(@NotNull @NotNull Player player, @Range(from=0, to=Integer.MAX_VALUE) int progression)
      Sets a progression for the provided player's team.

      If the advancement gets completed, advancement rewards will be given. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.

      Overrides:
      setProgression in class Advancement
      Parameters:
      player - The player who is responsible for the update.
      progression - The new non-negative progression to set.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • setProgression

      public void setProgression(@NotNull @NotNull Player player, @Range(from=0, to=Integer.MAX_VALUE) int progression, boolean giveReward)
      Sets a progression for the provided player's team. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      setProgression in class Advancement
      Parameters:
      player - The player who is responsible for the update.
      progression - The new non-negative progression to set.
      giveReward - Whether to give rewards if the advancement gets completed.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • 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. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.

      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.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • handlePlayer

      protected void handlePlayer(@NotNull @NotNull TeamProgression pro, @Nullable @Nullable Player player, int newProgression, int oldProgression, boolean giveRewards, @Nullable @Nullable AfterHandle afterHandle)
      Handles the reward process of the advancement.

      When the new progression is greater or equal than Advancement.maxProgression and the old progression is less than Advancement.maxProgression then the advancement is being completed by the provided player. If the provided player is non-null, they will receive the rewards. Otherwise, if there are online members in the team one of them will receive the advancement rewards. If no member of the team are online, the advancement will be set unredeemed for that team. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.

      Overrides:
      handlePlayer in class Advancement
      Parameters:
      pro - The TeamProgression of the team.
      player - The team member responsible for the update. May be null.
      newProgression - The new non-negative progression that has been set.
      oldProgression - The previous progression of the team.
      giveRewards - Whether to give rewards if the advancement gets completed.
      afterHandle - The action to perform after the reward process, or null to don't do any action. The default action updates the tab's advancement to the team (see AfterHandle.UPDATE_ADVANCEMENTS_TO_TEAM).
      Throws:
      UnsupportedOperationException - Always when it's called.
    • displayToastToPlayer

      public void displayToastToPlayer(@NotNull @NotNull Player player)
      Display the toast of this advancement to a player. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      displayToastToPlayer in class Advancement
      Parameters:
      player - The player the toast will be shown to.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • 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 FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      onGrant in class Advancement
      Parameters:
      player - The player who completed the advancement.
      giveRewards - Whether to give rewards.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • giveReward

      public void giveReward(@NotNull @NotNull Player player)
      Gives the rewards to the provided player when the advancement is completed. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      giveReward in class Advancement
      Parameters:
      player - The player who has completed the advancement.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • grant

      public void grant(@NotNull @NotNull Player player)
      Grants the advancement to the player's team giving rewards. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      grant in class Advancement
      Parameters:
      player - The player.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • grant

      public void grant(@NotNull @NotNull Player player, boolean giveRewards)
      Grant the advancement to the player's team. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      grant in class Advancement
      Parameters:
      player - The player
      giveRewards - Whether to give rewards.
      Throws:
      UnsupportedOperationException - Always when it's called.
    • revoke

      public void revoke(@NotNull @NotNull Player player)
      Revoke the advancement to the player's team. Since FakeAdvancements are not saved, this method always throws an UnsupportedOperationException.
      Overrides:
      revoke in class Advancement
      Parameters:
      player - The player.
      Throws:
      UnsupportedOperationException - Always when it's called.