Package net.minestom.server.advancements
Class AdvancementTab
java.lang.Object
net.minestom.server.advancements.AdvancementTab
- All Implemented Interfaces:
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 Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
AdvancementTab
(@NotNull String rootIdentifier, @NotNull AdvancementRoot root) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a viewer.void
createAdvancement
(@NotNull String identifier, @NotNull Advancement advancement, @NotNull Advancement parent) Creates and add an advancement into this tab.protected @NotNull AdvancementsPacket
Builds the packet which build the whole advancement tab.@NotNull AdvancementRoot
getRoot()
Gets the root advancement of this tab.static @Nullable Set
<AdvancementTab> Gets all the tabs of a viewer.Gets all the viewers of this viewable element.boolean
removeViewer
(@NotNull 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
getViewersAsAudience, getViewersAsAudiences, isViewer, sendPacketsToViewers, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Field Details
-
removePacket
-
-
Constructor Details
-
AdvancementTab
protected AdvancementTab(@NotNull @NotNull String rootIdentifier, @NotNull @NotNull AdvancementRoot root)
-
-
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 @NotNull String identifier, @NotNull @NotNull Advancement advancement, @NotNull @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
-