Search in sources :

Example 1 with Claim

use of me.ryanhamshire.GriefPrevention.Claim in project MyPet by xXKeyleXx.

the class GriefPreventionHook method canHurt.

@Override
public boolean canHurt(Player attacker, Entity defender) {
    try {
        if (!griefPrevention.claimsEnabledForWorld(defender.getWorld())) {
            return true;
        }
        if (!(defender instanceof Monster) && griefPrevention.config_claims_protectCreatures) {
            if (defender instanceof Tameable) {
                final Tameable tameable = (Tameable) defender;
                if (tameable.isTamed() && tameable.getOwner() != null) {
                    UUID ownerID = tameable.getOwner().getUniqueId();
                    if (attacker.getUniqueId().equals(ownerID)) {
                        return false;
                    }
                    PlayerData attackerData = griefPrevention.dataStore.getPlayerData(attacker.getUniqueId());
                    if (attackerData.ignoreClaims) {
                        return true;
                    }
                    if (!GriefPrevention.instance.pvpRulesApply(defender.getLocation().getWorld()) || (GriefPrevention.instance.config_pvp_protectPets && defender.getType() != EntityType.WOLF)) {
                        return false;
                    } else if (attackerData.pvpImmune) {
                        return false;
                    }
                }
            }
            PlayerData playerData = griefPrevention.dataStore.getPlayerData(attacker.getUniqueId());
            Claim claim = griefPrevention.dataStore.getClaimAt(defender.getLocation(), false, playerData.lastClaim);
            if (claim != null) {
                if (!(defender.getWorld().getPVP() && defender.getType() == EntityType.WOLF)) {
                    if (claim.allowContainers(attacker) != null) {
                        return false;
                    }
                }
            }
        }
    } catch (Throwable ignored) {
    }
    return true;
}
Also used : UUID(java.util.UUID) PlayerData(me.ryanhamshire.GriefPrevention.PlayerData) Claim(me.ryanhamshire.GriefPrevention.Claim)

Example 2 with Claim

use of me.ryanhamshire.GriefPrevention.Claim in project MyPet by xXKeyleXx.

the class GriefPreventionHook method canHurt.

@Override
public boolean canHurt(Player attacker, Player defender) {
    try {
        if (griefPrevention.pvpRulesApply(attacker.getWorld())) {
            if (attacker != defender) {
                DataStore dataStore = griefPrevention.dataStore;
                PlayerData defenderData = dataStore.getPlayerData(defender.getUniqueId());
                PlayerData attackerData = dataStore.getPlayerData(attacker.getUniqueId());
                if (griefPrevention.config_pvp_protectFreshSpawns) {
                    if (defenderData.pvpImmune || attackerData.pvpImmune) {
                        return false;
                    }
                }
                if ((griefPrevention.config_pvp_noCombatInPlayerLandClaims) || (griefPrevention.config_pvp_noCombatInAdminLandClaims)) {
                    Claim attackerClaim = dataStore.getClaimAt(attacker.getLocation(), false, attackerData.lastClaim);
                    if (!attackerData.ignoreClaims) {
                        if ((attackerClaim != null) && (!attackerData.inPvpCombat())) {
                            if (attackerClaim.isAdminClaim() && attackerClaim.parent == null && griefPrevention.config_pvp_noCombatInAdminLandClaims) {
                                return false;
                            }
                            if (attackerClaim.isAdminClaim() && attackerClaim.parent != null && griefPrevention.config_pvp_noCombatInAdminSubdivisions) {
                                return false;
                            }
                            if (!attackerClaim.isAdminClaim() && griefPrevention.config_pvp_noCombatInPlayerLandClaims) {
                                return false;
                            }
                        }
                        Claim defenderClaim = dataStore.getClaimAt(defender.getLocation(), false, defenderData.lastClaim);
                        if (defenderClaim != null && !defenderData.inPvpCombat()) {
                            if (defenderClaim.isAdminClaim() && defenderClaim.parent == null && griefPrevention.config_pvp_noCombatInAdminLandClaims) {
                                return false;
                            }
                            if (defenderClaim.isAdminClaim() && defenderClaim.parent != null && griefPrevention.config_pvp_noCombatInAdminSubdivisions) {
                                return false;
                            }
                            if (!defenderClaim.isAdminClaim() && griefPrevention.config_pvp_noCombatInPlayerLandClaims) {
                                return false;
                            }
                        }
                    }
                }
            }
        }
    } catch (Throwable ignored) {
    }
    return true;
}
Also used : DataStore(me.ryanhamshire.GriefPrevention.DataStore) PlayerData(me.ryanhamshire.GriefPrevention.PlayerData) Claim(me.ryanhamshire.GriefPrevention.Claim)

Example 3 with Claim

use of me.ryanhamshire.GriefPrevention.Claim in project RedProtect by FabioZumbi12.

the class RedProtectUtil method convertFromGP.

public int convertFromGP() {
    int claimed = 0;
    Collection<Claim> claims = GriefPrevention.instance.dataStore.getClaims();
    for (Claim claim : claims) {
        if (Bukkit.getWorlds().contains(claim.getGreaterBoundaryCorner().getWorld())) {
            World w = claim.getGreaterBoundaryCorner().getWorld();
            String pname = claim.getOwnerName().replace(" ", "_").toLowerCase();
            if (claim.ownerID != null) {
                pname = claim.ownerID.toString();
            }
            Set<PlayerRegion> leaders = new HashSet<>();
            leaders.add(new PlayerRegion(claim.ownerID != null ? claim.ownerID.toString() : pname, pname));
            Location newmin = claim.getGreaterBoundaryCorner();
            Location newmax = claim.getLesserBoundaryCorner();
            newmin.setY(w.getMinHeight());
            newmax.setY(w.getMaxHeight());
            Region r = new Region(nameGen(claim.getOwnerName().replace(" ", "_").toLowerCase(), w.getName()), new HashSet<>(), new HashSet<>(), leaders, newmin, newmax, RedProtect.get().getConfigManager().getDefFlagsValues(), "GriefPrevention region", 0, w.getName(), dateNow(), 0, null, true, true);
            Region other = RedProtect.get().getRegionManager().getTopRegion(w.getName(), r.getCenterX(), r.getCenterY(), r.getCenterZ());
            if (other == null || !r.getWelcome().equals(other.getWelcome())) {
                RedProtect.get().getRegionManager().add(r, w.getName());
                RedProtect.get().logger.debug(LogLevel.DEFAULT, "Region: " + r.getName());
                claimed++;
            }
        }
    }
    return claimed;
}
Also used : PlayerRegion(br.net.fabiozumbi12.RedProtect.Core.region.PlayerRegion) PlayerRegion(br.net.fabiozumbi12.RedProtect.Core.region.PlayerRegion) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Claim(me.ryanhamshire.GriefPrevention.Claim)

Example 4 with Claim

use of me.ryanhamshire.GriefPrevention.Claim in project RedProtect by FabioZumbi12.

the class RPUtil method convertFromGP.

public static int convertFromGP() {
    int claimed = 0;
    Collection<Claim> claims = GriefPrevention.instance.dataStore.getClaims();
    for (Claim claim : claims) {
        if (Bukkit.getWorlds().contains(claim.getGreaterBoundaryCorner().getWorld())) {
            World w = claim.getGreaterBoundaryCorner().getWorld();
            String pname = claim.getOwnerName().replace(" ", "_").toLowerCase();
            if (RedProtect.get().OnlineMode && claim.ownerID != null) {
                pname = claim.ownerID.toString();
            }
            List<String> leaders = new ArrayList<>();
            leaders.add(pname);
            Location newmin = claim.getGreaterBoundaryCorner();
            Location newmax = claim.getLesserBoundaryCorner();
            newmin.setY(0);
            newmax.setY(w.getMaxHeight());
            Region r = new Region(nameGen(claim.getOwnerName().replace(" ", "_"), w.getName()), new ArrayList<>(), new ArrayList<>(), leaders, newmin, newmax, RPConfig.getDefFlagsValues(), "GriefPrevention region", 0, w.getName(), DateNow(), 0, null, true);
            Region other = RedProtect.get().rm.getTopRegion(w, r.getCenterX(), r.getCenterY(), r.getCenterZ());
            if (other != null && r.getWelcome().equals(other.getWelcome())) {
            } else {
                RedProtect.get().rm.add(r, w);
                RedProtect.get().logger.debug("Region: " + r.getName());
                claimed++;
            }
        }
    }
    return claimed;
}
Also used : ArrayList(java.util.ArrayList) World(org.bukkit.World) Claim(me.ryanhamshire.GriefPrevention.Claim) Location(org.bukkit.Location)

Example 5 with Claim

use of me.ryanhamshire.GriefPrevention.Claim in project Parties by AlessioDP.

the class GriefPreventionHandler method addPartyPermission.

public static void addPartyPermission(Player claimer, PartyEntity party, PermissionType perm) {
    Claim claim = GriefPrevention.instance.dataStore.getClaimAt(claimer.getLocation(), false, null);
    for (UUID uuid : party.getMembers()) {
        if (claimer.getUniqueId().equals(uuid))
            continue;
        if (perm.isRemove())
            claim.dropPermission(uuid.toString());
        else
            claim.setPermission(uuid.toString(), perm.convertPermission());
    }
    GriefPrevention.instance.dataStore.saveClaim(claim);
}
Also used : UUID(java.util.UUID) Claim(me.ryanhamshire.GriefPrevention.Claim)

Aggregations

Claim (me.ryanhamshire.GriefPrevention.Claim)5 UUID (java.util.UUID)2 PlayerData (me.ryanhamshire.GriefPrevention.PlayerData)2 Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)1 PlayerRegion (br.net.fabiozumbi12.RedProtect.Core.region.PlayerRegion)1 ArrayList (java.util.ArrayList)1 DataStore (me.ryanhamshire.GriefPrevention.DataStore)1 Location (org.bukkit.Location)1 World (org.bukkit.World)1