Skip to content

Developer API

fren_gor edited this page Apr 19, 2021 · 16 revisions

Welcome to the official UltimateScoreboards Developer API Wiki.

UltimateScoreboards comes with an extensive and easy API to create and manage scoreboards.

To see a complete usage guide check out the API Usage page.

The LATEST version of the API is the 1.0.

Javadocs: https://us-docs.frengor.com (alternative link)

Start guide


Adding UltimateScoreboards to your project

The API is published on jitpack.io.

Maven

If you're using Maven add these lines to your POM file.

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
</dependencies>
    <dependency>
        <groupId>com.frengor</groupId>
        <artifactId>UltimateScoreboardsAPI</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

Gradle

If you're using Gradle add these lines to your build script.

repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    compileOnly 'com.frengor:UltimateScoreboardsAPI:1.0'
}

Manually

Download the last API jar from releases. Add it to the build path of your project.


Getting an instance of the API

To get an instance of the API you need to use one of the next two method:

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

Services Manager

RegisteredServiceProvider<UltimateScoreboardsAPI> provider = Bukkit.getServicesManager().getRegistration(UltimateScoreboardsAPI.class);
if (provider != null) {
    UltimateScoreboardsAPI api = provider.getProvider();
}

Static Access

// Returns null if the API hasn't been loaded yet
UltimateScoreboardsAPI api = UltimateScoreboardsAPI.getAPI();

Example Usage

Create a line

// Get the API instance
UltimateScoreboardsAPI api = UltimateScoreboardsAPI.getAPI();
// Create a text line
TextLine line = api.craftTextLine("This is a line");

Create a scoreboard

// Get the API instance
UltimateScoreboardsAPI api = UltimateScoreboardsAPI.getAPI();
// Create title
Line title = api.craftTextLine("&eThis is the title");
// Create some lines
Line line1 = api.craftSlidingLine("Sliding!!!");
Line line2 = api.craftSlidingLine("Just another line", true);
// Create the scoreboard
Scoreboard scoreboard = api.craftLongScoreboard(title, Arrays.asList(line1, line2));
scoreboard.addViewer(aplayer);