Search in sources :

Example 1 with CuboidArea

use of com.bekvon.bukkit.residence.protection.CuboidArea in project FastAsyncWorldEdit by IntellectualSites.

the class ResidenceFeature method getMask.

@Override
public FaweMask getMask(final com.sk89q.worldedit.entity.Player wePlayer, final MaskType type, boolean isWhitelist) {
    final Player player = BukkitAdapter.adapt(wePlayer);
    final Location location = player.getLocation();
    ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location);
    if (residence != null) {
        boolean isAllowed;
        while (!(isAllowed = isAllowed(player, residence, type)) && residence != null) {
            residence = residence.getSubzoneByLoc(location);
        }
        if (isAllowed) {
            final CuboidArea area = residence.getAreaArray()[0];
            final Location pos1 = area.getLowLoc();
            final Location pos2 = area.getHighLoc();
            final ClaimedResidence finalResidence = residence;
            return new FaweMask(new CuboidRegion(BukkitAdapter.asBlockVector(pos1), BukkitAdapter.asBlockVector(pos2))) {

                @Override
                public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
                    return isAllowed(BukkitAdapter.adapt(player), finalResidence, type);
                }
            };
        }
    }
    return null;
}
Also used : Player(org.bukkit.entity.Player) ClaimedResidence(com.bekvon.bukkit.residence.protection.ClaimedResidence) CuboidArea(com.bekvon.bukkit.residence.protection.CuboidArea) FaweMask(com.fastasyncworldedit.core.regions.FaweMask) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) Location(org.bukkit.Location)

Aggregations

ClaimedResidence (com.bekvon.bukkit.residence.protection.ClaimedResidence)1 CuboidArea (com.bekvon.bukkit.residence.protection.CuboidArea)1 FaweMask (com.fastasyncworldedit.core.regions.FaweMask)1 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)1 Location (org.bukkit.Location)1 Player (org.bukkit.entity.Player)1