Working with claims

How to work with claims with SimpleClaimSystem API

Available methods :

Claim.java

Example of use :

/** 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.";
}

Last updated