Skip to content

Using The API

Picono435 edited this page Aug 16, 2020 · 5 revisions

Overview

This page covers how you can use the PicoJobs API, for create addons and a lot more.

Remember that all the softwares connected to PicoJobs should have the license GPL-3.0, as said here.

JavaDocs

The javadocs of the PicoJobs API can be found here

Examples

Here you can find some examples of the important things of the API.

Getting the managers

// Getting the Jobs Manager.
JobsManager jobsManager = PicoJobsAPI.getJobsManager();
// Getting the Players Manager.
PlayersManager playersManager = PicoJobsAPI.getPlayersManager();

Getting a job player

JobPlayer jp = playersManager.getJobPlayer(player);

Check if a player has a job

JobPlayer jp = playersManager.getJobPlayer(player);
if(jp.hasJob()) {
    // Player has job
} else {
    // Player doesn't have a job
}

Get player job

JobPlayer jp = playersManager.getJobPlayer(player);
Job job = jp.getJob();
if(job == null) {
    // Player does not have a job ;(
    return;
}
// Execute code with job

Get job by name

// Setting the variable of the job name
String jobname = "hunter";
// Getting the job by name
Job job = jobsManager.getJob(jobname);

Get & Compare the job type

# Getting the job type
job.getType();

# Comparing the job type
if(job.getType() == Type.BREAK) {
    // This is a job of the type break
} else {
    // This is not a job of the type break
}