Search in sources :

Example 36 with ProtectedRegion

use of com.sk89q.worldguard.protection.regions.ProtectedRegion in project LandLord by SpatiumPrinceps.

the class WorldGuardHandler method canClaim.

public boolean canClaim(Player player, Chunk currChunk) {
    RegionManager regionManager = wg.getRegionManager(player.getWorld());
    if (regionManager != null) {
        ProtectedRegion check = new ProtectedCuboidRegion("check", toVector(currChunk.getBlock(0, 0, 0)), toVector(currChunk.getBlock(15, 127, 15)));
        List<ProtectedRegion> intersects = check.getIntersectingRegions(new ArrayList<>(regionManager.getRegions().values()));
        for (ProtectedRegion intersect : intersects) {
            if (!regionManager.getApplicableRegions(intersect).canBuild(wg.wrapPlayer(player))) {
                return false;
            }
        }
    }
    return true;
}
Also used : ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) ProtectedCuboidRegion(com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion)

Example 37 with ProtectedRegion

use of com.sk89q.worldguard.protection.regions.ProtectedRegion in project LandLord by SpatiumPrinceps.

the class WorldGuardHandler method getRegion.

public OwnedLand getRegion(Chunk chunk) {
    RegionManager manager = wg.getRegionContainer().get(chunk.getWorld());
    ProtectedRegion pr = manager != null ? manager.getRegion(OwnedLand.getName(chunk)) : null;
    return (pr != null ? new OwnedLand(pr, chunk) : null);
}
Also used : OwnedLand(biz.princeps.landlord.util.OwnedLand) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager)

Example 38 with ProtectedRegion

use of com.sk89q.worldguard.protection.regions.ProtectedRegion in project LandLord by SpatiumPrinceps.

the class WorldGuardHandler method getRegionsAsOL.

public List<OwnedLand> getRegionsAsOL(UUID id) {
    List<OwnedLand> list = new ArrayList<>();
    OfflinePlayer op = Bukkit.getOfflinePlayer(id);
    if (op != null)
        for (World world : Bukkit.getWorlds()) {
            // Only count enabled worlds
            if (!Landlord.getInstance().getConfig().getStringList("disabled-worlds").contains(world.getName()))
                for (ProtectedRegion protectedRegion : getRegions(id, world)) {
                    list.add(getRegion(protectedRegion));
                }
        }
    return list;
}
Also used : OwnedLand(biz.princeps.landlord.util.OwnedLand) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion)

Aggregations

ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)38 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)14 ArrayList (java.util.ArrayList)8 Vector (com.sk89q.worldedit.Vector)7 Location (org.bukkit.Location)7 World (org.bukkit.World)7 Player (org.bukkit.entity.Player)6 OwnedLand (biz.princeps.landlord.util.OwnedLand)5 WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)5 FlagConflictException (com.sk89q.worldguard.protection.flags.registry.FlagConflictException)5 WorldGuardPlugin (com.sk89q.worldguard.bukkit.WorldGuardPlugin)4 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)4 RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)4 HashSet (java.util.HashSet)4 BuyRegion (me.wiefferink.areashop.regions.BuyRegion)4 GeneralRegion (me.wiefferink.areashop.regions.GeneralRegion)4 RentRegion (me.wiefferink.areashop.regions.RentRegion)4 LandlordCommand (biz.princeps.landlord.commands.LandlordCommand)3 BlockVector (com.sk89q.worldedit.BlockVector)3 Flag (com.sk89q.worldguard.protection.flags.Flag)3