Class Claim
java.lang.Object
net.mathias2246.buildmc.api.claims.Claim
Represents a claimed area of land within a world.
A Claim is defined by its owner, claim type, world, and a rectangular
region of chunks. Claims may have additional attributes such
as a name, whitelisted players, and protections.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProtection(@NotNull org.bukkit.NamespacedKey protection) Adds a protection to this claim.voidaddWhitelistedPlayer(@NotNull UUID playerId) Adds a player to the whitelist of this claim.booleanChecks whether this claim contains the given chunk coordinates in the given world.booleancontains(@NotNull org.bukkit.Chunk chunk) Checks whether this claim contains the given chunk.intGets the first X-coordinate of the claimed area.intGets the second X-coordinate of the claimed area.intGets the first Z-coordinate of the claimed area.intGets the second Z-coordinate of the claimed area.@Nullable LonggetId()Gets the database ID of this claim.getName()Gets the display name of this claim.Gets the owner ID of this claim.Gets the list of protections applied to this claim.getType()Gets the type of this claim.Gets the list of whitelisted players in this claim.Gets the world UUID where this claim exists.booleanhasProtection(@NotNull Protection protection) Checks if this claim has a specific protection.booleanhasProtection(@NotNull org.bukkit.NamespacedKey protection) Checks if this claim has a specific protection.booleanisPlayerWhitelisted(@NotNull UUID playerID) Checks if a player is whitelisted in this claim.voidremoveProtection(@NotNull org.bukkit.NamespacedKey protection) Removes a protection from this claim.voidremoveWhitelistedPlayer(@NotNull UUID playerId) Removes a player from the whitelist of this claim.voidsetID(long id) Sets the database ID of this claim.toString()
-
Constructor Details
-
Claim
public Claim(@Nullable @Nullable Long id, @NotNull @NotNull ClaimType type, @NotNull @NotNull String ownerId, @NotNull @NotNull UUID worldId, int chunkX1, int chunkZ1, int chunkX2, int chunkZ2, @NotNull @NotNull String name, @NotNull @NotNull List<UUID> whitelistedPlayers, @NotNull @NotNull List<String> protections) Constructs a new claim.- Parameters:
id- The database ID of this claim, ornullif not yet persisted.type- TheClaimTypeof this claim.ownerId- The ID of the owner (usually a player UUID as string or a team name depending on theClaimType).worldId- The UUID of the world where this claim is located.chunkX1- The X-coordinate of the first chunk corner.chunkZ1- The Z-coordinate of the first chunk corner.chunkX2- The X-coordinate of the opposite chunk corner.chunkZ2- The Z-coordinate of the opposite chunk corner.name- The display name of this claim, ornullif unnamed.whitelistedPlayers- The list of players who are whitelisted in this claim.protections- The list of protections (as string keys). If empty and the Claim is not a placeholder, the default protections will be applied.
-
-
Method Details
-
getId
Gets the database ID of this claim.- Returns:
- The ID, or
nullif not yet persisted.
-
getType
-
getOwnerId
-
getWorldId
-
getChunkX1
public int getChunkX1()Gets the first X-coordinate of the claimed area.- Returns:
- The X-coordinate of the first corner chunk.
-
getChunkZ1
public int getChunkZ1()Gets the first Z-coordinate of the claimed area.- Returns:
- The Z-coordinate of the first corner chunk.
-
getChunkX2
public int getChunkX2()Gets the second X-coordinate of the claimed area.- Returns:
- The X-coordinate of the opposite corner chunk.
-
getChunkZ2
public int getChunkZ2()Gets the second Z-coordinate of the claimed area.- Returns:
- The Z-coordinate of the opposite corner chunk.
-
getName
-
setID
@Internal public void setID(long id) Sets the database ID of this claim.This method is intended for internal use only. DO NOT OVERRIDE THE ID OF CLAIMS THAT DON'T BELONG TO YOU.
- Parameters:
id- The new claim ID.
-
getWhitelistedPlayers
-
isPlayerWhitelisted
Checks if a player is whitelisted in this claim.- Parameters:
playerID- The player's UUID.- Returns:
trueif the player is whitelisted, otherwisefalse.
-
addWhitelistedPlayer
Adds a player to the whitelist of this claim.- Parameters:
playerId- The UUID of the player to add.
-
removeWhitelistedPlayer
Removes a player from the whitelist of this claim.- Parameters:
playerId- The UUID of the player to remove.
-
getProtections
-
hasProtection
public boolean hasProtection(@NotNull @NotNull org.bukkit.NamespacedKey protection) Checks if this claim has a specific protection.- Parameters:
protection- TheNamespacedKeyof the protection.- Returns:
trueif the protection is present, otherwisefalse.
-
hasProtection
Checks if this claim has a specific protection.- Parameters:
protection- TheProtectionobject representing the protection.- Returns:
trueif the protection is present, otherwisefalse.
-
addProtection
public void addProtection(@NotNull @NotNull org.bukkit.NamespacedKey protection) Adds a protection to this claim.- Parameters:
protection- TheNamespacedKeyof the protection to add.
-
removeProtection
public void removeProtection(@NotNull @NotNull org.bukkit.NamespacedKey protection) Removes a protection from this claim.- Parameters:
protection- TheNamespacedKeyof the protection to remove.
-
contains
Checks whether this claim contains the given chunk coordinates in the given world.- Parameters:
chunkX- The X-coordinate of the chunk.chunkZ- The Z-coordinate of the chunk.worldUUID- The UUID of the world.- Returns:
trueif the chunk is inside this claim, otherwisefalse.
-
contains
public boolean contains(@NotNull @NotNull org.bukkit.Chunk chunk) Checks whether this claim contains the given chunk.- Parameters:
chunk- TheChunkto check.- Returns:
trueif the chunk is inside this claim, otherwisefalse.
-
toString
-