BedWars Quests add-on
  • GET A COPY
    • Purchase Quests add-on
  • GENERAL
    • Home
  • Get Started
    • Migrating from v3
    • Installing add-on
      • 🛏️Bed Wars Core
      • 🔑License Key
      • 💾Database
      • 🪅Integrations
      • ⌨️Commands & Permissions
    • Quest & Challenge Types
    • Quest Flags
  • PlaceholderAPI
    • add-on Placeholders
  • DEVELOPER API
    • API Hook-up
    • Custom Events
Powered by GitBook
On this page
  • Registering the API in your project
  • Obtaining and using the API
  1. DEVELOPER API

API Hook-up

Easy to understand and use

Ask for 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

UUID uuid = player.getUniqueID();
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

UUID uuid = player.getUniqueID();
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

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

 questsAPI.getQuestUtil().startQuest(user, quest);
Previousadd-on PlaceholdersNextCustom Events

Last updated 4 months ago