Class Claim

java.lang.Object
net.mathias2246.buildmc.api.claims.Claim

public class Claim extends Object
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
    Constructor
    Description
    Claim(@Nullable Long id, @NotNull ClaimType type, @NotNull String ownerId, @NotNull UUID worldId, int chunkX1, int chunkZ1, int chunkX2, int chunkZ2, @NotNull String name, @NotNull List<UUID> whitelistedPlayers, @NotNull List<String> protections)
    Constructs a new claim.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addProtection(@NotNull org.bukkit.NamespacedKey protection)
    Adds a protection to this claim.
    void
    addWhitelistedPlayer(@NotNull UUID playerId)
    Adds a player to the whitelist of this claim.
    boolean
    contains(int chunkX, int chunkZ, UUID worldUUID)
    Checks whether this claim contains the given chunk coordinates in the given world.
    boolean
    contains(@NotNull org.bukkit.Chunk chunk)
    Checks whether this claim contains the given chunk.
    int
    Gets the first X-coordinate of the claimed area.
    int
    Gets the second X-coordinate of the claimed area.
    int
    Gets the first Z-coordinate of the claimed area.
    int
    Gets the second Z-coordinate of the claimed area.
    @Nullable Long
    Gets the database ID of this claim.
    Gets the display name of this claim.
    Gets the owner ID of this claim.
    com.google.common.collect.ImmutableSet<String>
    Gets the set of protections applied to this claim.
    Gets the type of this claim.
    com.google.common.collect.ImmutableSet<UUID>
    Gets the set of whitelisted players in this claim.
    Gets the world UUID where this claim exists.
    boolean
    hasProtection(@NotNull Protection protection)
    Checks if this claim has a specific protection.
    boolean
    hasProtection(@NotNull org.bukkit.NamespacedKey protection)
    Checks if this claim has a specific protection.
    boolean
    isPlayerWhitelisted(@NotNull UUID playerID)
    Checks if a player is whitelisted in this claim.
    void
    removeProtection(@NotNull org.bukkit.NamespacedKey protection)
    Removes a protection from this claim.
    void
    removeWhitelistedPlayer(@NotNull UUID playerId)
    Removes a player from the whitelist of this claim.
    void
    setID(Long id)
    Deprecated.
    void
    setName(@NotNull String name)
    Sets the claim name of this claim.
    void
    setOwnerId(@NotNull String ownerId)
    Sets the owner ID of this claim.
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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, or null if not yet persisted.
      type - The ClaimType of this claim.
      ownerId - The ID of the owner (usually a player UUID as string, a team name or "server" depending on the ClaimType).
      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.
      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

      @Contract(pure=true) @Nullable public @Nullable Long getId()
      Gets the database ID of this claim.
      Returns:
      The ID, or null if not yet persisted.
    • getType

      @Contract(pure=true) public ClaimType getType()
      Gets the type of this claim.
      Returns:
      The claim type.
    • getOwnerId

      @Contract(pure=true) public String getOwnerId()
      Gets the owner ID of this claim.
      Returns:
      The owner ID (usually a player UUID as string, a team name or "server" depending on the ClaimType).
    • setOwnerId

      @Internal public void setOwnerId(@NotNull @NotNull String ownerId)
      Sets the owner ID of this claim.

      This method is intended for internal use only. Use ClaimManager to set the Owner ID. (usually a player UUID as string, a team name or "server" depending on the ClaimType)

      Parameters:
      ownerId - The new owner ID.
    • getWorldId

      @Contract(pure=true) public UUID getWorldId()
      Gets the world UUID where this claim exists.
      Returns:
      The world UUID.
    • getChunkX1

      @Contract(pure=true) public int getChunkX1()
      Gets the first X-coordinate of the claimed area.
      Returns:
      The X-coordinate of the first corner chunk.
    • getChunkZ1

      @Contract(pure=true) public int getChunkZ1()
      Gets the first Z-coordinate of the claimed area.
      Returns:
      The Z-coordinate of the first corner chunk.
    • getChunkX2

      @Contract(pure=true) public int getChunkX2()
      Gets the second X-coordinate of the claimed area.
      Returns:
      The X-coordinate of the opposite corner chunk.
    • getChunkZ2

      @Contract(pure=true) public int getChunkZ2()
      Gets the second Z-coordinate of the claimed area.
      Returns:
      The Z-coordinate of the opposite corner chunk.
    • getName

      @Contract(pure=true) public String getName()
      Gets the display name of this claim.
      Returns:
      The name of the claim
    • setName

      @Internal public void setName(@NotNull @NotNull String name)
      Sets the claim name of this claim.

      This method is intended for internal use only. Use ClaimManager to change claim name.

      Parameters:
      name - The new claim name.
      See Also:
    • setID

      @Internal @Deprecated public void setID(Long id)
      Deprecated.
      Sets the database ID of this claim.

      This method is intended for internal use only and won't be removed. DO NOT OVERRIDE THE ID OF CLAIMS.

      Parameters:
      id - The new claim ID.
    • getWhitelistedPlayers

      @Contract(pure=true) public com.google.common.collect.ImmutableSet<UUID> getWhitelistedPlayers()
      Gets the set of whitelisted players in this claim.
      Returns:
      An immutable set of whitelisted player UUIDs.
    • isPlayerWhitelisted

      @Contract(pure=true) public boolean isPlayerWhitelisted(@NotNull @NotNull UUID playerID)
      Checks if a player is whitelisted in this claim.
      Parameters:
      playerID - The player's UUID.
      Returns:
      true if the player is whitelisted, otherwise false.
    • addWhitelistedPlayer

      @Internal public void addWhitelistedPlayer(@NotNull @NotNull UUID playerId)
      Adds a player to the whitelist of this claim.

      This method is intended for internal use only. Use ClaimManager to add a player to the whitelist.

      Parameters:
      playerId - The UUID of the player to add.
      See Also:
    • removeWhitelistedPlayer

      @Internal public void removeWhitelistedPlayer(@NotNull @NotNull UUID playerId)
      Removes a player from the whitelist of this claim.

      This method is intended for internal use only. Use ClaimManager to remove a player from the whitelist.

      Parameters:
      playerId - The UUID of the player to remove.
      See Also:
    • getProtections

      @Contract(pure=true) public com.google.common.collect.ImmutableSet<String> getProtections()
      Gets the set of protections applied to this claim.
      Returns:
      An immutable set of protections keys as strings.
    • hasProtection

      @Contract(pure=true) public boolean hasProtection(@NotNull @NotNull org.bukkit.NamespacedKey protection)
      Checks if this claim has a specific protection.
      Parameters:
      protection - The NamespacedKey of the protection.
      Returns:
      true if the protection is present, otherwise false.
    • hasProtection

      @Contract(pure=true) public boolean hasProtection(@NotNull @NotNull Protection protection)
      Checks if this claim has a specific protection.
      Parameters:
      protection - The Protection object representing the protection.
      Returns:
      true if the protection is present, otherwise false.
    • addProtection

      @Internal public void addProtection(@NotNull @NotNull org.bukkit.NamespacedKey protection)
      Adds a protection to this claim.

      This method is intended for internal use only. Use ClaimManager to add protections.

      Parameters:
      protection - The NamespacedKey of the protection to add.
      See Also:
    • removeProtection

      @Internal public void removeProtection(@NotNull @NotNull org.bukkit.NamespacedKey protection)
      Removes a protection from this claim.

      This method is intended for internal use only. Use ClaimManager to remove protections.

      Parameters:
      protection - The NamespacedKey of the protection to remove.
      See Also:
    • contains

      @Contract(pure=true) public boolean contains(int chunkX, int chunkZ, UUID worldUUID)
      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:
      true if the chunk is inside this claim, otherwise false.
    • contains

      @Contract(pure=true) public boolean contains(@NotNull @NotNull org.bukkit.Chunk chunk)
      Checks whether this claim contains the given chunk.
      Parameters:
      chunk - The Chunk to check.
      Returns:
      true if the chunk is inside this claim, otherwise false.
    • toString

      @Contract(pure=true) public String toString()
      Overrides:
      toString in class Object