Lingering potion PvP protections.
Protecting fresh respawns and players in pvp safe zones.
This commit is contained in:
parent
c6ed67af5f
commit
6bf463bab1
|
|
@ -650,6 +650,40 @@ public class EntityEventHandler implements Listener
|
||||||
attacker = (Player)arrow.getShooter();
|
attacker = (Player)arrow.getShooter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//protect players from lingering potion damage when protected from pvp
|
||||||
|
if(damageSource.getType() == EntityType.AREA_EFFECT_CLOUD && event.getEntityType() == EntityType.PLAYER && GriefPrevention.instance.pvpRulesApply(event.getEntity().getWorld()))
|
||||||
|
{
|
||||||
|
Player damaged = (Player)event.getEntity();
|
||||||
|
PlayerData damagedData = GriefPrevention.instance.dataStore.getPlayerData(damaged.getUniqueId());
|
||||||
|
|
||||||
|
//case 1: recently spawned
|
||||||
|
if(GriefPrevention.instance.config_pvp_protectFreshSpawns && damagedData.pvpImmune)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//case 2: in a pvp safe zone
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Claim damagedClaim = GriefPrevention.instance.dataStore.getClaimAt(damaged.getLocation(), false, damagedData.lastClaim);
|
||||||
|
if(damagedClaim != null)
|
||||||
|
{
|
||||||
|
damagedData.lastClaim = damagedClaim;
|
||||||
|
if(GriefPrevention.instance.claimIsPvPSafeZone(damagedClaim))
|
||||||
|
{
|
||||||
|
PreventPvPEvent pvpEvent = new PreventPvPEvent(damagedClaim);
|
||||||
|
Bukkit.getPluginManager().callEvent(pvpEvent);
|
||||||
|
if(!pvpEvent.isCancelled())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the attacker is a player and defender is a player (pvp combat)
|
//if the attacker is a player and defender is a player (pvp combat)
|
||||||
|
|
@ -690,9 +724,7 @@ public class EntityEventHandler implements Listener
|
||||||
{
|
{
|
||||||
if( attackerClaim != null && //ignore claims mode allows for pvp inside land claims
|
if( attackerClaim != null && //ignore claims mode allows for pvp inside land claims
|
||||||
!attackerData.inPvpCombat() &&
|
!attackerData.inPvpCombat() &&
|
||||||
(attackerClaim.isAdminClaim() && attackerClaim.parent == null && GriefPrevention.instance.config_pvp_noCombatInAdminLandClaims ||
|
GriefPrevention.instance.claimIsPvPSafeZone(attackerClaim))
|
||||||
attackerClaim.isAdminClaim() && attackerClaim.parent != null && GriefPrevention.instance.config_pvp_noCombatInAdminSubdivisions ||
|
|
||||||
!attackerClaim.isAdminClaim() && GriefPrevention.instance.config_pvp_noCombatInPlayerLandClaims))
|
|
||||||
{
|
{
|
||||||
attackerData.lastClaim = attackerClaim;
|
attackerData.lastClaim = attackerClaim;
|
||||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(attackerClaim);
|
PreventPvPEvent pvpEvent = new PreventPvPEvent(attackerClaim);
|
||||||
|
|
@ -708,9 +740,7 @@ public class EntityEventHandler implements Listener
|
||||||
Claim defenderClaim = this.dataStore.getClaimAt(defender.getLocation(), false, defenderData.lastClaim);
|
Claim defenderClaim = this.dataStore.getClaimAt(defender.getLocation(), false, defenderData.lastClaim);
|
||||||
if( defenderClaim != null &&
|
if( defenderClaim != null &&
|
||||||
!defenderData.inPvpCombat() &&
|
!defenderData.inPvpCombat() &&
|
||||||
(defenderClaim.isAdminClaim() && defenderClaim.parent == null && GriefPrevention.instance.config_pvp_noCombatInAdminLandClaims ||
|
GriefPrevention.instance.claimIsPvPSafeZone(defenderClaim))
|
||||||
defenderClaim.isAdminClaim() && defenderClaim.parent != null && GriefPrevention.instance.config_pvp_noCombatInAdminSubdivisions ||
|
|
||||||
!defenderClaim.isAdminClaim() && GriefPrevention.instance.config_pvp_noCombatInPlayerLandClaims))
|
|
||||||
{
|
{
|
||||||
defenderData.lastClaim = defenderClaim;
|
defenderData.lastClaim = defenderClaim;
|
||||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(defenderClaim);
|
PreventPvPEvent pvpEvent = new PreventPvPEvent(defenderClaim);
|
||||||
|
|
@ -1108,10 +1138,7 @@ public class EntityEventHandler implements Listener
|
||||||
PlayerData defenderData = this.dataStore.getPlayerData(effectedPlayer.getUniqueId());
|
PlayerData defenderData = this.dataStore.getPlayerData(effectedPlayer.getUniqueId());
|
||||||
PlayerData attackerData = this.dataStore.getPlayerData(thrower.getUniqueId());
|
PlayerData attackerData = this.dataStore.getPlayerData(thrower.getUniqueId());
|
||||||
Claim attackerClaim = this.dataStore.getClaimAt(thrower.getLocation(), false, attackerData.lastClaim);
|
Claim attackerClaim = this.dataStore.getClaimAt(thrower.getLocation(), false, attackerData.lastClaim);
|
||||||
if( attackerClaim != null &&
|
if(attackerClaim != null && GriefPrevention.instance.claimIsPvPSafeZone(attackerClaim))
|
||||||
(attackerClaim.isAdminClaim() && attackerClaim.parent == null && GriefPrevention.instance.config_pvp_noCombatInAdminLandClaims ||
|
|
||||||
attackerClaim.isAdminClaim() && attackerClaim.parent != null && GriefPrevention.instance.config_pvp_noCombatInAdminSubdivisions ||
|
|
||||||
!attackerClaim.isAdminClaim() && GriefPrevention.instance.config_pvp_noCombatInPlayerLandClaims))
|
|
||||||
{
|
{
|
||||||
attackerData.lastClaim = attackerClaim;
|
attackerData.lastClaim = attackerClaim;
|
||||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(attackerClaim);
|
PreventPvPEvent pvpEvent = new PreventPvPEvent(attackerClaim);
|
||||||
|
|
@ -1125,10 +1152,7 @@ public class EntityEventHandler implements Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
Claim defenderClaim = this.dataStore.getClaimAt(effectedPlayer.getLocation(), false, defenderData.lastClaim);
|
Claim defenderClaim = this.dataStore.getClaimAt(effectedPlayer.getLocation(), false, defenderData.lastClaim);
|
||||||
if( defenderClaim != null &&
|
if(defenderClaim != null && GriefPrevention.instance.claimIsPvPSafeZone(defenderClaim))
|
||||||
(defenderClaim.isAdminClaim() && defenderClaim.parent == null && GriefPrevention.instance.config_pvp_noCombatInAdminLandClaims ||
|
|
||||||
defenderClaim.isAdminClaim() && defenderClaim.parent != null && GriefPrevention.instance.config_pvp_noCombatInAdminSubdivisions ||
|
|
||||||
!defenderClaim.isAdminClaim() && GriefPrevention.instance.config_pvp_noCombatInPlayerLandClaims))
|
|
||||||
{
|
{
|
||||||
defenderData.lastClaim = defenderClaim;
|
defenderData.lastClaim = defenderClaim;
|
||||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(defenderClaim);
|
PreventPvPEvent pvpEvent = new PreventPvPEvent(defenderClaim);
|
||||||
|
|
|
||||||
|
|
@ -3449,4 +3449,11 @@ public class GriefPrevention extends JavaPlugin
|
||||||
if(hand == EquipmentSlot.OFF_HAND) return player.getInventory().getItemInOffHand();
|
if(hand == EquipmentSlot.OFF_HAND) return player.getInventory().getItemInOffHand();
|
||||||
return player.getInventory().getItemInMainHand();
|
return player.getInventory().getItemInMainHand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean claimIsPvPSafeZone(Claim claim)
|
||||||
|
{
|
||||||
|
return claim.isAdminClaim() && claim.parent == null && GriefPrevention.instance.config_pvp_noCombatInAdminLandClaims ||
|
||||||
|
claim.isAdminClaim() && claim.parent != null && GriefPrevention.instance.config_pvp_noCombatInAdminSubdivisions ||
|
||||||
|
!claim.isAdminClaim() && GriefPrevention.instance.config_pvp_noCombatInPlayerLandClaims;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user