Java Code Examples for com.sk89q.worldguard.protection.managers.RegionManager#getApplicableRegions()
The following examples show how to use
com.sk89q.worldguard.protection.managers.RegionManager#getApplicableRegions() .
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: WorldGuard6Hook.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(); RegionManager manager = plugin.getRegionManager(l.getWorld()); if (manager == null) return r; ApplicableRegionSet applicable = manager.getApplicableRegions(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: WorldGuardHook.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(); WorldGuardPlatform platform = WorldGuard.getInstance().getPlatform(); RegionManager manager = platform.getRegionContainer().get(BukkitAdapter.adapt(l.getWorld())); if (manager == null) return r; ApplicableRegionSet applicable = manager.getApplicableRegions(BukkitAdapter.asBlockVector(l)); if (applicable == null) return r; for (ProtectedRegion region : applicable) r.add(new WorldGuardRegion(l.getWorld(), region)); return r; }
Example 3
Source File: Worldguard.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public ProtectedRegion getRegion(final com.sk89q.worldguard.LocalPlayer player, final Location loc) { RegionManager manager = this.worldguard.getRegionManager(loc.getWorld()); if (manager == null) { if (this.worldguard.getGlobalStateManager().get(loc.getWorld()).useRegions) { System.out.println("Region capability is not enabled for WorldGuard."); } else { System.out.println("WorldGuard is not enabled for that world."); } return null; } final ProtectedRegion global = manager.getRegion("__global__"); if (global != null && isAllowed(player, global)) { return global; } final ApplicableRegionSet regions = manager.getApplicableRegions(loc); for (final ProtectedRegion region : regions) { if (isAllowed(player, region)) { return region; } } return null; }
Example 4
Source File: WorldGuardHandler.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
public static ProtectedRegion getNetherRegionAt(Location location) { if (!Settings.nether_enabled || location == null) { return null; } RegionManager regionManager = getRegionManager(location.getWorld()); if (regionManager == null) { return null; } Iterable<ProtectedRegion> applicableRegions = regionManager.getApplicableRegions(toVector(location)); for (ProtectedRegion region : applicableRegions) { String id = region.getId().toLowerCase(); if (!id.equalsIgnoreCase("__global__") && id.endsWith("nether")) { return region; } } return null; }
Example 5
Source File: NPCRegionCondition.java From BetonQuest with GNU General Public License v3.0 | 6 votes |
@Override protected Boolean execute(String playerID) throws QuestRuntimeException { NPC npc = CitizensAPI.getNPCRegistry().getById(ID); if (npc == null) { throw new QuestRuntimeException("NPC with ID " + ID + " does not exist"); } Entity npcEntity = npc.getEntity(); if (npcEntity == null) return false; Player player = PlayerConverter.getPlayer(playerID); WorldGuardPlatform worldguardPlatform = WorldGuard.getInstance().getPlatform(); RegionManager manager = worldguardPlatform.getRegionContainer().get(BukkitAdapter.adapt(player.getWorld())); if (manager == null) { return false; } ApplicableRegionSet set = manager.getApplicableRegions(BlockVector3.at(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ())); for (ProtectedRegion compare : set) { if (compare.equals(region)) return true; } return false; }
Example 6
Source File: RegionCondition.java From BetonQuest with GNU General Public License v3.0 | 6 votes |
@Override protected Boolean execute(String playerID) { Player player = PlayerConverter.getPlayer(playerID); WorldGuardPlatform worldguardPlatform = WorldGuard.getInstance().getPlatform(); RegionManager manager = worldguardPlatform.getRegionContainer().get(BukkitAdapter.adapt(player.getWorld())); if (manager == null) { return false; } ProtectedRegion region = manager.getRegion(name); ApplicableRegionSet set = manager.getApplicableRegions(BlockVector3.at(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ())); for (ProtectedRegion compare : set) { if (compare.equals(region)) return true; } return false; }
Example 7
Source File: WorldGuardApi.java From ClaimChunk with MIT License | 5 votes |
static boolean _isAllowedClaim(ClaimChunk claimChunk, Chunk chunk) { try { // Generate a region in the given chunk to get all intersecting regions int bx = chunk.getX() << 4; int bz = chunk.getZ() << 4; BlockVector3 pt1 = BlockVector3.at(bx, 0, bz); BlockVector3 pt2 = BlockVector3.at(bx + 15, 256, bz + 15); ProtectedCuboidRegion region = new ProtectedCuboidRegion("_", pt1, pt2); RegionManager regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(chunk.getWorld())); // No regions in this world, claiming should be determined by the config if (regionManager == null) { return claimChunk.chConfig().getBool("worldguard", "allowClaimingInNonGuardedWorlds"); } // If any regions in the given chunk deny chunk claiming, false is returned for (ProtectedRegion regionIn : regionManager.getApplicableRegions(region)) { StateFlag.State flag = regionIn.getFlag(FLAG_CHUNK_CLAIM); if (flag == StateFlag.State.DENY) return false; } // No objections return true; } catch (Exception e) { e.printStackTrace(); } // An error occurred, better to be on the safe side so false is returned return false; }
Example 8
Source File: HookWorldGuard_V6_2.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
private static ApplicableRegionSet getRegions(Location location) { World world = location.getWorld(); WorldGuardPlugin api = getAPI(); RegionManager manager = api.getRegionManager(world); return manager.getApplicableRegions(location); }
Example 9
Source File: HookWorldGuard_V6_1.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
private static ApplicableRegionSet getRegions(Location location) { World world = location.getWorld(); WorldGuardPlugin api = getAPI(); RegionManager manager = api.getRegionManager(world); return manager.getApplicableRegions(location); }
Example 10
Source File: WorldUtil.java From SonarPet with GNU General Public License v3.0 | 5 votes |
public static boolean allowRegion(Location location) { if (EchoPet.getPlugin().getWorldGuardProvider().isHooked()) { WorldGuardPlugin wg = EchoPet.getPlugin().getWorldGuardProvider().getDependency(); if (wg == null) { return true; } RegionManager regionManager = wg.getRegionManager(location.getWorld()); if (regionManager == null) { return true; } ApplicableRegionSet set = regionManager.getApplicableRegions(location); if (set.size() <= 0) { return true; } boolean result = true; boolean hasSet = false; boolean def = EchoPet.getPlugin().getMainConfig().getBoolean("worldguard.regions.allowByDefault", true); ConfigurationSection cs = EchoPet.getPlugin().getMainConfig().getConfigurationSection("worldguard.regions"); for (ProtectedRegion region : set) { for (String key : cs.getKeys(false)) { if (!key.equalsIgnoreCase("allowByDefault") && !key.equalsIgnoreCase("regionEnterCheck")) { if (region.getId().equals(key)) { if (!hasSet) { result = EchoPet.getPlugin().getMainConfig().getBoolean("worldguard.regions." + key, true); hasSet = true; } } } } } return hasSet ? result : def; } return true; }
Example 11
Source File: WorldGuardHandler.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public static String getIslandNameAt(Location location) { RegionManager regionManager = getRegionManager(location.getWorld()); Iterable<ProtectedRegion> applicableRegions = regionManager.getApplicableRegions(toVector(location)); for (ProtectedRegion region : applicableRegions) { String id = region.getId().toLowerCase(); if (!id.equalsIgnoreCase("__global__") && (id.endsWith("island") || id.endsWith("nether"))) { return id.substring(0, id.length() - 6); } } return null; }
Example 12
Source File: WorldGuardHandler.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public static ProtectedRegion getIslandRegionAt(Location location) { RegionManager regionManager = getRegionManager(location.getWorld()); if (regionManager == null) { return null; } Iterable<ProtectedRegion> applicableRegions = regionManager.getApplicableRegions(toVector(location)); for (ProtectedRegion region : applicableRegions) { String id = region.getId().toLowerCase(); if (!id.equalsIgnoreCase("__global__") && (id.endsWith("island") || id.endsWith("nether"))) { return region; } } return null; }
Example 13
Source File: WorldGuardHandler.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public static Set<ProtectedRegion> getIntersectingRegions(Location islandLocation) { log.entering(CN, "getIntersectingRegions", islandLocation); RegionManager regionManager = getRegionManager(islandLocation.getWorld()); ApplicableRegionSet applicableRegions = regionManager.getApplicableRegions(getIslandRegion(islandLocation)); Set<ProtectedRegion> regions = getRegions(applicableRegions); for (Iterator<ProtectedRegion> iterator = regions.iterator(); iterator.hasNext(); ) { if (iterator.next() instanceof GlobalProtectedRegion) { iterator.remove(); } } log.exiting(CN, "getIntersectingRegions"); return regions; }
Example 14
Source File: WorldGuardHook.java From FunnyGuilds with Apache License 2.0 | 5 votes |
public static ApplicableRegionSet getRegionSet(Location location) { if (location == null || worldGuard == null) { return null; } RegionManager regionManager = worldGuard.getRegionManager(location.getWorld()); if (regionManager == null) { return null; } return regionManager.getApplicableRegions(location); }
Example 15
Source File: WorldUtil.java From EchoPet with GNU General Public License v3.0 | 5 votes |
public static boolean allowRegion(Location location) { if (EchoPet.getPlugin().getWorldGuardProvider().isHooked()) { WorldGuardPlugin wg = EchoPet.getPlugin().getWorldGuardProvider().getDependency(); if (wg == null) { return true; } RegionManager regionManager = wg.getRegionManager(location.getWorld()); if (regionManager == null) { return true; } ApplicableRegionSet set = regionManager.getApplicableRegions(location); if (set.size() <= 0) { return true; } boolean result = true; boolean hasSet = false; boolean def = EchoPet.getPlugin().getMainConfig().getBoolean("worldguard.regions.allowByDefault", true); ConfigurationSection cs = EchoPet.getPlugin().getMainConfig().getConfigurationSection("worldguard.regions"); for (ProtectedRegion region : set) { for (String key : cs.getKeys(false)) { if (!key.equalsIgnoreCase("allowByDefault") && !key.equalsIgnoreCase("regionEnterCheck")) { if (region.getId().equals(key)) { if (!hasSet) { result = EchoPet.getPlugin().getMainConfig().getBoolean("worldguard.regions." + key, true); hasSet = true; } } } } } return hasSet ? result : def; } return true; }