com.sk89q.worldguard.protection.regions.RegionQuery Java Examples
The following examples show how to use
com.sk89q.worldguard.protection.regions.RegionQuery.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldGuard7FAWEHook.java From Skript with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("null") @Override public Collection<? extends Region> getRegionsAt_i(@Nullable final Location l) { final ArrayList<Region> r = new ArrayList<>(); if (l == null) // Working around possible cause of issue #280 return Collections.emptyList(); if (l.getWorld() == null) return Collections.emptyList(); RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); if (query == null) return r; ApplicableRegionSet applicable = query.getApplicableRegions(BukkitAdapter.adapt(l)); if (applicable == null) return r; final Iterator<ProtectedRegion> i = applicable.iterator(); while (i.hasNext()) r.add(new WorldGuardRegion(l.getWorld(), i.next())); return r; }
Example #2
Source File: HookWorldGuard_V7_0.java From CombatLogX with GNU General Public License v3.0 | 6 votes |
public static boolean allowsMobCombat(Location location) { WorldGuard api = getAPI(); WorldGuardPlatform platform = api.getPlatform(); RegionContainer container = platform.getRegionContainer(); RegionQuery query = container.createQuery(); com.sk89q.worldedit.util.Location weLocation = BukkitAdapter.adapt(location); if(MOB_COMBAT_FLAG instanceof StateFlag) { StateFlag mobCombatFlag = (StateFlag) MOB_COMBAT_FLAG; State state = query.queryState(weLocation, null, mobCombatFlag); return (state != State.DENY); } return true; }
Example #3
Source File: HookWorldGuard_V7_0.java From CombatLogX with GNU General Public License v3.0 | 6 votes |
public static boolean allowsTagging(Location location) { WorldGuard api = getAPI(); WorldGuardPlatform platform = api.getPlatform(); RegionContainer container = platform.getRegionContainer(); RegionQuery query = container.createQuery(); if(NO_TAGGING_FLAG instanceof BooleanFlag) { BooleanFlag noTaggingFlag = (BooleanFlag) NO_TAGGING_FLAG; com.sk89q.worldedit.util.Location weLocation = BukkitAdapter.adapt(location); Boolean value = query.queryValue(weLocation, null, noTaggingFlag); return (value == null || !value); } return true; }
Example #4
Source File: WorldGuard.java From Modern-LWC with MIT License | 5 votes |
/** * Check if a player can build in a region * * @param player * @param block * @return */ private boolean canBuild(Player player, Block block) { LocalPlayer localPlayer = worldGuardPlugin.wrapPlayer(player); RegionPermissionModel regionPermissionModel = new RegionPermissionModel(localPlayer); if (regionPermissionModel.mayIgnoreRegionProtection(BukkitAdapter.adapt(block.getWorld()))) { return true; } RegionQuery regionQuery = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); return regionQuery.testBuild(BukkitAdapter.adapt(block.getLocation()), localPlayer); }
Example #5
Source File: WorldGuardCompat.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
public boolean test(Entity entity){ try { RegionQuery rq = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); return !(rq.testState(BukkitAdapter.adapt(entity.getLocation()), null, ENTITY_FLAG)); }catch (NullPointerException e){ return false; } }
Example #6
Source File: WorldGuard7FAWEHook.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean canBuild_i(final Player p, final Location l) { if (p.hasPermission("worldguard.region.bypass." + l.getWorld().getName())) return true; RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); LocalPlayer player = WorldGuardPlugin.inst().wrapPlayer(p); return query.testState(BukkitAdapter.adapt(l), player, Flags.BUILD); }
Example #7
Source File: WorldGuardHook.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean canBuild_i(Player p, Location l) { if (p.hasPermission("worldguard.region.bypass." + l.getWorld().getName())) return true; // Build access always granted by permission WorldGuardPlatform platform = WorldGuard.getInstance().getPlatform(); RegionQuery query = platform.getRegionContainer().createQuery(); return query.testBuild(BukkitAdapter.adapt(l), plugin.wrapPlayer(p)); }
Example #8
Source File: HookWorldGuard_V7_0.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
public static boolean allowsPVP(Location location) { WorldGuard api = getAPI(); WorldGuardPlatform platform = api.getPlatform(); RegionContainer container = platform.getRegionContainer(); RegionQuery query = container.createQuery(); com.sk89q.worldedit.util.Location weLocation = BukkitAdapter.adapt(location); StateFlag.State state = query.queryState(weLocation, null, Flags.PVP); return (state != StateFlag.State.DENY); }
Example #9
Source File: WorldGuardIntegration.java From QuickShop-Reremake with GNU General Public License v3.0 | 4 votes |
@Override public boolean canCreateShopHere(@NotNull Player player, @NotNull Location location) { LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); com.sk89q.worldedit.util.Location wgLoc = BukkitAdapter.adapt(location); boolean canBypass = WorldGuard.getInstance() .getPlatform() .getSessionManager() .hasBypass(localPlayer, BukkitAdapter.adapt(location.getWorld())); if (canBypass) { Util.debugLog( "Player " + player.getName() + " bypassing the protection checks, because player have bypass permission in WorldGuard"); return true; } RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); RegionQuery query = container.createQuery(); if (query.getApplicableRegions(wgLoc).getRegions().isEmpty()) { return !whiteList; } for (WorldGuardFlags flag : createFlags) { switch (flag) { case BUILD: if (query.queryState(wgLoc, localPlayer, Flags.BUILD) == StateFlag.State.DENY) { return false; } break; case FLAG: if (query.queryState(wgLoc, localPlayer, this.createFlag) == StateFlag.State.DENY) { return false; } break; case CHEST_ACCESS: if (query.queryState(wgLoc, localPlayer, Flags.CHEST_ACCESS) == StateFlag.State.DENY) { return false; } break; case INTERACT: if (query.queryState(wgLoc, localPlayer, Flags.INTERACT) == StateFlag.State.DENY) { return false; } break; } } return true; }
Example #10
Source File: WorldGuardIntegration.java From QuickShop-Reremake with GNU General Public License v3.0 | 4 votes |
@Override public boolean canTradeShopHere(@NotNull Player player, @NotNull Location location) { LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); com.sk89q.worldedit.util.Location wgLoc = BukkitAdapter.adapt(location); boolean canBypass = WorldGuard.getInstance() .getPlatform() .getSessionManager() .hasBypass(localPlayer, BukkitAdapter.adapt(location.getWorld())); if (canBypass) { Util.debugLog( "Player " + player.getName() + " bypassing the protection checks, because player have bypass permission in WorldGuard"); return true; } RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); RegionQuery query = container.createQuery(); if (query.getApplicableRegions(wgLoc).getRegions().isEmpty()) { return !whiteList; } for (WorldGuardFlags flag : tradeFlags) { switch (flag) { case BUILD: if (!query.testState(wgLoc, localPlayer, Flags.BUILD)) { return false; } break; case FLAG: if (!query.testState(wgLoc, localPlayer, this.tradeFlag)) { return false; } break; case CHEST_ACCESS: if (!query.testState(wgLoc, localPlayer, Flags.CHEST_ACCESS)) { return false; } break; case INTERACT: if (!query.testState(wgLoc, localPlayer, Flags.INTERACT)) { return false; } break; } } return true; }