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.
    Gets the list of protections applied to this claim.
    Gets the type of this claim.
    Gets the list 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)
    Sets the database ID of this claim.
     

    Methods inherited from class java.lang.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 or a team name 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, or null if 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

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

      public ClaimType getType()
      Gets the type of this claim.
      Returns:
      The claim type.
    • getOwnerId

      public String getOwnerId()
      Gets the owner ID of this claim.
      Returns:
      The owner ID (usually a player UUID as string or a team name depending on the ClaimType).
    • getWorldId

      public UUID getWorldId()
      Gets the world UUID where this claim exists.
      Returns:
      The world UUID.
    • 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

      public String getName()
      Gets the display name of this claim.
      Returns:
      The name of the claim
    • 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

      public List<UUID> getWhitelistedPlayers()
      Gets the list of whitelisted players in this claim.
      Returns:
      A list of whitelisted player UUIDs.
    • isPlayerWhitelisted

      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

      public void addWhitelistedPlayer(@NotNull @NotNull UUID playerId)
      Adds a player to the whitelist of this claim.
      Parameters:
      playerId - The UUID of the player to add.
    • removeWhitelistedPlayer

      public void removeWhitelistedPlayer(@NotNull @NotNull UUID playerId)
      Removes a player from the whitelist of this claim.
      Parameters:
      playerId - The UUID of the player to remove.
    • getProtections

      public List<String> getProtections()
      Gets the list of protections applied to this claim.
      Returns:
      A list of protections keys as strings.
    • hasProtection

      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

      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

      public void addProtection(@NotNull @NotNull org.bukkit.NamespacedKey protection)
      Adds a protection to this claim.
      Parameters:
      protection - The NamespacedKey of the protection to add.
    • removeProtection

      public void removeProtection(@NotNull @NotNull org.bukkit.NamespacedKey protection)
      Removes a protection from this claim.
      Parameters:
      protection - The NamespacedKey of the protection to remove.
    • contains

      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

      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

      public String toString()
      Overrides:
      toString in class Object