Skip to content

Start Guide

fren_gor edited this page Mar 10, 2022 · 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/.

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.1.2</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.1.2'
}

Note: I don't use Gradle, if there are errors please open an issue or make a pull request.

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.

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