Add the involved entities in PreventPvPEvent (#1186)
This commit is contained in:
parent
2f0f98db25
commit
e95b7986e4
|
|
@ -819,7 +819,7 @@ public class EntityEventHandler implements Listener
|
|||
damagedData.lastClaim = damagedClaim;
|
||||
if (GriefPrevention.instance.claimIsPvPSafeZone(damagedClaim))
|
||||
{
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(damagedClaim);
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(damagedClaim, attacker, damaged);
|
||||
Bukkit.getPluginManager().callEvent(pvpEvent);
|
||||
if (!pvpEvent.isCancelled())
|
||||
{
|
||||
|
|
@ -887,7 +887,7 @@ public class EntityEventHandler implements Listener
|
|||
GriefPrevention.instance.claimIsPvPSafeZone(attackerClaim))
|
||||
{
|
||||
attackerData.lastClaim = attackerClaim;
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(attackerClaim);
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(attackerClaim, attacker, defender);
|
||||
Bukkit.getPluginManager().callEvent(pvpEvent);
|
||||
if (!pvpEvent.isCancelled())
|
||||
{
|
||||
|
|
@ -904,7 +904,7 @@ public class EntityEventHandler implements Listener
|
|||
GriefPrevention.instance.claimIsPvPSafeZone(defenderClaim))
|
||||
{
|
||||
defenderData.lastClaim = defenderClaim;
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(defenderClaim);
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(defenderClaim, attacker, defender);
|
||||
Bukkit.getPluginManager().callEvent(pvpEvent);
|
||||
if (!pvpEvent.isCancelled())
|
||||
{
|
||||
|
|
@ -947,7 +947,7 @@ public class EntityEventHandler implements Listener
|
|||
GriefPrevention.instance.claimIsPvPSafeZone(defenderClaim))
|
||||
{
|
||||
defenderData.lastClaim = defenderClaim;
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(defenderClaim);
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(defenderClaim, attacker, defender);
|
||||
Bukkit.getPluginManager().callEvent(pvpEvent);
|
||||
|
||||
//if other plugins aren't making an exception to the rule
|
||||
|
|
@ -1047,7 +1047,7 @@ public class EntityEventHandler implements Listener
|
|||
message += " " + GriefPrevention.instance.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement);
|
||||
if (sendErrorMessagesToPlayers)
|
||||
GriefPrevention.sendMessage(attacker, TextMode.Err, message);
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(new Claim(subEvent.getEntity().getLocation(), subEvent.getEntity().getLocation(), null, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null));
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(new Claim(subEvent.getEntity().getLocation(), subEvent.getEntity().getLocation(), null, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null), attacker, tameable);
|
||||
Bukkit.getPluginManager().callEvent(pvpEvent);
|
||||
if (!pvpEvent.isCancelled())
|
||||
{
|
||||
|
|
@ -1441,7 +1441,7 @@ public class EntityEventHandler implements Listener
|
|||
if (attackerClaim != null && GriefPrevention.instance.claimIsPvPSafeZone(attackerClaim))
|
||||
{
|
||||
attackerData.lastClaim = attackerClaim;
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(attackerClaim);
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(attackerClaim, thrower, effectedPlayer);
|
||||
Bukkit.getPluginManager().callEvent(pvpEvent);
|
||||
if (!pvpEvent.isCancelled())
|
||||
{
|
||||
|
|
@ -1455,7 +1455,7 @@ public class EntityEventHandler implements Listener
|
|||
if (defenderClaim != null && GriefPrevention.instance.claimIsPvPSafeZone(defenderClaim))
|
||||
{
|
||||
defenderData.lastClaim = defenderClaim;
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(defenderClaim);
|
||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(defenderClaim, thrower, effectedPlayer);
|
||||
Bukkit.getPluginManager().callEvent(pvpEvent);
|
||||
if (!pvpEvent.isCancelled())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package me.ryanhamshire.GriefPrevention.events;
|
||||
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
|
@ -17,10 +19,14 @@ public class PreventPvPEvent extends Event implements Cancellable
|
|||
}
|
||||
|
||||
Claim claim;
|
||||
Player attacker;
|
||||
Entity defender;
|
||||
|
||||
public PreventPvPEvent(Claim claim)
|
||||
public PreventPvPEvent(Claim claim, Player attacker, Entity defender)
|
||||
{
|
||||
this.claim = claim;
|
||||
this.attacker = attacker;
|
||||
this.defender = defender;
|
||||
}
|
||||
|
||||
public Claim getClaim()
|
||||
|
|
@ -28,6 +34,20 @@ public class PreventPvPEvent extends Event implements Cancellable
|
|||
return this.claim;
|
||||
}
|
||||
|
||||
public Player getAttacker()
|
||||
{
|
||||
return attacker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The defender -- almost in all cases a player, unless the attacker damages a Tamable (pet),
|
||||
* in which case the pet is returned.
|
||||
*/
|
||||
public Entity getDefender()
|
||||
{
|
||||
return defender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user