Interface ClaimManager
ClaimManager provides methods to interact with land claims,
protections, and whitelists within the BuildMC plugin.
It allows checking claim ownership, player permissions, protections, and managing claims through players or teams.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddPlayerToWhitelist(long claimID, UUID playerID) Adds a player to a claim's whitelist.voidaddProtection(long claimId, @NotNull Protection protection) Adds a protection to a claim by ID.voidaddProtection(long claimId, @NotNull org.bukkit.NamespacedKey protection) Adds a protection to a claim by ID.voidaddProtection(@NotNull Claim claim, @NotNull Protection protection) Adds a protection to a claim by ID.voidaddProtection(@NotNull Claim claim, @NotNull org.bukkit.NamespacedKey protection) Adds a protection to a claim by ID.voiddeleteClaims(Collection<Claim> claims) Deletes multipleClaimobjects from the system and removes them from the database.booleandoesOwnerHaveClaimWithName(String ownerId, String claimName) Checks whether the owner already has a claim with the given name.com.google.common.collect.ImmutableSet<Claim> Retrieves allClaimentries stored in the database.@Nullable ClaimgetClaim(@NotNull org.bukkit.Location location) Gets the claim at a given location.@Nullable ClaimgetClaimByID(long claimID) Gets a claim by its ID.@Nullable LonggetClaimId(@NotNull org.bukkit.Location loc) Gets the claim ID of a claimedLocation.@Nullable StringgetClaimNameById(long claimId) Gets the name of a claim by its ID.com.google.common.collect.ImmutableSet<Claim> getClaimsInArea(org.bukkit.Location pos1, org.bukkit.Location pos2) Gets all claims within the given area.@NotNull StringgetOwnerName(@NotNull Claim claim) Gets the name of the owner of the given claim.@Nullable org.bukkit.scoreboard.TeamgetPlayerTeam(@NotNull org.bukkit.entity.Player player) Gets the current scoreboardTeamof a player.@Nullable IntegergetRemainingPlayerClaims(String playerUUID) Gets how many claimable chunks a player has left.@Nullable IntegergetRemainingPlayerClaims(UUID playerUUID) Gets how many claimable chunks a player has left.@Nullable IntegergetRemainingTeamClaims(String teamName) Gets how many claimable chunks a team has left.booleanhasAllProtectionKeys(Claim claim, Collection<org.bukkit.NamespacedKey> keys) Checks if a claim has all the specified protections by key.booleanhasAllProtections(Claim claim, Collection<String> protections) Checks if a claim has all the specified protections by string identifiers.booleanhasAnyProtection(Claim claim, Collection<org.bukkit.NamespacedKey> protections) Checks if a claim has any of the provided protections.booleanhasProtection(Claim claim, org.bukkit.NamespacedKey protection) Checks if a claim has a specific protection.booleanisClaimed(@NotNull org.bukkit.Location loc) Checks if aLocationis claimed.booleanisClaimInArea(UUID worldID, int chunkX1, int chunkZ1, int chunkX2, int chunkZ2) Checks if there is any claim within the given chunk area.booleanisPlayerAllowed(@NotNull org.bukkit.entity.Player player, @NotNull Collection<org.bukkit.NamespacedKey> protections, @Nullable Claim claim) Checks whether a player is allowed to perform an action in a claim given multiple protection keys.booleanisPlayerAllowed(@NotNull org.bukkit.entity.Player player, @NotNull Collection<org.bukkit.NamespacedKey> protections, org.bukkit.Location location) Checks whether a player is allowed to perform an action at a specific location given multiple protection keys.booleanisPlayerAllowed(@NotNull org.bukkit.entity.Player player, @NotNull org.bukkit.NamespacedKey protection, @Nullable Claim claim) Checks whether a player is allowed to perform an action in a given claim for a single protection key.booleanisPlayerAllowed(@NotNull org.bukkit.entity.Player player, @NotNull org.bukkit.NamespacedKey protection, org.bukkit.Location location) Checks whether a player is allowed to perform an action at a location for a single protection key.booleanisPlayerAllowedInClaim(@Nullable Claim claim, @NotNull org.bukkit.entity.Player player) Checks whether a player is allowed to be inside the given claim.booleanisWorldAllowed(@NotNull org.bukkit.World world) Checks whether a player is allowed to create a claim in a specific world.registerClaims(List<Claim> claims) Registers multipleClaimobjects in the system and persists them to the database.booleanremoveClaimById(long claimId) Removes a claim by its ID.voidremovePlayerFromWhitelist(long claimID, UUID playerID) Removes a player from a claim's whitelist.voidremoveProtection(long claimId, @NotNull Protection protection) Removes a protection from a claim by ID.voidremoveProtection(long claimId, @NotNull org.bukkit.NamespacedKey protection) Removes a protection from a claim by ID.voidremoveProtection(@NotNull Claim claim, @NotNull Protection protection) Removes a protection from a claim by ID.voidremoveProtection(@NotNull Claim claim, @NotNull org.bukkit.NamespacedKey protection) Removes a protection from a claim by ID.voidsetRemainingPlayerClaims(String playerUUID, @Nullable Integer remainingClaims) Sets the number of claimable chunks a player has left.voidsetRemainingPlayerClaims(UUID playerUUID, @Nullable Integer remainingClaims) Sets the number of claimable chunks a player has left.voidsetRemainingTeamClaims(String teamName, @Nullable Integer remainingClaims) Sets the number of claimable chunks a team has left.@Nullable LongtryClaimArea(@NotNull Claim claim) Attempts to register aClaiminstance.@Nullable LongtryClaimArea(@NotNull ClaimType type, @NotNull String claimOwner, @NotNull String claimName, org.bukkit.Location pos1, org.bukkit.Location pos2) Attempts to create a claim of someClaimTypebetween two positions.@Nullable LongtryClaimPlaceholderArea(@NotNull String claimName, org.bukkit.Location pos1, org.bukkit.Location pos2) Attempts to create a placeholder claim between two positions.@Nullable LongtryClaimPlayerArea(@NotNull org.bukkit.entity.Player player, @NotNull String claimName, org.bukkit.Location pos1, org.bukkit.Location pos2) Attempts to create a claim for a player between two positions.@Nullable LongtryClaimServerArea(@NotNull String claimName, org.bukkit.Location pos1, org.bukkit.Location pos2) Attempts to create a claim owned by the server between two positions.@Nullable LongtryClaimTeamArea(@NotNull org.bukkit.scoreboard.Team team, @NotNull String claimName, org.bukkit.Location pos1, org.bukkit.Location pos2) Attempts to create a claim for aTeambetween two positions.voidupdateClaimName(long claimId, @NotNull String newName) Update the name of a ClaimvoidupdateClaimName(@NotNull Claim claim, @NotNull String newName) Update the name of a ClaimvoidupdateClaimOwner(long claimId, @NotNull String newOwnerId) Update the owner of a ClaimvoidupdateClaimOwner(@NotNull Claim claim, @NotNull String newOwnerId) Update the owner of a Claim
-
Method Details
-
getPlayerTeam
@Nullable @Nullable org.bukkit.scoreboard.Team getPlayerTeam(@NotNull @NotNull org.bukkit.entity.Player player) Gets the current scoreboardTeamof a player.- Parameters:
player- the player- Returns:
- the
Teamthe player is in, ornullif none
-
getOwnerName
-
isWorldAllowed
@Contract(pure=true) boolean isWorldAllowed(@NotNull @NotNull org.bukkit.World world) Checks whether a player is allowed to create a claim in a specific world.Players can bypass this by using the 'buildmc.bypass-claim-dimension-list' permission.
- Parameters:
world- TheWorldto check- Returns:
trueif, claims can be created by anyone in the given world.
-
isPlayerAllowedInClaim
@Contract(pure=true) boolean isPlayerAllowedInClaim(@Nullable @Nullable Claim claim, @NotNull @NotNull org.bukkit.entity.Player player) Checks whether a player is allowed to be inside the given claim. If the player is not the owner, not whitelisted or doesn't bypass protections, he won't be allowed.This will only check on
ClaimType.PLAYERorClaimType.SERVER.- Parameters:
claim- theClaimto checkplayer- the player- Returns:
trueif the player is allowed, otherwisefalse
-
isPlayerAllowed
boolean isPlayerAllowed(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull Collection<org.bukkit.NamespacedKey> protections, org.bukkit.Location location) Checks whether a player is allowed to perform an action at a specific location given multiple protection keys. If all provided protections are false, the player is allowed.- Parameters:
player- the playerprotections- the protections to checklocation- the location- Returns:
trueif the player is allowed, otherwisefalse
-
isPlayerAllowed
@Contract(pure=true) boolean isPlayerAllowed(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull Collection<org.bukkit.NamespacedKey> protections, @Nullable @Nullable Claim claim) Checks whether a player is allowed to perform an action in a claim given multiple protection keys. If all provided protections are false, the player is allowed.- Parameters:
player- the playerprotections- the protections to checkclaim- the claim, ornullif outside a claim- Returns:
trueif the player is allowed, otherwisefalse
-
isPlayerAllowed
@Contract(pure=true) boolean isPlayerAllowed(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.NamespacedKey protection, @Nullable @Nullable Claim claim) Checks whether a player is allowed to perform an action in a given claim for a single protection key.- Parameters:
player- the playerprotection- the protection to checkclaim- the claim, ornullif outside a claim- Returns:
trueif the player is allowed, otherwisefalse
-
isPlayerAllowed
@Contract(pure=true) boolean isPlayerAllowed(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.NamespacedKey protection, org.bukkit.Location location) Checks whether a player is allowed to perform an action at a location for a single protection key.- Parameters:
player- the playerprotection- the protection to checklocation- the location- Returns:
trueif the player is allowed, otherwisefalse
-
hasAnyProtection
@Contract(pure=true) boolean hasAnyProtection(Claim claim, Collection<org.bukkit.NamespacedKey> protections) Checks if a claim has any of the provided protections.- Parameters:
claim- the claimprotections- the protections (protections) to check- Returns:
trueif the claim has any of the protections
-
hasProtection
Checks if a claim has a specific protection.- Parameters:
claim- the claimprotection- the protection to check- Returns:
trueif the claim has the protection
-
hasAllProtections
Checks if a claim has all the specified protections by string identifiers.- Parameters:
claim- the claimprotections- the protections to check- Returns:
trueif the claim has all the protections
-
hasAllProtectionKeys
@Contract(pure=true) boolean hasAllProtectionKeys(Claim claim, Collection<org.bukkit.NamespacedKey> keys) Checks if a claim has all the specified protections by key.- Parameters:
claim- the claimkeys- the protection keys to check- Returns:
trueif the claim has all the protections
-
isClaimInArea
@Contract(pure=true) boolean isClaimInArea(UUID worldID, int chunkX1, int chunkZ1, int chunkX2, int chunkZ2) throws SQLException Checks if there is any claim within the given chunk area.- Parameters:
worldID- the world UUIDchunkX1- first corner chunk XchunkZ1- first corner chunk ZchunkX2- opposite corner chunk XchunkZ2- opposite corner chunk Z- Returns:
trueif a claim exists in the area- Throws:
SQLException- if a database error occurs
-
getClaimsInArea
@Contract(value="null, _ -> fail; _, null -> fail", pure=true) com.google.common.collect.ImmutableSet<Claim> getClaimsInArea(org.bukkit.Location pos1, org.bukkit.Location pos2) throws SQLException, IllegalArgumentException Gets all claims within the given area.- Parameters:
pos1- first corner locationpos2- opposite corner location- Returns:
- immutable set of claims in the area
- Throws:
SQLException- if a database error occursIllegalArgumentException- if any of theLocations are null, or they're not in the same world.
-
isClaimed
@Contract(pure=true) boolean isClaimed(@NotNull @NotNull org.bukkit.Location loc) Checks if aLocationis claimed.- Parameters:
loc- a location- Returns:
trueif the chunk is claimed
-
getClaimId
Gets the claim ID of a claimedLocation.- Parameters:
loc- a location- Returns:
- the claim ID, or
nullif unclaimed
-
getClaimByID
Gets a claim by its ID.- Parameters:
claimID- the claim ID- Returns:
- the claim, or
nullif none exists
-
getClaim
Gets the claim at a given location.- Parameters:
location- a location- Returns:
- the claim, or
nullif unclaimed
-
getAllClaims
@Contract(pure=true) com.google.common.collect.ImmutableSet<Claim> getAllClaims() throws SQLExceptionRetrieves allClaimentries stored in the database.Note: This method may be resource-intensive if a large number of claims exist. Consider using it primarily during startup, data synchronization, or administrative tasks.
- Returns:
- An immutable set containing all
Claimobjects found in the database. - Throws:
SQLException- if a database access error occurs while retrieving claims.
-
tryClaimArea
@Contract("_, _, _, null, _ -> fail; _, _, _, _, null -> fail") @Nullable @Nullable Long tryClaimArea(@NotNull @NotNull ClaimType type, @NotNull @NotNull String claimOwner, @NotNull @NotNull String claimName, org.bukkit.Location pos1, org.bukkit.Location pos2) throws IllegalArgumentException Attempts to create a claim of someClaimTypebetween two positions.- Parameters:
type- theClaimTypeof the claimclaimOwner- the id of the claim owner."Server" for
ClaimType.SERVERorClaimType.PLACEHOLDER.The team id for
ClaimType.TEAM, or the playerUUIDforClaimType.PLAYER.claimName- the claim namepos1- first corner locationpos2- opposite corner location- Returns:
- The ID of the claim. Or
nullif the claim was not created successfully - Throws:
IllegalArgumentException- if any of theLocations are null, or they're not in the same world.
-
tryClaimArea
-
tryClaimPlayerArea
@Contract("_, _, null, _ -> fail; _, _, _, null -> fail") @Nullable @Nullable Long tryClaimPlayerArea(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String claimName, org.bukkit.Location pos1, org.bukkit.Location pos2) throws IllegalArgumentException Attempts to create a claim for a player between two positions.- Parameters:
player- the playerclaimName- the claim namepos1- first corner locationpos2- opposite corner location- Returns:
- The ID of the claim. Or
nullif the claim was not created successfully - Throws:
IllegalArgumentException- if any of theLocations are null, or they're not in the same world.
-
tryClaimTeamArea
@Contract("_, _, null, _ -> fail; _, _, _, null -> fail") @Nullable @Nullable Long tryClaimTeamArea(@NotNull @NotNull org.bukkit.scoreboard.Team team, @NotNull @NotNull String claimName, org.bukkit.Location pos1, org.bukkit.Location pos2) throws IllegalArgumentException Attempts to create a claim for aTeambetween two positions.- Parameters:
team- the teamclaimName- the claim namepos1- first corner locationpos2- opposite corner location- Returns:
- The ID of the claim. Or
nullif the claim was not created successfully - Throws:
IllegalArgumentException- if any of theLocations are null, or they're not in the same world.
-
tryClaimServerArea
@Contract("_, null, _ -> fail; _, _, null -> fail") @Nullable @Nullable Long tryClaimServerArea(@NotNull @NotNull String claimName, org.bukkit.Location pos1, org.bukkit.Location pos2) throws IllegalArgumentException Attempts to create a claim owned by the server between two positions.- Parameters:
claimName- the claim namepos1- first corner locationpos2- opposite corner location- Returns:
- The ID of the claim. Or
nullif the claim was not created successfully - Throws:
IllegalArgumentException- if any of theLocations are null, or they're not in the same world
-
tryClaimPlaceholderArea
@Contract("_, null, _ -> fail; _, _, null -> fail") @Nullable @Nullable Long tryClaimPlaceholderArea(@NotNull @NotNull String claimName, org.bukkit.Location pos1, org.bukkit.Location pos2) throws IllegalArgumentException Attempts to create a placeholder claim between two positions.A
ClaimType.PLACEHOLDERclaim may be used to reserve an area temporarily without assigning it to a player, team, or the server.- Parameters:
claimName- the claim namepos1- first corner locationpos2- opposite corner location- Returns:
- The ID of the claim. Or
nullif the claim was not created successfully - Throws:
IllegalArgumentException- if any of theLocations are null, or they're not in the same world
-
registerClaims
Registers multipleClaimobjects in the system and persists them to the database.This method will first fire a
ClaimCreateEventcontaining all provided claims. If the event is cancelled by any listener, the registration process is aborted andnullis returned.If not cancelled, all claims are inserted into the database in a batch operation. The returned map links each
Claimto its newly assigned database ID.Important: You are responsible for supplying fully initialized
Claiminstances. This method only handles persistence and cache registration; it does not validate claim boundaries, ownership rules, or overlap constraints.- Parameters:
claims- the list of claims to register- Returns:
- a map of each claim to its generated database ID, or
nullif the creation event was cancelled - Throws:
SQLException- if a database access error occurs during insertion
-
deleteClaims
Deletes multipleClaimobjects from the system and removes them from the database.If the provided collection is
nullor empty, the method returns immediately without performing any action.A
ClaimRemoveEventis fired before deletion, allowing listeners to react to or track the removal. This event is informational and does not prevent deletion.Each claim must already have a valid database ID. If any claim has a
nullID, anIllegalArgumentExceptionis thrown and no database operation is performed.Important: You are responsible for ensuring the claims are valid and should be removed. This method only handles persistence and cache removal.
- Parameters:
claims- the collection of claims to delete- Throws:
SQLException- if a database access error occurs during deletionIllegalArgumentException- if any claim does not have a valid ID
-
addPlayerToWhitelist
Adds a player to a claim's whitelist.- Parameters:
claimID- the claim IDplayerID- the player UUID
-
removePlayerFromWhitelist
Removes a player from a claim's whitelist.- Parameters:
claimID- the claim IDplayerID- the player UUID
-
addProtection
void addProtection(@NotNull @NotNull Claim claim, @NotNull @NotNull org.bukkit.NamespacedKey protection) Adds a protection to a claim by ID.- Parameters:
claim- the claimprotection- the protection key
-
addProtection
Adds a protection to a claim by ID.- Parameters:
claim- the claimprotection- the protection
-
addProtection
Adds a protection to a claim by ID.- Parameters:
claimId- the claim IDprotection- the protection
-
addProtection
void addProtection(long claimId, @NotNull @NotNull org.bukkit.NamespacedKey protection) Adds a protection to a claim by ID.- Parameters:
claimId- the claim IDprotection- the protection key
-
removeProtection
void removeProtection(@NotNull @NotNull Claim claim, @NotNull @NotNull org.bukkit.NamespacedKey protection) Removes a protection from a claim by ID.- Parameters:
claim- the claimprotection- the protection key
-
removeProtection
Removes a protection from a claim by ID.- Parameters:
claim- the claimprotection- the protection
-
removeProtection
Removes a protection from a claim by ID.- Parameters:
claimId- the claim IDprotection- the protection
-
removeProtection
void removeProtection(long claimId, @NotNull @NotNull org.bukkit.NamespacedKey protection) Removes a protection from a claim by ID.- Parameters:
claimId- the claim IDprotection- the protection key
-
getClaimNameById
Gets the name of a claim by its ID.- Parameters:
claimId- the claim ID- Returns:
- the claim name
-
removeClaimById
boolean removeClaimById(long claimId) Removes a claim by its ID.- Parameters:
claimId- the claim ID- Returns:
trueif the claim was removed successfully
-
doesOwnerHaveClaimWithName
@Contract(pure=true) boolean doesOwnerHaveClaimWithName(String ownerId, String claimName) throws SQLException Checks whether the owner already has a claim with the given name.- Parameters:
ownerId- the owner identifierclaimName- the claim name- Returns:
trueif the owner already has a claim with that name- Throws:
SQLException- if a database error occurs
-
getRemainingTeamClaims
-
getRemainingPlayerClaims
-
getRemainingPlayerClaims
-
setRemainingTeamClaims
Sets the number of claimable chunks a team has left.If
remainingClaimsisnull, the team's remaining claim record is removed.- Parameters:
teamName- the team nameremainingClaims- the new number of remaining claims, ornullto remove the record
-
setRemainingPlayerClaims
Sets the number of claimable chunks a player has left.If
remainingClaimsisnull, the player's remaining claim record is removed.- Parameters:
playerUUID- the player's UUID as a stringremainingClaims- the new number of remaining claims, ornullto remove the record
-
setRemainingPlayerClaims
Sets the number of claimable chunks a player has left.If
remainingClaimsisnull, the player's remaining claim record is removed.- Parameters:
playerUUID- the player's UUIDremainingClaims- the new number of remaining claims, ornullto remove the record
-
updateClaimName
void updateClaimName(@NotNull @NotNull Claim claim, @NotNull @NotNull String newName) throws SQLException, IllegalArgumentException Update the name of a Claim- Parameters:
claim- the claimnewName- the new claim name- Throws:
SQLException- if a database error occursIllegalArgumentException- if the claim has no ID
-
updateClaimName
Update the name of a Claim- Parameters:
claimId- the claim IDnewName- the new claim name- Throws:
SQLException- if a database error occurs
-
updateClaimOwner
void updateClaimOwner(@NotNull @NotNull Claim claim, @NotNull @NotNull String newOwnerId) throws SQLException, IllegalArgumentException Update the owner of a Claim- Parameters:
claim- the claimnewOwnerId- the new owner ID (usually a player UUID as string, a team name or "server" depending on theClaimType)- Throws:
SQLException- if a database error occursIllegalArgumentException- if the claim has no ID
-
updateClaimOwner
Update the owner of a Claim- Parameters:
claimId- the claim IDnewOwnerId- the new owner ID (usually a player UUID as string, a team name or "server" depending on theClaimType)- Throws:
SQLException- if a database error occurs
-