Get Started
Documentation
- 🖥️ Commands
- 🏙️ Towns
- 🏠 Claims
- 🔨 Roles
- 🌟 Advancements
- ☯️ Relations
- ⚔️ Wars
- 🚫 Inactive Town Pruning
Developers
- 📦 API v3
- 🧡 Towns API
- ⚙️ Claims API
- ❗ API Events
- 🕸️ API v1 (Legacy)
HuskTowns provides API for getting, creating, changing the type of, & deleting claims and admin claims.
This page assumes you have read the general API introduction and that you have both imported HuskTowns 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<TownClaim>
at the location
Optional<TownClaim>
, you can use Optional#isPresent()
to check if a claim exists at the locationTownClaim
object, you can get the associated Town
object (see Towns API) using #town()
, and the Claim
itself using #claim()
Claim
object has a range of properties describing the claim.void showTownWhoHasClaimedAt(org.bukkit.Location location) {
Position position = huskTowns.getPosition(location);
Optional<TownClaim> claim = huskTowns.getClaimAt(position);
if (claim.isPresent()) {
System.out.println("This location is claimed by " + claim.get().town().getName());
}
}
ClaimWorld
in HuskTowns. World
s without ClaimWorld
s are not protected by HuskTowns.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 = huskTowns.getClaimWorld(world);
if (claimWorld.isPresent()) {
System.out.println("This world is protected by HuskTowns, and contains " + claimWorld.get().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(OnlineUser user, OperationType type, Position position)
#isOperationAllowed
method that accepts and build an Operation
via Operation.builder()
for more complex operation checks!void checkUserAccessAt(org.bukkit.Player player, org.bukkit.Location location) {
OnlineUser user = huskTowns.getOnlineUser(player);
Position position = huskTowns.getPosition(location);
if (huskTowns.isOperationAllowed(user, OperationType.BREAK_BLOCKS, position)) {
System.out.println("User can build here!");
} else {
System.out.println("User can't build here!");
}
}
#createClaimAt(OnlineUser actor, Town town, Chunk chunk, World world)
#createAdminClaimAt(OnlineUser actor, Chunk chunk, World world)
#getClaimAt(Position position)
to get the TownClaim
object for the claim you just created (see #1)#createClaimAt(OnlineUser actor, Town town, Position position)
void createClaimAt(org.bukkit.Player player, org.bukkit.Chunk chunk, org.bukkit.World world) {
OnlineUser user = huskTowns.getOnlineUser(player);
Town town = huskTowns.getTown("townName").get();
huskTowns.createClaimAt(user, town, chunk, world);
}
#editClaimAt(Chunk chunk, World world, Consumer<TownClaim> editor)
Consumer<TownClaim>
to modify the TownClaim
object
townClaim.claim().setType(Claim.Type type)
to change the type of the claimvoid editClaimAt(org.bukkit.Chunk chunk, org.bukkit.World world) {
huskTowns.editClaimAt(chunk, world, townClaim -> {
townClaim.claim().setType(Claim.Type.FARM);
});
}
#deleteClaimAt(OnlineUser actor, Position position)
Chunk
and a World
is also availablevoid deleteClaimAt(org.bukkit.Player player, org.bukkit.Location location) {
OnlineUser user = huskTowns.getOnlineUser(player);
Position position = huskTowns.getPosition(location);
huskTowns.deleteClaimAt(user, position);
}
OnlineUser
(displaying the outline particle effect) using #highlightClaim(OnlineUser actor, TownClaim claim)
#highlightClaimAt
to attempt to highlight a claim at a specified Position
void highlightClaimAt(org.bukkit.Player player, org.bukkit.Location location) {
OnlineUser user = huskTowns.getOnlineUser(player);
Position position = huskTowns.getPosition(location);
Optional<TownClaim> claim = huskTowns.getClaimAt(position);
if (claim.isPresent()) {
huskTowns.highlightClaim(user, claim.get());
}
}