Class AdvancementTab

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

public class AdvancementTab extends Object implements Viewable
Represents a tab which can be shared between multiple players. Created using AdvancementManager.createTab(String, AdvancementRoot).

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

    • AdvancementTab

      protected AdvancementTab(@NotNull @NotNull String rootIdentifier, @NotNull @NotNull AdvancementRoot root)
  • Method Details

    • getTabs

      @Nullable public static @Nullable Set<AdvancementTab> getTabs(@NotNull @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 @NotNull AdvancementRoot getRoot()
      Gets the root advancement of this tab.
      Returns:
      the root advancement
    • createAdvancement

      public void createAdvancement(@NotNull @NotNull String identifier, @NotNull @NotNull Advancement advancement, @NotNull @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 @NotNull 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 @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 @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 @NotNull 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