Package net.minestom.server.advancements
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 Summary
Fields Modifier and Type Field Description protected AdvancementsPacket
removePacket
-
Constructor Summary
Constructors Modifier Constructor Description protected
AdvancementTab(java.lang.String rootIdentifier, AdvancementRoot root)
-
Method Summary
Modifier and Type Method Description boolean
addViewer(Player player)
Adds a viewer.void
createAdvancement(java.lang.String identifier, Advancement advancement, Advancement parent)
Creates and add an advancement into this tab.protected AdvancementsPacket
createPacket()
Builds the packet which build the whole advancement tab.AdvancementRoot
getRoot()
Gets the root advancement of this tab.static java.util.Set<AdvancementTab>
getTabs(Player player)
Gets all the tabs of a viewer.java.util.Set<Player>
getViewers()
Gets all the viewers of this viewable element.boolean
removeViewer(Player player)
Removes a viewer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minestom.server.Viewable
isViewer, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Field Details
-
Constructor Details
-
Method Details
-
getTabs
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
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 identifieradvancement
- the advancement to addparent
- the parent of this advancement, it cannot be null
-
createPacket
Builds the packet which build the whole advancement tab.- Returns:
- the packet adding this advancement tab and all its advancements
-
addViewer
Description copied from interface:Viewable
Adds a viewer. -
removeViewer
Description copied from interface:Viewable
Removes a viewer.- Specified by:
removeViewer
in interfaceViewable
- 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
Description copied from interface:Viewable
Gets all the viewers of this viewable element.- Specified by:
getViewers
in interfaceViewable
- Returns:
- A Set containing all the element's viewers
-