Class WorldGuardAPI

java.lang.Object
me.EtienneDx.RealEstate.ClaimAPI.WorldGuard.WorldGuardAPI
All Implemented Interfaces:
IClaimAPI

public class WorldGuardAPI extends Object implements IClaimAPI
WorldGuardAPI provides an implementation of the IClaimAPI interface using WorldGuard.

This class uses WorldGuard's platform API to query and wrap claims in the WGClaim class. Note that some operations (such as changing a claim's owner) are not supported.

  • Constructor Details

    • WorldGuardAPI

      public WorldGuardAPI()
      Constructs a new WorldGuardAPI instance.

      It obtains the RegionContainer via the WorldGuard platform API.

  • Method Details

    • getClaimAt

      public IClaim getClaimAt(org.bukkit.Location bukkitLocation)
      Retrieves a claim at the specified Bukkit location.

      The method converts the given Bukkit location into a WorldEdit location and queries for applicable WorldGuard regions. If one or more regions are found, the first region is wrapped in a WGClaim instance.

      Specified by:
      getClaimAt in interface IClaimAPI
      Parameters:
      bukkitLocation - the Bukkit location to check for a claim
      Returns:
      an IClaim instance representing the claim at the location, or null if no claim exists
    • saveClaim

      public void saveClaim(IClaim claim)
      Saves the specified claim.

      For WorldGuard, claims are automatically saved; thus, no action is required.

      Specified by:
      saveClaim in interface IClaimAPI
      Parameters:
      claim - the claim to be saved
    • getPlayerData

      public IPlayerData getPlayerData(UUID player)
      Retrieves player-specific claim data.

      Not supported in this implementation.

      Specified by:
      getPlayerData in interface IClaimAPI
      Parameters:
      player - the UUID of the player
      Returns:
      null as player data is not implemented
    • changeClaimOwner

      public void changeClaimOwner(IClaim claim, UUID newOwner)
      Changes the owner of the specified claim.

      Changing a claim's owner is not supported by WorldGuard. This method always throws an exception.

      Specified by:
      changeClaimOwner in interface IClaimAPI
      Parameters:
      claim - the claim whose owner is to be changed
      newOwner - the UUID of the new owner
      Throws:
      UnsupportedOperationException - always thrown as this operation is not supported
    • registerEvents

      public void registerEvents()
      Registers any necessary event listeners for claim-related events.

      No events are registered for WorldGuard integration in this implementation.

      Specified by:
      registerEvents in interface IClaimAPI
    • addPlayerPermission

      public void addPlayerPermission(IClaim claim, UUID player, ClaimPermission permission)
      Adds the given player's permission to the specified claim.

      This method delegates to the WGClaim implementation's addPlayerPermissions method.

      Parameters:
      claim - the claim (must be an instance of WGClaim)
      player - the UUID of the player to grant permission
      permission - the permission type to add (e.g. BUILD, ACCESS, etc.)
    • removePlayerPermission

      public void removePlayerPermission(IClaim claim, UUID player)
      Removes any permission for the given player from the specified claim.

      This method delegates to the WGClaim implementation's dropPlayerPermissions method.

      Parameters:
      claim - the claim (must be an instance of WGClaim)
      player - the UUID of the player whose permission should be removed