Interface WorldGuardApi
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 TypeMethodDescriptionboolean
Checks if PvP (Player vs Player combat) is allowed for the specified player.boolean
Checks if PvP (Player vs Player combat) is allowed for the specified player at a specific location.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
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
- thePlayer
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
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.
-
playerCanBuild
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.
-
hasRegionsInChunk
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
- theChunk
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
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.
-
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")
-