Skip to content

Standard Advancement

Escanor Targaryen edited this page Aug 5, 2021 · 4 revisions

Advancement

Advancement is an abstract class, it can't be extended but is it is important to undestand how this API works.

Each advancement has a unique advancement key, consisting of "tab_name:id_advancement".

The visible part of the advancement is described in the AdvancementDisplay.

The maxCriteria indicates how many times an action or a quantity of something must be done. It is usually shown after the title of the andvancement, if visible. When this value is set to 1, nothing is shown.

maxCriteria at 1:

maxCriteria at 3:

The EventManagerAPI is used to manage events and to manage advancement progress.

Visibility

Each advancement can be shown or hidden to a player, this is decided in the isVisible () method. It can be overwritten and edited. Or you can create an interface that extends IVisibility to create your own visibility behavior. Some interfaces are available and can facilitate visibility management:

  • HiddenVisibility - the advancement is visible If the advancement progression is greater than 0 or has been completed.
  • ParentGrantedVisibility - the advancement is visible If the Parent or Parents of the advancement are shown.
  • VanillaVisibility - the advancement is visible if the parent or grandparent is visible. If nothing is extended or the method is not overridden, the advancement will always be visible.

Root Advancement

The rootadvancement is the main advancement, where all the others gradually connect. Tt is present only once for each tab Inside it there is the path for the backgound of the tab. For example to set the texture of the stone blocks: "textures/block/stone.png"

The texture may vary depending on the player's texture pack.

Example:

AdvancementDisplay rootDisplay = new AdvancementDisplay(Material.GRASS, "Example root", AdvancementFrameType.TASK, false, false, 0, 0, "description");

root = new RootAdvancement(advancementTab, "root", rootDisplay, "textures/block/stone.png");

Base Advancement

The base advancement defines a classic advancement with all its features.

Example:

public class Pickaxe extends BaseAdvancement implements ParentGrantedVisibility {
    public Pickaxe( @NotNull String key, @NotNull AdvancementDisplay display, @NotNull Advancement parent) {
        super(key, display, parent);

        registerEvent(CraftItemEvent.class, e -> {
            Player p = (Player) e.getWhoClicked();
            if (isVisible(p) && !isGranted(p) && e.getRecipe().getResult().getType() == Material.STONE_PICKAXE) {
                incrementTeamCriteria(p);
            }
        });

    }
}