Class AdvancementAPI
java.lang.Object
io.github.lambdaphoenix.advancementLib.AdvancementAPI
API for registering and tracking custom or vanilla advancements in your plugin.
Use this API to define custom triggers and conditions for granting advancements to players. All registration must go through the builder pattern.
Example usage:
AdvancementAPI api = new AdvancementAPI(plugin);
api.register(PlayerInteractEvent.class)
.advancementKey("minecraft:adventure/trade")
.condition((player, event) -> event.getAction() == Action.RIGHT_CLICK_BLOCK)
.targetValue(5)
.playerExtractor(event -> event.getPlayer())
.build();
- Since:
- 0.1.0
- Version:
- 0.3.2
- Author:
- lambdaphoenix
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAdvancementAPI
(org.bukkit.plugin.Plugin plugin) Creates a new AdvancementAPI instance for your plugin. -
Method Summary
Modifier and TypeMethodDescriptionint
getProgress
(String advancementKey, org.bukkit.entity.Player player) Gets the current progress towards an advancement for a specific player.<E extends org.bukkit.event.Event>
AdvancementRegisterBuilder<E> Starts a newAdvancementRegisterBuilder
for the given event type.void
resetAdvancement
(String advancementKey, org.bukkit.entity.Player player) Resets the player's advancement including all criteria.void
resetProgress
(String advancementKey, org.bukkit.entity.Player player) Resets the current progress for the specified advancement to the player.
-
Constructor Details
-
AdvancementAPI
public AdvancementAPI(org.bukkit.plugin.Plugin plugin) Creates a new AdvancementAPI instance for your plugin.- Parameters:
plugin
- your plugin instance (notnull
)- Throws:
NullPointerException
- if plugin isnull
- Since:
- 0.1.0
- See Also:
-
-
Method Details
-
register
public <E extends org.bukkit.event.Event> AdvancementRegisterBuilder<E> register(Class<E> eventType) Starts a newAdvancementRegisterBuilder
for the given event type.This is the only supported way to register advancements.
- Type Parameters:
E
- the event type- Parameters:
eventType
- the Bukkit event class to listen for- Returns:
- a new builder instance
- Since:
- 0.2.0
- See Also:
-
getProgress
Gets the current progress towards an advancement for a specific player.- Parameters:
advancementKey
- the namespaced key of the advancementplayer
- the player to check progress for- Returns:
- the number of times the condition has been met
- Since:
- 0.1.0
-
resetProgress
Resets the current progress for the specified advancement to the player.- Parameters:
advancementKey
- the namespaced key of the advancementplayer
- the player who should have their progress reset- Since:
- 0.3.1
- See Also:
-
resetAdvancement
Resets the player's advancement including all criteria.- Parameters:
advancementKey
- the namespaced key of the advancementplayer
- the player who should have their advancement reset- Since:
- 0.3.1
- See Also:
-