Class AdvancementTab

java.lang.Object
net.minestom.server.advancements.AdvancementTab
All Implemented Interfaces:
Viewable

public class AdvancementTab
extends java.lang.Object
implements Viewable
Represents a tab which can be shared between multiple players.

Each tab requires a root advancement and all succeeding advancements need to have a parent in the tab. You can create a new advancement using createAdvancement(String, Advancement, Advancement).

Be sure to use addViewer(Player) and removeViewer(Player) to control which players can see the tab. (all viewers will see the same tab, with the same amount of validated advancements etc... so shared).

  • Field Details

  • Constructor Details

  • Method Details

    • getTabs

      @Nullable public static java.util.Set<AdvancementTab> getTabs​(@NotNull Player player)
      Gets all the tabs of a viewer.
      Parameters:
      player - the player to get the tabs from
      Returns:
      all the advancement tabs that the player sees, can be null if the player doesn't see anything
    • getRoot

      @NotNull public AdvancementRoot getRoot()
      Gets the root advancement of this tab.
      Returns:
      the root advancement
    • createAdvancement

      public void createAdvancement​(@NotNull java.lang.String identifier, @NotNull Advancement advancement, @NotNull Advancement parent)
      Creates and add an advancement into this tab.
      Parameters:
      identifier - the unique identifier
      advancement - the advancement to add
      parent - the parent of this advancement, it cannot be null
    • createPacket

      @NotNull protected AdvancementsPacket createPacket()
      Builds the packet which build the whole advancement tab.
      Returns:
      the packet adding this advancement tab and all its advancements
    • addViewer

      public boolean addViewer​(@NotNull Player player)
      Description copied from interface: Viewable
      Adds a viewer.
      Specified by:
      addViewer in interface Viewable
      Parameters:
      player - the viewer to add
      Returns:
      true if the player has been added, false otherwise (could be because he is already a viewer)
    • removeViewer

      public boolean removeViewer​(@NotNull Player player)
      Description copied from interface: Viewable
      Removes a viewer.
      Specified by:
      removeViewer in interface Viewable
      Parameters:
      player - the viewer to remove
      Returns:
      true if the player has been removed, false otherwise (could be because he was not a viewer)
    • getViewers

      @NotNull public java.util.Set<Player> getViewers()
      Description copied from interface: Viewable
      Gets all the viewers of this viewable element.
      Specified by:
      getViewers in interface Viewable
      Returns:
      A Set containing all the element's viewers