Developer API
Developer API
ChunkClaim exposes a public Java API so other plugins can query claim ownership and permissions.
Getting the API Instance
import org.bukkit.Bukkit;
ChunkClaimApi api = Bukkit.getServicesManager()
.getRegistration(ChunkClaimApi.class)
.getProvider();
Warning: Always null-check the registration. ChunkClaim might not be installed on all servers.
var reg = Bukkit.getServicesManager().getRegistration(ChunkClaimApi.class);
if (reg == null) {
// ChunkClaim not installed — handle gracefully
return;
}
ChunkClaimApi api = reg.getProvider();
API Methods
Checking Claim Status
// Is this chunk claimed by anyone?
boolean claimed = api.isClaimed(chunk);
// Who owns this chunk? (empty if wilderness)
Optional<UUID> owner = api.getOwner(chunk);
owner.ifPresent(uuid -> {
String name = Bukkit.getOfflinePlayer(uuid).getName();
player.sendMessage("This chunk belongs to: " + name);
});
Checking Player Permissions
// Can this player place/break blocks here?
boolean canBuild = api.canBuild(player, block);
// Can this player use buttons/doors/levers?
boolean canInteract = api.canInteract(player, block);
// Can this player open chests/barrels/furnaces?
boolean canOpenContainer = api.canOpenContainer(player, block);
Example: Custom Protection Listener
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
if (!api.canBuild(player, block)) {
event.setCancelled(true);
player.sendMessage("§cYou don't have permission to build here!");
}
}
Soft-Dependency Setup (plugin.yml)
name: MyPlugin
version: 1.0.0
depend: []
softdepend:
- ChunkClaim
Using softdepend means your plugin loads after ChunkClaim if it's present, but still loads without it.