Class AdvancementTab
java.lang.Object
com.fren_gor.ultimateAdvancementAPI.AdvancementTab
The
AdvancementTab
class represents a tab in the advancement GUI.
Every advancement tab is represented by a unique namespace (not visible in the advancement GUI) and has only one RootAdvancement
.
An instance can be obtained using UltimateAdvancementAPI.createAdvancementTab(String)
.
The returned instance is not initialised, that is it doesn't contain any advancement yet.
-
Method Summary
Modifier and TypeMethodDescriptionUtility method which automatically grants the root advancement of this tab to every player after they have been loaded.Utility method which automatically shows this tab to every player just after they have been loaded.boolean
getAdvancement
(AdvancementKey namespacedKey) Gets the advancement of the tab with the providedAdvancementKey
.Gets an unmodifiableCollection
of all the tab's advancements.Returns an unmodifiableCollection
of all the advancement's keys of this tab asString
s.getAdvancementsByClass
(Class<? extends Advancement> filterClass) Gets an unmodifiableCollection
of all the tab's advancements that are an instance of the provided class or any of its subclasses.Gets an unmodifiableSet
of theAdvancementKey
s of all the tab's advancements.Gets an unmodifiableCollection
of all the tab's advancements but the root.Gets theDatabaseManager
of this tab.Gets theEventManager
of this tab.Gets the unique namespace of this tab.Gets the plugin that created this advancement tab.Returns an unmodifiableSet
of the players the tab is currently shown to.Returns the root advancement of this tab.void
grantRootAdvancement
(@NotNull UUID uuid) Grants the root advancement of the tab to the specified player giving rewards.void
grantRootAdvancement
(@NotNull UUID uuid, boolean giveRewards) Grants the root advancement of the tab to the specified player.void
grantRootAdvancement
(@NotNull Player player) Grants the root advancement of the tab to the specified player giving rewards.void
grantRootAdvancement
(@NotNull Player player, boolean giveRewards) Grants the root advancement of the tab to the specified player.boolean
hasAdvancement
(Advancement advancement) Returns whether the provided advancement belongs to the tab.boolean
hasAdvancement
(AdvancementKey namespacedKey) Returns whether an advancement with the providedAdvancementKey
belongs to the tab.int
hashCode()
void
Hides the tab and its advancements to the provided player.void
Hides the tab and its advancements to the provided players.boolean
isActive()
Returns whether the tab is initialised and not disposed.boolean
Returns whether the tab is disposed.boolean
Gets whether the tab is initialized.boolean
isOwnedByThisTab
(@NotNull Advancement advancement) Returns whether the namespace of the specified advancement's key is equals to this tab namespace.boolean
Returns whether the tab is shown to the specified player.void
registerAdvancements
(@NotNull RootAdvancement rootAdvancement, @NotNull BaseAdvancement... advancements) Register the advancements for this tab, initializing the tab.void
registerAdvancements
(@NotNull RootAdvancement rootAdvancement, @NotNull Set<BaseAdvancement> advancements) Register the advancements for this tab, initializing the tab.<E extends Event>
voidregisterEvent
(@NotNull Class<E> eventClass, @NotNull Consumer<E> consumer) Registers the provided event into theEventManager
of this tab.<E extends Event>
voidregisterEvent
(@NotNull Class<E> eventClass, @NotNull EventPriority priority, @NotNull Consumer<E> consumer) Registers the provided event into theEventManager
of this tab.void
Shows the tab to the provided player and sends them the advancements of the tab.void
Shows the tab to the provided players and sends them the advancements of the tab.toString()
Returns the namespace of the tab.void
Sends or updates the advancements of the tab to the provided team's members.void
Sends or updates the advancements of the tab to the provided player's team members.void
updateAdvancementsToTeam
(@NotNull Player player) Sends or updates the advancements of the tab to the provided player's team members.void
updateEveryAdvancement
(@NotNull Player player) Deprecated.
-
Method Details
-
isActive
public boolean isActive()Returns whether the tab is initialised and not disposed.- Returns:
- Whether the tab is initialised and not disposed.
-
getRootAdvancement
Returns the root advancement of this tab.- Returns:
- The root advancement of this tab.
- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
getAdvancements
@NotNull @Contract(pure=true) public @UnmodifiableView @NotNull Collection<@NotNull Advancement> getAdvancements()Gets an unmodifiableCollection
of all the tab's advancements.- Returns:
- An unmodifiable
Collection
of all the tab's advancements. - Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
getAdvancementsWithoutRoot
@NotNull public @Unmodifiable @NotNull Collection<@NotNull BaseAdvancement> getAdvancementsWithoutRoot()Gets an unmodifiableCollection
of all the tab's advancements but the root.- Returns:
- An unmodifiable
Collection
of all the tab's advancements but the root. - Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
getAdvancementsByClass
@NotNull @Contract(pure=true) public @Unmodifiable @NotNull Collection<@NotNull Advancement> getAdvancementsByClass(Class<? extends Advancement> filterClass) Gets an unmodifiableCollection
of all the tab's advancements that are an instance of the provided class or any of its subclasses.If the provided class is
null
, then an emptyCollection
is returned.- Parameters:
filterClass
- The filter class.- Returns:
- An unmodifiable
Collection
of all the tab's advancements that are an instance of the provided class or any of its subclasses. - Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
getAdvancementsNamespacedKeys
@NotNull @Contract(pure=true) public @UnmodifiableView @NotNull Set<@NotNull AdvancementKey> getAdvancementsNamespacedKeys()Gets an unmodifiableSet
of theAdvancementKey
s of all the tab's advancements.- Returns:
- An unmodifiable
Set
of theAdvancementKey
s of all the tab's advancements. - Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
hasAdvancement
Returns whether the provided advancement belongs to the tab.- Parameters:
advancement
- The advancement.- Returns:
- Whether the provided advancement belongs to the tab.
- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
hasAdvancement
@Contract(pure=true, value="null -> false") public boolean hasAdvancement(AdvancementKey namespacedKey) Returns whether an advancement with the providedAdvancementKey
belongs to the tab.- Parameters:
namespacedKey
- TheAdvancementKey
of the advancement.- Returns:
- Whether an advancement with the provided
AdvancementKey
belongs to the tab. - Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
getAdvancement
@Nullable @Contract(pure=true, value="null -> null") public @Nullable Advancement getAdvancement(AdvancementKey namespacedKey) Gets the advancement of the tab with the providedAdvancementKey
.- Parameters:
namespacedKey
- TheAdvancementKey
of the wanted advancement of this tab.- Returns:
- The advancement of the tab with the provided
AdvancementKey
, ornull
if there's not. - Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
getPlayers
Returns an unmodifiableSet
of the players the tab is currently shown to.- Returns:
- An unmodifiable
Set
of the players the tab is currently shown to. - Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
grantRootAdvancement
Grants the root advancement of the tab to the specified player giving rewards.- Parameters:
player
- The player who is completing the root advancement.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
grantRootAdvancement
Grants the root advancement of the tab to the specified player giving rewards.- Parameters:
uuid
- TheUUID
of the player who is completing the root advancement.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
grantRootAdvancement
Grants the root advancement of the tab to the specified player.- Parameters:
player
- The player who is completing the root advancement.giveRewards
- Whether to give rewards.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
grantRootAdvancement
Grants the root advancement of the tab to the specified player.- Parameters:
uuid
- TheUUID
of the player who is completing the root advancement.giveRewards
- Whether to give rewards.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
updateAdvancementsToTeam
Sends or updates the advancements of the tab to the provided player's team members.- Parameters:
player
- The player.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.UserNotLoadedException
- If the provided player's team is not loaded.
-
updateAdvancementsToTeam
Sends or updates the advancements of the tab to the provided player's team members.- Parameters:
uuid
- AUUID
of the player.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.UserNotLoadedException
- If the provided player's team is not loaded.
-
updateAdvancementsToTeam
Sends or updates the advancements of the tab to the provided team's members.- Parameters:
pro
- TheTeamProgression
of the team.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
updateEveryAdvancement
@Deprecated(since="2.2.0") public void updateEveryAdvancement(@NotNull @NotNull Player player) throws UserNotLoadedException Deprecated.UseupdateAdvancementsToTeam(Player)
instead.Sends or updates the advancements of the tab to the provided player.- Parameters:
player
- The player.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.UserNotLoadedException
- If the provided player's team is not loaded.
-
registerAdvancements
public void registerAdvancements(@NotNull @NotNull RootAdvancement rootAdvancement, @NotNull @NotNull BaseAdvancement... advancements) Register the advancements for this tab, initializing the tab. Thus, it cannot be called twice.- Parameters:
rootAdvancement
- The root of this tab.advancements
- The advancements of this tab. Cannot include anynull
advancement orRootAdvancement
.- Throws:
IllegalStateException
- If the tab is already initialised.DisposedException
- If the tab is disposed.
-
registerAdvancements
public void registerAdvancements(@NotNull @NotNull RootAdvancement rootAdvancement, @NotNull @NotNull Set<BaseAdvancement> advancements) Register the advancements for this tab, initializing the tab. Thus, it cannot be called twice.- Parameters:
rootAdvancement
- The root of this tab.advancements
- The advancements of this tab. Cannot include anynull
advancement orRootAdvancement
.- Throws:
IllegalStateException
- If the tab is already initialised.DisposedException
- If the tab is disposed.
-
showTab
Shows the tab to the provided players and sends them the advancements of the tab.- Parameters:
players
- The players the tab will be shown to.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
showTab
Shows the tab to the provided player and sends them the advancements of the tab.- Parameters:
player
- The player the tab will be shown to.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
hideTab
Hides the tab and its advancements to the provided players.- Parameters:
players
- The players the tab will be hid to.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.- Since:
- 1.0.2
-
hideTab
Hides the tab and its advancements to the provided player.- Parameters:
player
- The player the tab will be hid to.- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
isShownTo
Returns whether the tab is shown to the specified player.- Parameters:
player
- The player.- Returns:
- Whether the tab is shown to the specified player.
- Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
getAdvancementsAsStrings
Returns an unmodifiableCollection
of all the advancement's keys of this tab asString
s.- Returns:
- An unmodifiable
Collection
of all the advancement's keys of this tab asString
s. - Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.
-
isOwnedByThisTab
Returns whether the namespace of the specified advancement's key is equals to this tab namespace.- Parameters:
advancement
- The advancement.- Returns:
- Whether the namespace of the specified advancement's key is equals to this tab namespace.
-
automaticallyShowToPlayers
Utility method which automatically shows this tab to every player just after they have been loaded.More formally, this is equivalent to calling:
tab.registerEvent(PlayerLoadingCompletedEvent.class, EventPriority.LOWEST, e -> tab.showTab(e.getPlayer()));
- Returns:
- This
AdvancementTab
. - Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.- Since:
- 2.2.0
-
automaticallyGrantRootAdvancement
Utility method which automatically grants the root advancement of this tab to every player after they have been loaded.More formally, this is equivalent to calling:
tab.registerEvent(PlayerLoadingCompletedEvent.class, EventPriority.LOW, e -> tab.grantRootAdvancement(e.getPlayer()));
- Returns:
- This
AdvancementTab
. - Throws:
IllegalStateException
- If the tab is not initialised.DisposedException
- If the tab is disposed.- Since:
- 2.2.0
-
registerEvent
public <E extends Event> void registerEvent(@NotNull @NotNull Class<E> eventClass, @NotNull @NotNull Consumer<E> consumer) Registers the provided event into theEventManager
of this tab.- Type Parameters:
E
- The class of the event to register.- Parameters:
eventClass
- The class of the event to register.consumer
- The code to run when the event occurs.- Throws:
DisposedException
- If the tab is disposed.IllegalArgumentException
- If any argument is null.- Since:
- 2.2.0
-
registerEvent
public <E extends Event> void registerEvent(@NotNull @NotNull Class<E> eventClass, @NotNull @NotNull EventPriority priority, @NotNull @NotNull Consumer<E> consumer) Registers the provided event into theEventManager
of this tab.- Type Parameters:
E
- The class of the event to register.- Parameters:
eventClass
- The class of the event to register.priority
- The priority of the event. SeeEventPriority
.consumer
- The code to run when the event occurs.- Throws:
DisposedException
- If the tab is disposed.IllegalArgumentException
- If any argument is null.- Since:
- 2.2.0
-
toString
Returns the namespace of the tab. -
equals
-
hashCode
public int hashCode() -
getOwningPlugin
Gets the plugin that created this advancement tab.- Returns:
- The plugin that created this advancement tab.
-
getEventManager
Gets theEventManager
of this tab.- Returns:
- The
EventManager
of this tab.
-
getNamespace
Gets the unique namespace of this tab.- Returns:
- The unique namespace of this tab.
-
getDatabaseManager
Gets theDatabaseManager
of this tab.- Returns:
- The
DatabaseManager
of this tab.
-
isInitialised
public boolean isInitialised()Gets whether the tab is initialized.- Returns:
- Whether the tab is initialized.
-
isDisposed
public boolean isDisposed()Returns whether the tab is disposed.- Returns:
- Whether the tab is disposed.
-
updateAdvancementsToTeam(Player)
instead.