Querying Protection

To query protection, the Flags.BUILD flag can be tested using the methods explained in Flag Calculation.


Region queries do not check if a player has bypass permissions. Depending on your use case, you may want to check that separately.

boolean canBypass = WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(player, player.getWorld());

Example: Querying build permission using the query cache

LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
Location loc = new Location(world, 10, 64, 100);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();

if (!query.testState(loc, localPlayer, Flags.BUILD)) {
    // Can't build