Class WGClaim

java.lang.Object
me.EtienneDx.RealEstate.ClaimAPI.WorldGuard.WGClaim
All Implemented Interfaces:
IClaim

public class WGClaim extends Object implements IClaim
WGClaim is an implementation of the IClaim interface for WorldGuard regions.

This class wraps a WorldGuard ProtectedRegion and provides methods to access claim information such as its area, location, ownership, and permission management.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final UUID
    A constant used to represent the "server" owner for admin claims.
  • Constructor Summary

    Constructors
    Constructor
    Description
    WGClaim(com.sk89q.worldguard.protection.regions.ProtectedRegion region, org.bukkit.World world)
    Constructs a new WGClaim instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addManager(UUID player)
    Adds a manager to this claim.
    void
    Adds the specified permission for the given player to this claim.
    void
    Clears all managers from this claim.
    void
    Clears all player permissions from this claim.
    void
    Removes the specified player's permissions from this claim.
    int
    Calculates and returns the area of this claim.
    Returns the child claims of this claim.
    Returns the unique identifier of this claim.
    Returns the owner of this claim.
    Returns the owner's name of this claim.
    Returns the parent claim of this claim.
    org.bukkit.World
    Returns the world in which this claim is located.
    int
    Returns the X-coordinate of the claim's minimum point.
    int
    Returns the Y-coordinate of the claim's minimum point.
    int
    Returns the Z-coordinate of the claim's minimum point.
    boolean
    Determines whether this claim is an admin claim.
    boolean
    Indicates whether this claim is a parent claim.
    boolean
    Indicates whether this claim is a subclaim.
    boolean
    Indicates whether this claim is considered "wilderness".
    void
    Removes a manager from this claim.
    void
    setInheritPermissions(boolean inherit)
    Sets whether this claim should inherit permissions from its parent.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SERVER_UUID

      public static final UUID SERVER_UUID
      A constant used to represent the "server" owner for admin claims.
  • Constructor Details

    • WGClaim

      public WGClaim(com.sk89q.worldguard.protection.regions.ProtectedRegion region, org.bukkit.World world)
      Constructs a new WGClaim instance.
      Parameters:
      region - the WorldGuard ProtectedRegion representing the claim.
      world - the Bukkit World in which the claim exists.
  • Method Details

    • getId

      public String getId()
      Returns the unique identifier of this claim.
      Specified by:
      getId in interface IClaim
      Returns:
      the region ID as a String.
    • getArea

      public int getArea()
      Calculates and returns the area of this claim.

      The area is computed by subtracting the minimum point from the maximum point along the X and Z axes, then multiplying the resulting width and length.

      Specified by:
      getArea in interface IClaim
      Returns:
      the area of the claim.
    • getWorld

      public org.bukkit.World getWorld()
      Returns the world in which this claim is located.
      Specified by:
      getWorld in interface IClaim
      Returns:
      the Bukkit World object.
    • getX

      public int getX()
      Returns the X-coordinate of the claim's minimum point.
      Specified by:
      getX in interface IClaim
      Returns:
      the X-coordinate as an integer.
    • getY

      public int getY()
      Returns the Y-coordinate of the claim's minimum point.
      Specified by:
      getY in interface IClaim
      Returns:
      the Y-coordinate as an integer.
    • getZ

      public int getZ()
      Returns the Z-coordinate of the claim's minimum point.
      Specified by:
      getZ in interface IClaim
      Returns:
      the Z-coordinate as an integer.
    • isAdminClaim

      public boolean isAdminClaim()
      Determines whether this claim is an admin claim.

      A claim is considered an admin claim if it has no owners.

      Specified by:
      isAdminClaim in interface IClaim
      Returns:
      true if the region has no owners, false otherwise.
    • getChildren

      public Iterable<IClaim> getChildren()
      Returns the child claims of this claim.

      WorldGuard does not support child claims in this implementation, so an empty list is returned.

      Specified by:
      getChildren in interface IClaim
      Returns:
      an empty iterable.
    • isWilderness

      public boolean isWilderness()
      Indicates whether this claim is considered "wilderness".

      In this implementation, WorldGuard regions are never considered wilderness.

      Specified by:
      isWilderness in interface IClaim
      Returns:
      false always.
    • isSubClaim

      public boolean isSubClaim()
      Indicates whether this claim is a subclaim.

      Not supported in this implementation.

      Specified by:
      isSubClaim in interface IClaim
      Returns:
      false.
    • isParentClaim

      public boolean isParentClaim()
      Indicates whether this claim is a parent claim.

      Every WorldGuard region is treated as a parent claim in this implementation.

      Specified by:
      isParentClaim in interface IClaim
      Returns:
      true always.
    • getParent

      public IClaim getParent()
      Returns the parent claim of this claim.

      Not supported in this implementation.

      Specified by:
      getParent in interface IClaim
      Returns:
      null.
    • dropPlayerPermissions

      public void dropPlayerPermissions(UUID player)
      Removes the specified player's permissions from this claim.

      This is done by removing the player's name from the region's members list.

      Specified by:
      dropPlayerPermissions in interface IClaim
      Parameters:
      player - the UUID of the player whose permissions should be removed.
    • addPlayerPermissions

      public void addPlayerPermissions(UUID player, ClaimPermission permission)
      Adds the specified permission for the given player to this claim.

      For this implementation, all permissions are granted by adding the player's name to the region's members list.

      Specified by:
      addPlayerPermissions in interface IClaim
      Parameters:
      player - the UUID of the player.
      permission - the claim permission to add.
    • clearPlayerPermissions

      public void clearPlayerPermissions()
      Clears all player permissions from this claim.

      This is done by clearing the entire members list of the region.

      Specified by:
      clearPlayerPermissions in interface IClaim
    • removeManager

      public void removeManager(UUID player)
      Removes a manager from this claim.

      Not supported in this implementation.

      Specified by:
      removeManager in interface IClaim
      Parameters:
      player - the UUID of the player to remove as manager.
    • addManager

      public void addManager(UUID player)
      Adds a manager to this claim.

      Not supported in this implementation.

      Specified by:
      addManager in interface IClaim
      Parameters:
      player - the UUID of the player to add as manager.
    • clearManagers

      public void clearManagers()
      Clears all managers from this claim.

      Not supported in this implementation.

      Specified by:
      clearManagers in interface IClaim
    • getOwner

      public UUID getOwner()
      Returns the owner of this claim.

      If the region has no owners, this method returns the constant SERVER_UUID to indicate an admin claim. Otherwise, it returns the first owner's UUID.

      Specified by:
      getOwner in interface IClaim
      Returns:
      the owner's UUID, or SERVER_UUID if no owners exist.
    • getOwnerName

      public String getOwnerName()
      Returns the owner's name of this claim.

      If this is an admin claim, returns "SERVER". Otherwise, it attempts to look up the owner's name via Bukkit's OfflinePlayer; if not found, returns "Unknown".

      Specified by:
      getOwnerName in interface IClaim
      Returns:
      the owner's name as a String.
    • setInheritPermissions

      public void setInheritPermissions(boolean inherit)
      Sets whether this claim should inherit permissions from its parent.

      Not supported in this implementation.

      Specified by:
      setInheritPermissions in interface IClaim
      Parameters:
      inherit - if true, the claim should inherit permissions (ignored).