API Hook-up

Easy to understand and use

Download the API .jar file from here.

Registering the API in your project

First you need to create a folder in the main path of your project and store the .jar file there.

Maven

Replace libs with the name of the directory where the .jar file is stored and replace API.jar with the name of the .jar file.

<dependency>
  <groupId>com.reussy.development.quests</groupId>
  <artifactId>api</artifactId>
  <version>4.0.0-BETA</version> 
  <scope>system</scope>
  <systemPath>${project.basedir}\libs\API.jar</systemPath>
</dependency>

Gradle

Replace libs with the name of the directory where the .jar file is stored and replace API.jar with the name of the .jar file.

implementation fileTree(include: ['API.jar'], dir: 'libs')

Obtaining and using the API

To obtain the API class we make use of the service provided by Bukkit to register a class and retrieve it using #getRegistration method.

Retrieving the service

QuestsAPI questsAPI = Bukkit.getServicesManager().getRegistration(QuestsAPI.class).getProvider();

Manipulating a registered user in the cache

final UUID uuid = UUID.randomUUID(); // Obviously, it uses a player's UUID.
final IUser user = questsAPI.getUserUtil().getUser(uuid);
        
user.setRemainingChallenges(5);
user.getPlayer().sendMessage("The remaining challenges has been set to 5.");

Manipulating the progress of a quest or challenge

final UUID uuid = UUID.randomUUID();
final IUser user = questsAPI.getUserUtil().getUser(uuid);

user.getUserQuestsProgress("first_win").setProgress(10); // Set the progress to 10.
user.getUserQuestsProgress("first_win").setStatus(QuestStatus.COMPLETED); // Set the status to completed.
user.getPlayer().sendMessage("§aQuests §8» §7Quest §aFirst Win §7completed!");

Start a quest for a user

final UUID uuid = UUID.randomUUID();
final IUser user = questsAPI.getUserUtil().getUser(uuid);
final IQuest quest = questsAPI.getQuestUtil().getQuest("first_win");

 questsAPI.getQuestUtil().startQuest(user, quest);

Last updated