Search in sources :

Example 6 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project MagicPlugin by elBukkit.

the class WorldGuardAPI method getCastPermission.

@Nullable
public Boolean getCastPermission(Player player, SpellTemplate spell, Location location) {
    if (location != null && worldGuard != null && customFlags != null) {
        RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
        if (regionManager == null) {
            return null;
        }
        ApplicableRegionSet checkSet = regionManager.getApplicableRegions(location);
        if (checkSet == null) {
            return null;
        }
        return customFlags.getCastPermission(getAssociable(player), checkSet, spell);
    }
    return null;
}
Also used : RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet) Nullable(javax.annotation.Nullable)

Example 7 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project MagicPlugin by elBukkit.

the class WorldGuardAPI method getSpellOverrides.

@Nullable
public Set<String> getSpellOverrides(Player player, Location location) {
    if (location != null && worldGuard != null && customFlags != null) {
        RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
        if (regionManager == null) {
            return null;
        }
        ApplicableRegionSet checkSet = regionManager.getApplicableRegions(location);
        if (checkSet == null) {
            return null;
        }
        return customFlags.getSpellOverrides(getAssociable(player), checkSet);
    }
    return null;
}
Also used : RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet) Nullable(javax.annotation.Nullable)

Example 8 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project LandLord by SpatiumPrinceps.

the class WorldGuardHandler method claim.

public void claim(UUID owner, String landname, World world, Location down, Location upper) {
    BlockVector vec1 = OwnedLand.locationToVec(down);
    BlockVector vec2 = OwnedLand.locationToVec(upper);
    ProtectedCuboidRegion pr = new ProtectedCuboidRegion(landname, vec1, vec2);
    DefaultDomain ownerDomain = new DefaultDomain();
    ownerDomain.addPlayer(owner);
    pr.setOwners(ownerDomain);
    // flag management
    pr = setDefaultFlags(pr, down.getChunk());
    RegionManager manager = wg.getRegionContainer().get(world);
    if (manager != null) {
        manager.addRegion(pr);
    }
}
Also used : RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) ProtectedCuboidRegion(com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion) BlockVector(com.sk89q.worldedit.BlockVector) DefaultDomain(com.sk89q.worldguard.domains.DefaultDomain)

Example 9 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project EliteMobs by MagmaGuy.

the class WorldGuardCompatibility method protectWorldMinidugeonArea.

public static void protectWorldMinidugeonArea(Location location, Minidungeon minidungeon) {
    try {
        RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
        RegionManager regions = container.get(BukkitAdapter.adapt(location.getWorld()));
        ProtectedRegion global = regions.getRegion("__global__");
        if (global == null) {
            // But we want a __global__, so let's create one
            global = new GlobalProtectedRegion("__global__");
            regions.addRegion(global);
        }
        protectMinidungeonArea(global, minidungeon);
        DefaultDomain members = global.getMembers();
        members.addPlayer(UUID.fromString("198c4123-cafc-45df-ba79-02a421eb8ce7"));
        global.setOwners(members);
    } catch (Exception ex) {
        new WarningMessage("Failed to protect minidungeon world area!");
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) GlobalProtectedRegion(com.sk89q.worldguard.protection.regions.GlobalProtectedRegion) 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) DefaultDomain(com.sk89q.worldguard.domains.DefaultDomain) FlagConflictException(com.sk89q.worldguard.protection.flags.registry.FlagConflictException)

Example 10 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project EliteMobs by MagmaGuy.

the class WorldGuardCompatibility method protectWorldMinidugeonArea.

public static void protectWorldMinidugeonArea(Location location) {
    try {
        RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
        RegionManager regions = container.get(BukkitAdapter.adapt(location.getWorld()));
        ProtectedRegion global = regions.getRegion("__global__");
        if (global == null) {
            // But we want a __global__, so let's create one
            global = new GlobalProtectedRegion("__global__");
            regions.addRegion(global);
        }
        protectMinidungeonArea(global);
        DefaultDomain members = global.getMembers();
        members.addPlayer(UUID.fromString("198c4123-cafc-45df-ba79-02a421eb8ce7"));
        global.setOwners(members);
    } catch (Exception ex) {
        new WarningMessage("Failed to protect minidungeon world area!");
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) GlobalProtectedRegion(com.sk89q.worldguard.protection.regions.GlobalProtectedRegion) 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) DefaultDomain(com.sk89q.worldguard.domains.DefaultDomain) FlagConflictException(com.sk89q.worldguard.protection.flags.registry.FlagConflictException)

Aggregations

RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)26 ApplicableRegionSet (com.sk89q.worldguard.protection.ApplicableRegionSet)12 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)11 WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)6 FlagConflictException (com.sk89q.worldguard.protection.flags.registry.FlagConflictException)6 RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)6 StateFlag (com.sk89q.worldguard.protection.flags.StateFlag)5 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)5 Nullable (javax.annotation.Nullable)5 Location (org.bukkit.Location)5 ProtectedCuboidRegion (com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion)4 BlockVector (com.sk89q.worldedit.BlockVector)3 DefaultDomain (com.sk89q.worldguard.domains.DefaultDomain)3 BuyRegion (me.wiefferink.areashop.regions.BuyRegion)3 RentRegion (me.wiefferink.areashop.regions.RentRegion)3 World (org.bukkit.World)3 Player (org.bukkit.entity.Player)3 OwnedLand (biz.princeps.landlord.util.OwnedLand)2 ArrayList (java.util.ArrayList)2 GeneralRegion (me.wiefferink.areashop.regions.GeneralRegion)2