Fix: Fire arrows ignite protected entities.
A change to the Bukkit API broke this.
This commit is contained in:
parent
2e3e9d66fd
commit
c9f8f73b5b
|
|
@ -66,6 +66,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
import org.bukkit.event.entity.EntityBreakDoorEvent;
|
import org.bukkit.event.entity.EntityBreakDoorEvent;
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
@ -608,6 +609,23 @@ public class EntityEventHandler implements Listener
|
||||||
//when an entity is damaged
|
//when an entity is damaged
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onEntityDamage (EntityDamageEvent event)
|
public void onEntityDamage (EntityDamageEvent event)
|
||||||
|
{
|
||||||
|
this.handleEntityDamageEvent(event, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//when an entity is set on fire
|
||||||
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
|
public void onEntityCombustByEntity (EntityCombustByEntityEvent event)
|
||||||
|
{
|
||||||
|
//handle it just like we would an entity damge by entity event, except don't send player messages to avoid double messages
|
||||||
|
//in cases like attacking with a flame sword or flame arrow, which would ALSO trigger the direct damage event handler
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
EntityDamageByEntityEvent eventWrapper = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), DamageCause.FIRE_TICK, event.getDuration());
|
||||||
|
this.handleEntityDamageEvent(eventWrapper, false);
|
||||||
|
event.setCancelled(eventWrapper.isCancelled());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleEntityDamageEvent(EntityDamageEvent event, boolean sendErrorMessagesToPlayers)
|
||||||
{
|
{
|
||||||
//monsters are never protected
|
//monsters are never protected
|
||||||
if(isMonster(event.getEntity())) return;
|
if(isMonster(event.getEntity())) return;
|
||||||
|
|
@ -723,14 +741,14 @@ public class EntityEventHandler implements Listener
|
||||||
if(defenderData.pvpImmune)
|
if(defenderData.pvpImmune)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.ThatPlayerPvPImmune);
|
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.ThatPlayerPvPImmune);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(attackerData.pvpImmune)
|
if(attackerData.pvpImmune)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune);
|
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -751,7 +769,7 @@ public class EntityEventHandler implements Listener
|
||||||
if(!pvpEvent.isCancelled())
|
if(!pvpEvent.isCancelled())
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune);
|
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -767,7 +785,7 @@ public class EntityEventHandler implements Listener
|
||||||
if(!pvpEvent.isCancelled())
|
if(!pvpEvent.isCancelled())
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.PlayerInPvPSafeZone);
|
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.PlayerInPvPSafeZone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -830,7 +848,7 @@ public class EntityEventHandler implements Listener
|
||||||
if(failureReason != null)
|
if(failureReason != null)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
GriefPrevention.sendMessage(attacker, TextMode.Err, failureReason);
|
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, failureReason);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -866,7 +884,7 @@ public class EntityEventHandler implements Listener
|
||||||
String message = GriefPrevention.instance.dataStore.getMessage(Messages.NoDamageClaimedEntity, ownerName);
|
String message = GriefPrevention.instance.dataStore.getMessage(Messages.NoDamageClaimedEntity, ownerName);
|
||||||
if(attacker.hasPermission("griefprevention.ignoreclaims"))
|
if(attacker.hasPermission("griefprevention.ignoreclaims"))
|
||||||
message += " " + GriefPrevention.instance.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement);
|
message += " " + GriefPrevention.instance.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement);
|
||||||
GriefPrevention.sendMessage(attacker, TextMode.Err, message);
|
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, message);
|
||||||
PreventPvPEvent pvpEvent = new PreventPvPEvent(new Claim(subEvent.getEntity().getLocation(), subEvent.getEntity().getLocation(), null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), null));
|
PreventPvPEvent pvpEvent = new PreventPvPEvent(new Claim(subEvent.getEntity().getLocation(), subEvent.getEntity().getLocation(), null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), null));
|
||||||
Bukkit.getPluginManager().callEvent(pvpEvent);
|
Bukkit.getPluginManager().callEvent(pvpEvent);
|
||||||
if(!pvpEvent.isCancelled())
|
if(!pvpEvent.isCancelled())
|
||||||
|
|
@ -879,7 +897,7 @@ public class EntityEventHandler implements Listener
|
||||||
else if(attackerData.pvpImmune)
|
else if(attackerData.pvpImmune)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune);
|
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -945,10 +963,13 @@ public class EntityEventHandler implements Listener
|
||||||
//kill the arrow to avoid infinite bounce between crowded together animals
|
//kill the arrow to avoid infinite bounce between crowded together animals
|
||||||
if(arrow != null) arrow.remove();
|
if(arrow != null) arrow.remove();
|
||||||
|
|
||||||
|
if(sendErrorMessagesToPlayers)
|
||||||
|
{
|
||||||
String message = GriefPrevention.instance.dataStore.getMessage(Messages.NoDamageClaimedEntity, claim.getOwnerName());
|
String message = GriefPrevention.instance.dataStore.getMessage(Messages.NoDamageClaimedEntity, claim.getOwnerName());
|
||||||
if(attacker.hasPermission("griefprevention.ignoreclaims"))
|
if(attacker.hasPermission("griefprevention.ignoreclaims"))
|
||||||
message += " " + GriefPrevention.instance.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement);
|
message += " " + GriefPrevention.instance.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement);
|
||||||
GriefPrevention.sendMessage(attacker, TextMode.Err, message);
|
GriefPrevention.sendMessage(attacker, TextMode.Err, message);
|
||||||
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user