Interface WorldGuardApi


public interface WorldGuardApi
Version-specific API interface for WorldGuard integration across different Minecraft versions.

This interface provides a unified abstraction layer for WorldGuard operations that may vary between different WorldGuard and Minecraft versions. It handles region protection queries, PvP status checking, build permissions, and player location tracking within protected regions.

All methods in this interface are designed to work consistently across WorldGuard version changes, abstracting away the differences in WorldGuard's internal APIs between major version updates.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canPVP(@NotNull Player player)
    Checks if PvP (Player vs Player combat) is allowed for the specified player.
    boolean
    canPVP(@NotNull Player player, @NotNull Location location)
    Checks if PvP (Player vs Player combat) is allowed for the specified player at a specific location.
    @NotNull List<Player>
    getPlayersInRegion(@NotNull String regionName)
    Retrieves all players currently located within the specified WorldGuard region.
    @NotNull String
    Retrieves the version string of the WorldGuard plugin currently in use.
    boolean
    hasRegionsInChunk(@NotNull Chunk chunk)
    Checks if the specified chunk contains any WorldGuard regions.
    boolean
    playerCanBuild(@NotNull Player player, @NotNull Location loc)
    Checks if the specified player has build permissions at the given location.
  • Method Details

    • canPVP

      boolean canPVP(@NotNull @NotNull Player player)
      Checks if PvP (Player vs Player combat) is allowed for the specified player.

      This method checks the PvP status at the player's current location, taking into account WorldGuard region flags, global world settings, and any other PvP-related protections that may be in effect.

      Parameters:
      player - the Player to check PvP status for
      Returns:
      true if PvP is allowed for the player at their current location, false if PvP is disabled by WorldGuard protections
    • canPVP

      boolean canPVP(@NotNull @NotNull Player player, @NotNull @NotNull Location location)
      Checks if PvP (Player vs Player combat) is allowed for the specified player at a specific location.

      This method checks the PvP status at the specified location, taking into account WorldGuard region flags, global world settings, and any other PvP-related protections that may be in effect at that location.

      Parameters:
      player - the Player to check PvP status for
      location - the Location to check PvP status at
      Returns:
      true if PvP is allowed for the player at the specified location, false if PvP is disabled by WorldGuard protections
    • playerCanBuild

      boolean playerCanBuild(@NotNull @NotNull Player player, @NotNull @NotNull Location loc)
      Checks if the specified player has build permissions at the given location.

      This method verifies whether the player can place or break blocks at the specified location, taking into account WorldGuard region memberships, permissions, flags, and any other build-related protections.

      This check includes both explicit build permissions and implicit permissions through region membership, ownership, or global permissions.

      Parameters:
      player - the Player to check build permissions for
      loc - the Location to check build permissions at
      Returns:
      true if the player can build at the specified location, false if building is prohibited by WorldGuard protections
    • hasRegionsInChunk

      boolean hasRegionsInChunk(@NotNull @NotNull Chunk chunk)
      Checks if the specified chunk contains any WorldGuard regions.

      This method determines whether any WorldGuard protected regions overlap with the given chunk. This is useful for optimization purposes when bulk operations need to know if WorldGuard protections may be relevant in a particular area.

      Parameters:
      chunk - the Chunk to check for region presence
      Returns:
      true if the chunk contains or overlaps with any WorldGuard regions, false if the chunk is completely unprotected
    • getPlayersInRegion

      @NotNull @NotNull List<Player> getPlayersInRegion(@NotNull @NotNull String regionName)
      Retrieves all players currently located within the specified WorldGuard region.

      This method returns a list of all online players whose current location is within the boundaries of the named WorldGuard region. Players are included regardless of their permissions or membership status in the region.

      The region name should match exactly with a defined WorldGuard region. If the region does not exist, an empty list is returned.

      Parameters:
      regionName - the name of the WorldGuard region to search
      Returns:
      a List of Player instances currently within the region, or an empty list if no players are in the region or the region doesn't exist
    • getVersion

      @NotNull @NotNull String getVersion()
      Retrieves the version string of the WorldGuard plugin currently in use.

      This method returns the version information for the WorldGuard plugin, which can be useful for debugging, compatibility checking, or feature availability determination.

      Returns:
      the WorldGuard version string (e.g., "7.0.4", "6.2.1")