/** * Get the (effective) value for a list of state flags. The rules of * states is observed here; that is, {@code DENY} overrides {@code ALLOW}, * and {@code ALLOW} overrides {@code NONE}. One flag may override another. * * <p>{@code player} can be non-null to satisfy region group requirements, * otherwise it will be assumed that the caller that is not a member of any * regions. (FlagUtil on a region can be changed so that they only apply * to certain users.) The player argument is required if the * {@link Flags#BUILD} flag is in the list of flags.</p> * * @param location the location * @param player an optional player, which would be used to determine the region groups that apply * @param flags a list of flags to check * @return a state * @see RegionResultSet#queryState(RegionAssociable, StateFlag...) */ @Nullable public State queryState(Location location, @Nullable LocalPlayer player, StateFlag... flags) { return getApplicableRegions(location).queryState(player, flags); }
/** * Get the (effective) value for a list of state flags. The rules of * states is observed here; that is, {@code DENY} overrides {@code ALLOW}, * and {@code ALLOW} overrides {@code NONE}. One flag may override another. * * <p>{@code player} can be non-null to satisfy region group requirements, * otherwise it will be assumed that the caller that is not a member of any * regions. (FlagUtil on a region can be changed so that they only apply * to certain users.) The player argument is required if the * {@link Flags#BUILD} flag is in the list of flags.</p> * * @param location the location * @param associable an optional associable * @param flags a list of flags to check * @return a state * @see RegionResultSet#queryState(RegionAssociable, StateFlag...) */ @Nullable public State queryState(Location location, @Nullable RegionAssociable associable, StateFlag... flags) { return getApplicableRegions(location).queryState(associable, flags); }
public boolean isPVPAllowed(Player player, Location location) { if (worldGuardPlugin == null || location == null) return true; ApplicableRegionSet checkSet = getRegionSet(location); if (checkSet == null) return true; return checkSet.queryState(getAssociable(player), pvpFlag) != StateFlag.State.DENY; }
public boolean isExitAllowed(Player player, Location location) { if (worldGuardPlugin == null || location == null) return true; ApplicableRegionSet checkSet = getRegionSet(location); if (checkSet == null) return true; return checkSet.queryState(getAssociable(player), exitFlag) != StateFlag.State.DENY; }
@EventHandler public void canBuild(BuildPermissionEvent event) { ApplicableRegionSet regions = getApplicableRegions(event.getSign().getBlock().getLocation()); if (regions != null && Properties.WORLDGUARD_USE_FLAG) { event.allow(regions.queryState(worldGuard.wrapPlayer(event.getPlayer()), WorldGuardFlags.ENABLE_SHOP) == StateFlag.State.ALLOW); } else { event.allow(regions == null || regions.size() != 0); } }