use of net.kaikk.mc.gpp.PlayerData in project MyPet by xXKeyleXx.
the class GriefPreventionPlusHook method canHurt.
@Override
public boolean canHurt(Player attacker, Player defender) {
try {
if (attacker.hasPermission("griefprevention.nopvpimmunity")) {
return true;
}
if (attacker != defender) {
DataStore dataStore = griefPrevention.getDataStore();
final PlayerData defenderData = dataStore.getPlayerData(defender.getUniqueId());
final 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) {
final Claim attackerClaim = dataStore.getClaimAt(attacker.getLocation(), false, attackerData.lastClaim);
if (attackerClaim != null) {
if (attackerClaim.isAdminClaim() && (attackerClaim.getParent() == null) && griefPrevention.config.pvp_noCombatInAdminLandClaims) {
return false;
}
if (attackerClaim.isAdminClaim() && (attackerClaim.getParent() != null) && griefPrevention.config.pvp_noCombatInAdminSubdivisions) {
return false;
}
if (!attackerClaim.isAdminClaim() && griefPrevention.config.pvp_noCombatInPlayerLandClaims) {
return false;
}
}
final Claim defenderClaim = dataStore.getClaimAt(defender.getLocation(), false, defenderData.lastClaim);
if (defenderClaim != null) {
if (defenderClaim.isAdminClaim() && (defenderClaim.getParent() == null) && griefPrevention.config.pvp_noCombatInAdminLandClaims) {
return false;
}
if (defenderClaim.isAdminClaim() && (defenderClaim.getParent() != null) && griefPrevention.config.pvp_noCombatInAdminSubdivisions) {
return false;
}
if (!defenderClaim.isAdminClaim() && griefPrevention.config.pvp_noCombatInPlayerLandClaims) {
return false;
}
}
}
}
} catch (Throwable ignored) {
}
return true;
}
use of net.kaikk.mc.gpp.PlayerData in project MyPet by xXKeyleXx.
the class GriefPreventionPlusHook method canHurt.
@Override
public boolean canHurt(Player attacker, Entity defender) {
try {
if (!griefPrevention.claimsEnabledForWorld(defender.getWorld())) {
return true;
}
DataStore dataStore = griefPrevention.getDataStore();
if (!(defender instanceof Monster) && griefPrevention.config.claims_protectCreatures) {
if (defender instanceof Tameable && !griefPrevention.config.pvp_enabledWorlds.contains(defender.getWorld().getUID())) {
final Tameable tameable = (Tameable) defender;
if (tameable.isTamed() && (tameable.getOwner() != null)) {
final UUID ownerID = tameable.getOwner().getUniqueId();
if (attacker.getUniqueId().equals(ownerID)) {
return false;
}
final PlayerData attackerData = dataStore.getPlayerData(attacker.getUniqueId());
if (attackerData.ignoreClaims) {
return true;
}
}
}
PlayerData playerData = dataStore.getPlayerData(attacker.getUniqueId());
Claim claim = dataStore.getClaimAt(defender.getLocation(), false, playerData.lastClaim);
if (claim != null) {
if (claim.canOpenContainers(attacker) != null) {
return false;
}
}
}
} catch (Throwable ignored) {
}
return true;
}