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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations