Search in sources :

Example 1 with ClaimedResidence

use of com.bekvon.bukkit.residence.protection.ClaimedResidence in project Skript by SkriptLang.

the class ResidenceHook method getRegionsAt_i.

@SuppressWarnings("null")
@Override
public Collection<? extends Region> getRegionsAt_i(final Location l) {
    final List<ResidenceRegion> ress = new ArrayList<>();
    final ClaimedResidence res = Residence.getInstance().getResidenceManager().getByLoc(l);
    if (res == null)
        return Collections.emptyList();
    ress.add(new ResidenceRegion(l.getWorld(), res));
    return ress;
}
Also used : ClaimedResidence(com.bekvon.bukkit.residence.protection.ClaimedResidence) ArrayList(java.util.ArrayList)

Example 2 with ClaimedResidence

use of com.bekvon.bukkit.residence.protection.ClaimedResidence in project CombatLogX by SirBlobman.

the class ResidenceRegionHandler method isSafeZone.

@Override
public boolean isSafeZone(Player player, Location location, TagType tagType) {
    if (tagType != TagType.PLAYER)
        return false;
    ResidenceInterface residenceManager = ResidenceApi.getResidenceManager();
    ClaimedResidence claimedResidence = residenceManager.getByLoc(location);
    if (claimedResidence == null)
        return false;
    ResidencePermissions residencePermissions = claimedResidence.getPermissions();
    return !residencePermissions.has(Flags.pvp, true);
}
Also used : ClaimedResidence(com.bekvon.bukkit.residence.protection.ClaimedResidence) ResidencePermissions(com.bekvon.bukkit.residence.protection.ResidencePermissions) ResidenceInterface(com.bekvon.bukkit.residence.api.ResidenceInterface)

Example 3 with ClaimedResidence

use of com.bekvon.bukkit.residence.protection.ClaimedResidence in project MagicPlugin by elBukkit.

the class ResidenceManager method getWarps.

@Nullable
@Override
public Collection<PlayerWarp> getWarps(@Nonnull Player player) {
    ResidencePlayer residencePlayer = getResidencePlayer(player);
    if (residencePlayer == null) {
        return null;
    }
    Collection<ClaimedResidence> residences = residencePlayer.getResList();
    if (residences == null || residences.isEmpty()) {
        return null;
    }
    Collection<PlayerWarp> warps = new ArrayList<>();
    for (ClaimedResidence residence : residences) {
        Location location = residence.getTeleportLocation(player);
        if (location == null) {
            location = residence.getMainArea().getHighLoc().clone().add(residence.getMainArea().getLowLoc()).multiply(0.5);
            location = location.getWorld().getHighestBlockAt(location).getLocation();
        }
        PlayerWarp warp = new PlayerWarp(residence.getName(), location);
        warps.add(warp);
    }
    return warps;
}
Also used : ResidencePlayer(com.bekvon.bukkit.residence.containers.ResidencePlayer) ClaimedResidence(com.bekvon.bukkit.residence.protection.ClaimedResidence) PlayerWarp(com.elmakers.mine.bukkit.api.protection.PlayerWarp) ArrayList(java.util.ArrayList) Location(org.bukkit.Location) Nullable(javax.annotation.Nullable)

Example 4 with ClaimedResidence

use of com.bekvon.bukkit.residence.protection.ClaimedResidence 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)

Example 5 with ClaimedResidence

use of com.bekvon.bukkit.residence.protection.ClaimedResidence in project Skript by SkriptLang.

the class ResidenceHook method canBuild_i.

@Override
public boolean canBuild_i(final Player p, final Location l) {
    final ClaimedResidence res = Residence.getInstance().getResidenceManager().getByLoc(l);
    if (res == null)
        // No claim here
        return true;
    ResidencePermissions perms = res.getPermissions();
    return perms.playerHas(p, Flags.build, true);
}
Also used : ClaimedResidence(com.bekvon.bukkit.residence.protection.ClaimedResidence) ResidencePermissions(com.bekvon.bukkit.residence.protection.ResidencePermissions)

Aggregations

ClaimedResidence (com.bekvon.bukkit.residence.protection.ClaimedResidence)7 ResidencePermissions (com.bekvon.bukkit.residence.protection.ResidencePermissions)2 ArrayList (java.util.ArrayList)2 Location (org.bukkit.Location)2 Player (org.bukkit.entity.Player)2 ResidenceInterface (com.bekvon.bukkit.residence.api.ResidenceInterface)1 ResidencePlayer (com.bekvon.bukkit.residence.containers.ResidencePlayer)1 CuboidArea (com.bekvon.bukkit.residence.protection.CuboidArea)1 Fetchable (com.denizenscript.denizencore.objects.Fetchable)1 PlayerWarp (com.elmakers.mine.bukkit.api.protection.PlayerWarp)1 FaweMask (com.fastasyncworldedit.core.regions.FaweMask)1 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)1 Nullable (javax.annotation.Nullable)1 EventHandler (org.bukkit.event.EventHandler)1