Get Started
- 📚 Setup
- ➡️ Importers
- 📄 Config
- 📝 Translations
- 🔌 Hooks
Documentation
- 🖥️ Commands
- ⛔ Permissions
- 🥄 Claims
- ❤️ Trust
- 🎛️ Operation Groups
- 🪧 Sign Moderation
- 🪦 Drops Moderation
- 😴 Inactivity Pruning
- 🐕 Pets
HuskClaims provides API for getting, creating resizing, & deleting claims, child claims, and admin claims, and managing claim blocks.
This page assumes you have read the general API introduction and that you have both imported HuskClaims into your project and added it as a dependency.
Position
object using #getPosition(org.bukkit.Location location)
#isClaimAt(Position position)
to check if the location has been claimed#getClaimAt(Position position)
to get the Optional<Claim>
at the location
Optional<Claim>
, you can use Optional#isPresent()
to check if a claim exists at the locationClaim
object, you can also check if it's an admin claim (#isAdminClaim()
) or a child claim (#isChildClaim(ClaimWorld)
) — more on claim worlds in a bit!#getClaimOwnerNameAt(Position position)
, returning an Optional<String>
an administrator
(or whatever you have set in the locales)void showClaimerNameAt(org.bukkit.Location location) {
Position position = huskClaims.getPosition(location);
Optional<Claim> claim = huskClaims.getClaimAt(position);
if (claim.isPresent()) {
System.out.println("This location is claimed by " + huskClaims.getClaimOwnerNameAt(position).get());
}
}
ClaimWorld
in HuskClaims. World
s without ClaimWorld
s are not protected by HuskClaims.World
object from a Bukkit World using #getWorld(org.bukkit.World)
(or call #getWorld()
on a Position
object)ClaimWorld
for a world using #getClaimWorld(World world)
which will return an Optional<ClaimWorld>
void showClaimWorld(org.bukkit.World world) {
Optional<ClaimWorld> claimWorld = huskClaims.getClaimWorld(world);
if (claimWorld.isPresent()) {
System.out.println("This world is protected by HuskClaims, and contains " + claimWorld().getClaimCount() + " claims!");
}
}
OnlineUser
object using #getOnlineUser(@NotNull org.bukkit.Player player)
#getPosition()
to get the Position
of an OnlineUser
to check if there's a claim where they stand (see #1)OperationTypes
using isOperationAllowed(user, type, position)
#isOperationAllowed
method that accepts and build an Operation
via Operation.of()
for more complex operation checksTrustLevel.Privileges
at a location using #isPrivilegeAllowed(TrustLevel.Privilege privilege, User user, Position position)
#getTrustLevelAt(Position position, Trustable user)
(User
and OnlineUser
implement Trustable
!)
Optional<TrustLevel>
, which you can check if it is present using Optional#isPresent()
, or through the #ifPresent((trustLevel) -> {})
lambda syntax.void checkUserAccessAt(org.bukkit.Player player, org.bukkit.Location location) {
OnlineUser user = huskClaims.getOnlineUser(player);
Position position = huskClaims.getPosition(location);
if (huskClaims.isOperationAllowed(user, OperationType.BREAK_BLOCKS, position)) {
System.out.println("User can build here!");
}
if (huskClaims.isOperationAllowed(Operation.of(user, OperationType.PLACE_BLOCKS, position, true))) {
System.out.println("'true' sets this operation to be done silently.");
}
if (huskClaims.isPrivilegeAllowed(TrustLevel.Privilege.MANAGE_CHILD_CLAIMS, user, position)) {
System.out.println("User can manage child claims here!");
}
huskClaims.getTrustLevelAt(position, user).ifPresent((level) -> {
System.out.println("User has " + level.name() + " trust here!"); // "User has Build Trust here!"
});
}
Region.from(BlockPosition pos1, BlockPosition pos2)
Position
extends BlockPosition
, so you can use Position
objects for thisBlockPosition
using #getBlockPosition(x, z)
Region.from(BlockPosition center, int radius)
#isRegionClaimed(World world, Region region)
or #isRegionClaimed(ClaimWorld world, Region region)
#createAdminClaim(ClaimWorld world, Region region)
CompletableFuture<Claim>
, which you can use to get the created claim when it has been created asynchronously#createClaim(ClaimWorld world, Region region, User user)
— note that the user needs claim blocks for this (more on how to check/update this below)void createAdminClaimAround(org.bukkit.Player player, org.bukkit.Location location) {
OnlineUser user = huskClaims.getOnlineUser(player);
Position position = huskClaims.getPosition(location);
Region region = Region.from(position, 100); // Create a 100-block radius region around the player
if (!huskClaims.isRegionClaimed(position.getWorld(), region)) {
huskClaims.createAdminClaim(position.getWorld(), region).thenAccept((claim) -> {
// This future will complete when the claim has been created
System.out.println("Created admin claim at " + claim.getCenter().toString());
}).exceptionally((e) -> {
// This future can also complete exceptionally if the claim could not be created
System.out.println("Failed to create admin claim: " + e.getMessage());
return null;
});
} else {
System.out.println("This region is already claimed!");
}
}
#resizeClaim(Claim claim, Region region)
, or #resizeChildClaim(Claim claim, Region region)
for child claims
CompletableFuture<Claim>
, which you can use to get the resized claim when it has been resized asynchronously#deleteClaim(Claim claim)
, or #deleteChildClaim(Claim claim)
for child claimsvoid resizeClaim(org.bukkit.Player player, org.bukkit.Location location) {
OnlineUser user = huskClaims.getOnlineUser(player);
Position position = huskClaims.getPosition(location);
Optional<Claim> claim = huskClaims.getClaimAt(position);
if (claim.isPresent()) {
Region region = Region.from(position, 100); // Create a 100-block radius region around the player
if (huskClaims.isRegionClaimed(position.getWorld(), region)) {
System.out.println("This region is already claimed!");
return;
}
huskClaims.resizeClaim(claim.get(), region).thenAccept((resizedClaim) -> {
// This future will complete when the claim has been resized
System.out.println("Resized claim at " + resizedClaim.getCenter().toString());
}).exceptionally((e) -> {
// This future can also complete exceptionally if the claim could not be resized
System.out.println("Failed to resize claim: " + e.getMessage());
return null;
});
} else {
System.out.println("This region is not claimed!");
}
}
OnlineUser
's claim block balance using #getClaimBlocks(OnlineUser user)
#getClaimBlocks(User user)
or #getClaimBlocks(UUID uuid)
methods which will return a CompletableFuture<Long>
with their claim block count.#hasClaimBlocks(OnlineUser user, long amount)
#giveClaimBlocks
, #takeClaimBlocks
and #setClaimBlocks
methods which accept a User
and a long
amountClaimBlocksChangeEvent
, which you can listen to for when a user's claim block balance changes#takeClaimBlocks
will throw an IllegalArgumentException
if you attempt to take more claim blocks than the user hasvoid giveClaimBlocks(org.bukkit.Player player, long amount) {
OnlineUser user = huskClaims.getOnlineUser(player);
if (huskClaims.hasClaimBlocks(user, amount)) {
huskClaims.takeClaimBlocks(user, amount); // This will empty the user's claim block balance
System.out.println("Took " + amount + " claim blocks from " + player.getName());
} else {
System.out.println(player.getName() + " does not have enough claim blocks!");
}
}