Class FakeAdvancement
FakeAdvancement
class is a non-saved and non-registrable invisible advancement.
This means that FakeAdvancement
s are not saved into the database and that they cannot be registered in any tab.
They are also not displayed by clients, but the connection to their parent is still visible. Thus, they can be sent in packets to display a connection.
Since FakeAdvancement
s are not saved, many methods are not supported.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
TheAdvancementDisplay
used byFakeAdvancement
s. -
Field Summary
Fields inherited from class com.fren_gor.ultimateAdvancementAPI.advancement.BaseAdvancement
parent
Fields inherited from class com.fren_gor.ultimateAdvancementAPI.advancement.Advancement
advancementTab, display, key, maxProgression
-
Constructor Summary
ConstructorDescriptionFakeAdvancement
(@NotNull Advancement parent, float x, float y) Creates a newFakeAdvancement
.FakeAdvancement
(@NotNull Advancement parent, @NotNull FakeAdvancement.FakeAdvancementDisplay display) Creates a newFakeAdvancement
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
displayToastToPlayer
(@NotNull Player player) Display the toast of this advancement to a player.getAnnounceMessage
(@NotNull Player player) Gets the chat message to be sent when an advancement is completed.Gets theAdvancementDisplay
of this advancement.Returns the NMS wrapper of this advancement.int
getProgression
(@NotNull TeamProgression progression) Gets the current progression of the provided team.int
getProgression
(@NotNull UUID uuid) Gets the current progression of the provided player's team.int
getProgression
(@NotNull Player player) Gets the current progression of the provided player's team.void
giveReward
(@NotNull Player player) Gives the rewards to the provided player when the advancement is completed.void
Grants the advancement to the player's team giving rewards.void
Grant the advancement to the player's team.protected void
handlePlayer
(@NotNull TeamProgression pro, @Nullable Player player, int newProgression, int oldProgression, boolean giveRewards, @Nullable AfterHandle afterHandle) Handles the reward process of the advancement.incrementProgression
(@NotNull TeamProgression pro, @Nullable Player player, @Range(from=0, to=Integer.MAX_VALUE) int increment, boolean giveRewards) Increases the progression of the provided team.incrementProgression
(@NotNull UUID uuid) Increases the progression of the provided player's team by one.Increases the progression of the provided player's team.incrementProgression
(@NotNull UUID uuid, @Range(from=0, to=Integer.MAX_VALUE) int increment, boolean giveReward) Increases the progression of the provided player's team.incrementProgression
(@NotNull UUID uuid, boolean giveReward) Increases the progression of the provided player's team by one.incrementProgression
(@NotNull Player player) Increases the progression of the provided player's team by one.Increases the progression of the provided player's team.incrementProgression
(@NotNull Player player, @Range(from=0, to=Integer.MAX_VALUE) int increment, boolean giveReward) Increases the progression of the provided player's team.incrementProgression
(@NotNull Player player, boolean giveReward) Increases the progression of the provided player's team by one.boolean
isGranted
(@NotNull TeamProgression progression) Returns whether the advancement has been completed by the provided team.boolean
Returns whether the advancement has been completed by the provided player's team.boolean
Returns whether the advancement has been completed by the provided player's team.boolean
isVisible
(@NotNull TeamProgression progression) Returns whether the advancement is visible to the provided team.boolean
Returns whether the advancement is visible to the provided player.boolean
Returns whether the advancement is visible to the provided player.void
Called when the advancement is completed by a player.void
onUpdate
(@NotNull TeamProgression teamProgression, @NotNull Map<AdvancementWrapper, Integer> addedAdvancements) Handles the serialisation of the advancement into the update packet.void
Revoke the advancement to the player's team.protected void
setProgression
(@NotNull TeamProgression pro, @Nullable Player player, @Range(from=0, to=Integer.MAX_VALUE) int progression, boolean giveRewards) Sets a new progression for the provided team.void
Sets a progression for the provided player's team.void
setProgression
(@NotNull UUID uuid, @Range(from=0, to=Integer.MAX_VALUE) int progression, boolean giveReward) Sets a progression for the provided player's team.void
Sets a progression for the provided player's team.void
setProgression
(@NotNull Player player, @Range(from=0, to=Integer.MAX_VALUE) int progression, boolean giveReward) Sets a progression for the provided player's team.Methods inherited from class com.fren_gor.ultimateAdvancementAPI.advancement.BaseAdvancement
getParent, validateRegister
Methods inherited from class com.fren_gor.ultimateAdvancementAPI.advancement.Advancement
equals, getAdvancementTab, getKey, getMaxProgression, hashCode, isValid, onDispose, onRegister, registerEvent, registerEvent, toString
-
Constructor Details
-
FakeAdvancement
Creates a newFakeAdvancement
.- Parameters:
parent
- The parent of the advancement.x
- The x coordinate of the advancement.y
- The y coordinate of the advancement.
-
FakeAdvancement
public FakeAdvancement(@NotNull @NotNull Advancement parent, @NotNull @NotNull FakeAdvancement.FakeAdvancementDisplay display) Creates a newFakeAdvancement
.- Parameters:
parent
- The parent of the advancement.display
- The display information of this advancement.
-
-
Method Details
-
getDisplay
Gets theAdvancementDisplay
of this advancement.- Overrides:
getDisplay
in classAdvancement
- Returns:
- The
AdvancementDisplay
of this advancement.
-
getNMSWrapper
Returns the NMS wrapper of this advancement. Should craft the NMS wrapper once and returns it henceforth.- Overrides:
getNMSWrapper
in classBaseAdvancement
- Returns:
- The NMS wrapper of this advancement.
-
getProgression
Gets the current progression of the provided player's team. SinceFakeAdvancement
s are not saved, this method returns always0
.- Overrides:
getProgression
in classAdvancement
- Parameters:
player
- The player.- Returns:
- Always
0
.
-
getProgression
Gets the current progression of the provided player's team. SinceFakeAdvancement
s are not saved, this method returns always0
.- Overrides:
getProgression
in classAdvancement
- Parameters:
uuid
- TheUUID
of the player.- Returns:
- Always
0
.
-
getProgression
Gets the current progression of the provided team. SinceFakeAdvancement
s are not saved, this method returns always0
.- Overrides:
getProgression
in classAdvancement
- Parameters:
progression
- TheTeamProgression
of the team.- Returns:
- Always
0
.
-
isVisible
Returns whether the advancement is visible to the provided player.An advancement is visible to a player if and only if it is visible to all the players in the player's team. By default, every advancement is visible to every player, but this behavior can be changed overriding
Advancement.isVisible(TeamProgression)
or implementing a suitable interface for the Advancement Visibility System (seeIVisibility
for more information). SinceFakeAdvancement
s are not saved, this method returns alwaystrue
.- Overrides:
isVisible
in classAdvancement
- Parameters:
player
- The player.- Returns:
- Always
true
.
-
isVisible
Returns whether the advancement is visible to the provided player.An advancement is visible to a player if and only if it is visible to all the players in the player's team. By default, every advancement is visible to every player, but this behavior can be changed overriding
Advancement.isVisible(TeamProgression)
or implementing a suitable interface for the Advancement Visibility System (seeIVisibility
for more information). SinceFakeAdvancement
s are not saved, this method returns alwaystrue
.- Overrides:
isVisible
in classAdvancement
- Parameters:
uuid
- TheUUID
of the player.- Returns:
- Always
true
.
-
isVisible
Returns whether the advancement is visible to the provided team.An advancement is visible to a team if and only if it is visible to all the players in the team. By default, every advancement is visible to every player, but this behavior can be changed overriding this method or implementing a suitable interface for the Advancement Visibility System. Since
FakeAdvancement
s are not saved, this method returns alwaystrue
.- Overrides:
isVisible
in classAdvancement
- Parameters:
progression
- TheTeamProgression
of the team.- Returns:
- Always
true
.
-
onUpdate
public void onUpdate(@NotNull @NotNull TeamProgression teamProgression, @NotNull @NotNull Map<AdvancementWrapper, Integer> addedAdvancements) Handles the serialisation of the advancement into the update packet.Advancement(s) to be sent have to be added to the provided
Map
, which contains theAdvancementWrapper
s paired with the progression of the provided team.- Overrides:
onUpdate
in classAdvancement
- Parameters:
teamProgression
- TheTeamProgression
of the team of the player(s).addedAdvancements
- TheMap
in which the advancements to be sent are added as keys. The values are the current progressions of the team.
-
isGranted
Returns whether the advancement has been completed by the provided player's team. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
isGranted
in classAdvancement
- Parameters:
player
- The player.- Returns:
- Whether the advancement has been completed by the provided player's team.
- Throws:
UnsupportedOperationException
- Always when it's called.
-
isGranted
Returns whether the advancement has been completed by the provided player's team. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
isGranted
in classAdvancement
- Parameters:
uuid
- TheUUID
of the player.- Returns:
- Whether the advancement has been completed by the provided player's team.
- Throws:
UnsupportedOperationException
- Always when it's called.
-
isGranted
Returns whether the advancement has been completed by the provided team. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
isGranted
in classAdvancement
- Parameters:
progression
- TheTeamProgression
of the team.- Returns:
- Whether the advancement has been completed by the provided team.
- Throws:
UnsupportedOperationException
- Always when it's called.
-
getAnnounceMessage
Gets the chat message to be sent when an advancement is completed.The message is sent to everybody online on the server. Since
FakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
getAnnounceMessage
in classAdvancement
- Parameters:
player
- The player who has completed the advancement.- Returns:
- The message to be displayed, or
null
if no message should be displayed. - Throws:
UnsupportedOperationException
- Always when it's called.
-
incrementProgression
Increases the progression of the provided player's team by one.If the advancement gets completed, advancement rewards will be given. Since
FakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
incrementProgression
in classAdvancement
- Parameters:
uuid
- TheUUID
of the player responsible for the increment. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.- Returns:
- The new progression. It is always less or equal to
Advancement.maxProgression
. - Throws:
UnsupportedOperationException
- Always when it's called.
-
incrementProgression
public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull UUID uuid, boolean giveReward) Increases the progression of the provided player's team by one. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
incrementProgression
in classAdvancement
- Parameters:
uuid
- TheUUID
of the player responsible for the increment. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.giveReward
- Whether to give rewards if the advancement gets completed.- Returns:
- The new progression. It is always less or equal to
Advancement.maxProgression
. - Throws:
UnsupportedOperationException
- Always when it's called.
-
incrementProgression
public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull UUID uuid, @Range(from=0, to=Integer.MAX_VALUE) int increment) Increases the progression of the provided player's team.If the advancement gets completed, advancement rewards will be given. Since
FakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
incrementProgression
in classAdvancement
- Parameters:
uuid
- TheUUID
of the player responsible for the increment. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.increment
- The progression increment. Must be greater than0
.- Returns:
- The new progression. It is always less or equal to
Advancement.maxProgression
. - Throws:
UnsupportedOperationException
- Always when it's called.
-
incrementProgression
public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull UUID uuid, @Range(from=0, to=Integer.MAX_VALUE) int increment, boolean giveReward) Increases the progression of the provided player's team. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
incrementProgression
in classAdvancement
- Parameters:
uuid
- TheUUID
of the player responsible for the increment. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.increment
- The progression increment. Must be greater than0
.giveReward
- Whether to give rewards if the advancement gets completed.- Returns:
- The new progression. It is always less or equal to
Advancement.maxProgression
. - Throws:
UnsupportedOperationException
- Always when it's called.
-
incrementProgression
public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull Player player) Increases the progression of the provided player's team by one.If the advancement gets completed, advancement rewards will be given. Since
FakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
incrementProgression
in classAdvancement
- Parameters:
player
- The player who is responsible for the increment.- Returns:
- The new progression. It is always less or equal to
Advancement.maxProgression
. - Throws:
UnsupportedOperationException
- Always when it's called.
-
incrementProgression
public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull Player player, boolean giveReward) Increases the progression of the provided player's team by one. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
incrementProgression
in classAdvancement
- Parameters:
player
- The player who is responsible for the increment.giveReward
- Whether to give rewards if the advancement gets completed.- Returns:
- The new progression. It is always less or equal to
Advancement.maxProgression
. - Throws:
UnsupportedOperationException
- Always when it's called.
-
incrementProgression
public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull Player player, @Range(from=0, to=Integer.MAX_VALUE) int increment) Increases the progression of the provided player's team.If the advancement gets completed, advancement rewards will be given. Since
FakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
incrementProgression
in classAdvancement
- Parameters:
player
- The player who is responsible for the increment.increment
- The progression increment. Must be greater than0
.- Returns:
- The new progression. It is always less or equal to
Advancement.maxProgression
. - Throws:
UnsupportedOperationException
- Always when it's called.
-
incrementProgression
public @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull Player player, @Range(from=0, to=Integer.MAX_VALUE) int increment, boolean giveReward) Increases the progression of the provided player's team. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
incrementProgression
in classAdvancement
- Parameters:
player
- The player who is responsible for the increment.increment
- The progression increment. Must be greater than0
.giveReward
- Whether to give rewards if the advancement gets completed.- Returns:
- The new progression. It is always less or equal to
Advancement.maxProgression
. - Throws:
UnsupportedOperationException
- Always when it's called.
-
incrementProgression
protected @Range(from=0, to=Integer.MAX_VALUE) int incrementProgression(@NotNull @NotNull TeamProgression pro, @Nullable @Nullable Player player, @Range(from=0, to=Integer.MAX_VALUE) int increment, boolean giveRewards) Increases the progression of the provided team.The provided player must be an online member of the team. If no members are online or no particular player is to be preferred, it can be put to
null
. In this case, rewards will be given to a pseudorandom online member if there are any or the advancement will be set unredeemed. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
incrementProgression
in classAdvancement
- Parameters:
pro
- TheTeamProgression
of the team.player
- The team member responsible for the increment. May benull
.increment
- The progression increment. Must be greater than0
.giveRewards
- Whether to give rewards if the advancement gets completed.- Returns:
- The new progression. It is always less or equal to
Advancement.maxProgression
. - Throws:
UnsupportedOperationException
- Always when it's called.
-
setProgression
public void setProgression(@NotNull @NotNull UUID uuid, @Range(from=0, to=Integer.MAX_VALUE) int progression) Sets a progression for the provided player's team.If the advancement gets completed, advancement rewards will be given. Since
FakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
setProgression
in classAdvancement
- Parameters:
uuid
- TheUUID
of the player responsible for the update. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.progression
- The new non-negative progression to set.- Throws:
UnsupportedOperationException
- Always when it's called.
-
setProgression
public void setProgression(@NotNull @NotNull UUID uuid, @Range(from=0, to=Integer.MAX_VALUE) int progression, boolean giveReward) Sets a progression for the provided player's team. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
setProgression
in classAdvancement
- Parameters:
uuid
- TheUUID
of the player responsible for the update. If the player is not online, rewards will be given to a pseudorandom online member of the same team if there are any, or it will be set unredeemed.progression
- The new non-negative progression to set.giveReward
- Whether to give rewards if the advancement gets completed.- Throws:
UnsupportedOperationException
- Always when it's called.
-
setProgression
public void setProgression(@NotNull @NotNull Player player, @Range(from=0, to=Integer.MAX_VALUE) int progression) Sets a progression for the provided player's team.If the advancement gets completed, advancement rewards will be given. Since
FakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
setProgression
in classAdvancement
- Parameters:
player
- The player who is responsible for the update.progression
- The new non-negative progression to set.- Throws:
UnsupportedOperationException
- Always when it's called.
-
setProgression
public void setProgression(@NotNull @NotNull Player player, @Range(from=0, to=Integer.MAX_VALUE) int progression, boolean giveReward) Sets a progression for the provided player's team. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
setProgression
in classAdvancement
- Parameters:
player
- The player who is responsible for the update.progression
- The new non-negative progression to set.giveReward
- Whether to give rewards if the advancement gets completed.- Throws:
UnsupportedOperationException
- Always when it's called.
-
setProgression
protected void setProgression(@NotNull @NotNull TeamProgression pro, @Nullable @Nullable Player player, @Range(from=0, to=Integer.MAX_VALUE) int progression, boolean giveRewards) Sets a new progression for the provided team.The provided player must be an online member of the team. If no members are online or no particular player is to be preferred, it can be put to
null
. In this case, rewards will be given to a pseudorandom online member if there are any or the advancement will be set unredeemed. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
setProgression
in classAdvancement
- Parameters:
pro
- TheTeamProgression
that belongs to the team.player
- The team member responsible for the update. May benull
.progression
- The new non-negative progression to set.giveRewards
- Whether to give rewards if the advancement gets completed.- Throws:
UnsupportedOperationException
- Always when it's called.
-
handlePlayer
protected void handlePlayer(@NotNull @NotNull TeamProgression pro, @Nullable @Nullable Player player, int newProgression, int oldProgression, boolean giveRewards, @Nullable @Nullable AfterHandle afterHandle) Handles the reward process of the advancement.When the new progression is greater or equal than
Advancement.maxProgression
and the old progression is less thanAdvancement.maxProgression
then the advancement is being completed by the provided player. If the provided player is non-null, they will receive the rewards. Otherwise, if there are online members in the team one of them will receive the advancement rewards. If no member of the team are online, the advancement will be set unredeemed for that team. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
handlePlayer
in classAdvancement
- Parameters:
pro
- TheTeamProgression
of the team.player
- The team member responsible for the update. May benull
.newProgression
- The new non-negative progression that has been set.oldProgression
- The previous progression of the team.giveRewards
- Whether to give rewards if the advancement gets completed.afterHandle
- The action to perform after the reward process, ornull
to don't do any action. The default action updates the tab's advancement to the team (seeAfterHandle.UPDATE_ADVANCEMENTS_TO_TEAM
).- Throws:
UnsupportedOperationException
- Always when it's called.
-
displayToastToPlayer
Display the toast of this advancement to a player. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
displayToastToPlayer
in classAdvancement
- Parameters:
player
- The player the toast will be shown to.- Throws:
UnsupportedOperationException
- Always when it's called.
-
onGrant
Called when the advancement is completed by a player. It handles the chat message, the toast notification, and the advancement rewards (seeAdvancement.giveReward(Player)
for more information). SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
onGrant
in classAdvancement
- Parameters:
player
- The player who completed the advancement.giveRewards
- Whether to give rewards.- Throws:
UnsupportedOperationException
- Always when it's called.
-
giveReward
Gives the rewards to the provided player when the advancement is completed. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
giveReward
in classAdvancement
- Parameters:
player
- The player who has completed the advancement.- Throws:
UnsupportedOperationException
- Always when it's called.
-
grant
Grants the advancement to the player's team giving rewards. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
grant
in classAdvancement
- Parameters:
player
- The player.- Throws:
UnsupportedOperationException
- Always when it's called.
-
grant
Grant the advancement to the player's team. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
grant
in classAdvancement
- Parameters:
player
- The playergiveRewards
- Whether to give rewards.- Throws:
UnsupportedOperationException
- Always when it's called.
-
revoke
Revoke the advancement to the player's team. SinceFakeAdvancement
s are not saved, this method always throws anUnsupportedOperationException
.- Overrides:
revoke
in classAdvancement
- Parameters:
player
- The player.- Throws:
UnsupportedOperationException
- Always when it's called.
-