Developer API
Adding the Dependency
The plugin is published on JitPack. Add the JitPack repository and the plugin as a dependency:
Gradle
repositories {
maven { url = 'https://jitpack.io' }
}
dependencies {
compileOnly 'com.github.Xyness:SimpleClaimSystem:1.11'
}
Maven
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.Xyness</groupId>
<artifactId>SimpleClaimSystem</artifactId>
<version>1.11</version>
</dependency>
And in your plugin.yml:
depend: [SimpleClaimSystem]
# or for an optional dependency:
soft-depend: [SimpleClaimSystem]Accessing the API
/** Instance of SimpleClaimSystem API */
private SimpleClaimSystemAPI scs;
// Access to the SimpleClaimSystem API
scs = SimpleClaimSystemAPI_Provider.getAPI();
The full method list lives in the SimpleClaimSystemAPI class on the plugin's GitHub repository.
Working with Players
Player data is exposed via CPlayer.java on the plugin's GitHub repository. Once you've obtained the API instance you can fetch a CPlayer from a Bukkit Player:
private SimpleClaimSystemAPI scs;
scs = SimpleClaimSystemAPI_Provider.getAPI();
// Returns the player's claims count, or 0 if the CPlayer is null
public int getPlayerClaimsCount(Player player) {
var target = scs.getCPlayer(player);
if (target == null) return 0;
return target.getClaimsCount();
}Working with Claims
The Claim class on the plugin's GitHub repository documents the available claim methods. A complete usage example:
/** Instance of SimpleClaimSystem API */
private SimpleClaimSystemAPI scs;
// Access to the SimpleClaimSystem API
scs = SimpleClaimSystemAPI_Provider.getAPI();
// Get the player (we suppose players are online)
Player player = Bukkit.getPlayer("Xyness");
Player targetPlayer = Bukkit.getPlayer("User1");
// Get the claim by its name
Claim claim = scs.getPlayerClaim(player, "claim-1");
if (claim != null) {
if (scs.addPlayerToClaim(claim, targetPlayer.getName())) {
String claimName = claim.getName();
String claimOwner = claim.getOwner();
String message = String.format(
"You have been added to the claim '%s' of %s.", claimName, claimOwner);
targetPlayer.sendMessage(message);
} else {
String message = "§cAn error has occurred, please contact an administrator.";
targetPlayer.sendMessage(message);
}
} else {
String message = String.format(
"The 'claim-1' claim of the player Xyness does not exist.");
}