Skip to content

Start Guide

fren_gor edited this page Dec 13, 2024 · 63 revisions

Adding UltimateAdvancementAPI to your project

The API is published on maven.
Javadoc can be found at https://frengor.com/javadocs/UltimateAdvancementAPI/latest/.
Builds can be found on Jenkins: https://jenkins.frengor.com/job/UltimateAdvancementAPI/.

Warning

If you have JitPack declared in your repositories, make sure to declare the UltimateAdvancementAPI Maven repository before it! JitPack provides an empty jar instead of the correct one and this has already caused many issues in the past.

Maven

If you're using Maven, import UltimateAdvancementAPI adding these lines to your POM file.

<repositories>
    <repository>
        <id>fren_gor</id>
        <url>https://nexus.frengor.com/repository/public/</url>
    </repository>
</repositories>
<dependency>
    <groupId>com.frengor</groupId>
    <artifactId>ultimateadvancementapi</artifactId>
    <version>2.4.3</version>
    <scope>provided</scope>
</dependency>

Gradle

If you're using Gradle, import UltimateAdvancementAPI adding these lines to your build script.

repositories {
    maven { url 'https://nexus.frengor.com/repository/public/' }
}
dependencies {
    compileOnly 'com.frengor:ultimateadvancementapi:2.4.3'
}

Manually

Download the lastest API jar from the downlaod page or Jenkins and add it to the build path of your project.

Shadeable Version

Shadeable version installation process can be found at this page.


Getting an instance of the API

To get an instance of the API use the UltimateAdvancementAPI#getInstance(Plugin plugin) method:

UltimateAdvancementAPI api = UltimateAdvancementAPI.getInstance(yourPluginInstance);

If UltimateAdvancementAPI is not enabled it will throw a APINotInstantiatedException.

Important

Remember to add depend: [UltimateAdvancementAPI] or softdepend: [UltimateAdvancementAPI] to your plugin.yml.


Example Usage

Simple example with the creation of an advancement tab with only one advancement.

public class MainClass extends JavaPlugin implements Listener {

    private AdvancementTab advancementTab;
    private RootAdvancement root;
    private UltimateAdvancementAPI api;

    @Override
    public void onEnable() {
        api = UltimateAdvancementAPI.getInstance(this);

        advancementTab = api.createAdvancementTab("your_tab_name");

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

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

        advancementTab.registerAdvancements(root);

        Bukkit.getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onJoin(PlayerLoadingCompletedEvent e) {
        // Called after a player has successfully been loaded by the API
        Player p = e.getPlayer();
        // Here you can show tabs to players
        advancementTab.showTab(p);
    }
}

Result:
result