API Hook-up

Easy to understand and use

Ask for the API .jar file from here.

Registering the API in your project

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.challenges</groupId>
  <artifactId>api</artifactId>
  <version>1.0.0-BETA</version> 
  <scope>system</scope>
  <systemPath>${project.basedir}\libs\Challenges-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: ['Challenges-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

ChallengesAPI challengesAPI = Bukkit.getServicesManager().getRegistration(ChallengesAPI.class).getProvider();

Change challenge wins

UUID uuid = player.getUniqueId();
IUser user = challengesAPI.getUserUtil().getUser(uuid);
IChallenge challenge = challengesAPI.getChallengesUtil().getChallenge(@NotNull String id);
IChallengeUser challengeUser = challengesAPI.getChallengesUtil().getUserChallenge(user, challenge)

challengeUser.setChallengeWins(2);

Last updated

Was this helpful?