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.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

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

challengeUser.setChallengeWins(2);

Last updated