Search in sources :

Example 11 with RegionContainer

use of com.sk89q.worldguard.protection.regions.RegionContainer in project TriggerReactor by wysohn.

the class WorldguardSupport method getRegionNames.

/**
 * List all the names of regions that is covering the provided location
 *
 * @param loc location to check
 * @return set of region names. It may be empty but never be null.
 */
public Set<String> getRegionNames(Location loc) {
    Set<String> names = new HashSet<>();
    RegionContainer container = wg.getPlatform().getRegionContainer();
    for (ProtectedRegion region : container.get(BukkitAdapter.adapt(loc.getWorld())).getApplicableRegions(toVector3(loc)).getRegions()) {
        names.add(region.getId());
    }
    return names;
}
Also used : RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) HashSet(java.util.HashSet)

Example 12 with RegionContainer

use of com.sk89q.worldguard.protection.regions.RegionContainer in project EliteMobs by MagmaGuy.

the class WorldGuardFlagChecker method getIntegerFlagValue.

@Nullable
public static Integer getIntegerFlagValue(Location location, Flag flag) {
    com.sk89q.worldedit.util.Location wgLocation = BukkitAdapter.adapt(location);
    RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
    RegionQuery query = container.createQuery();
    ApplicableRegionSet set = query.getApplicableRegions(wgLocation);
    Object object = set.queryValue(null, flag);
    return object == null ? null : (Integer) object;
}
Also used : RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) RegionQuery(com.sk89q.worldguard.protection.regions.RegionQuery) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet) Nullable(javax.annotation.Nullable)

Example 13 with RegionContainer

use of com.sk89q.worldguard.protection.regions.RegionContainer in project EliteMobs by MagmaGuy.

the class WorldGuardCompatibility method protectMinidungeonArea.

public static boolean protectMinidungeonArea(String regionName, Location location) {
    try {
        RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
        RegionManager regions = container.get(BukkitAdapter.adapt(location.getWorld()));
        ProtectedRegion protectedRegion = regions.getRegion(regionName);
        if (protectedRegion == null) {
            new WarningMessage("The region name picked did not exist!");
            return false;
        }
        protectMinidungeonArea(protectedRegion);
        return true;
    } catch (Exception ex) {
        new WarningMessage("Failed to protect region " + regionName + " !");
        return false;
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) GlobalProtectedRegion(com.sk89q.worldguard.protection.regions.GlobalProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) FlagConflictException(com.sk89q.worldguard.protection.flags.registry.FlagConflictException)

Example 14 with RegionContainer

use of com.sk89q.worldguard.protection.regions.RegionContainer in project EliteMobs by MagmaGuy.

the class WorldGuardFlagChecker method doEventFlag.

public static boolean doEventFlag(Location location) {
    com.sk89q.worldedit.util.Location wgLocation = BukkitAdapter.adapt(location);
    RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
    RegionQuery query = container.createQuery();
    ApplicableRegionSet set = query.getApplicableRegions(wgLocation);
    return set.testState(null, WorldGuardCompatibility.getEliteMobsEventsFlag());
}
Also used : RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) RegionQuery(com.sk89q.worldguard.protection.regions.RegionQuery) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet)

Example 15 with RegionContainer

use of com.sk89q.worldguard.protection.regions.RegionContainer in project EliteMobs by MagmaGuy.

the class WorldGuardFlagChecker method doEliteMobsSpawnFlag.

public static boolean doEliteMobsSpawnFlag(Location location) {
    com.sk89q.worldedit.util.Location wgLocation = BukkitAdapter.adapt(location);
    RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
    RegionQuery query = container.createQuery();
    ApplicableRegionSet set = query.getApplicableRegions(wgLocation);
    return set.testState(null, WorldGuardCompatibility.getEliteMobsSpawnFlag());
}
Also used : RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) RegionQuery(com.sk89q.worldguard.protection.regions.RegionQuery) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet)

Aggregations

RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)15 ApplicableRegionSet (com.sk89q.worldguard.protection.ApplicableRegionSet)8 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)8 WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)6 FlagConflictException (com.sk89q.worldguard.protection.flags.registry.FlagConflictException)6 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)6 RegionQuery (com.sk89q.worldguard.protection.regions.RegionQuery)6 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)5 DefaultDomain (com.sk89q.worldguard.domains.DefaultDomain)2 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)1 ProtectedCuboidRegion (com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion)1 HashSet (java.util.HashSet)1 Nullable (javax.annotation.Nullable)1