mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Listen to EntityDamageByEntity subevents
This commit is contained in:
parent
ed5531d44b
commit
882a457484
@ -61,6 +61,23 @@ public class mcEntityListener implements Listener
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
|
||||
{
|
||||
Entity defender = event.getEntity();
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
if(attacker instanceof Player && defender instanceof Player)
|
||||
{
|
||||
if(!defender.getWorld().getPVP())
|
||||
return;
|
||||
if(Party.getInstance().inSameParty((Player)defender, (Player)attacker))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
Combat.combatChecks(event, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
@ -68,24 +85,6 @@ public class mcEntityListener implements Listener
|
||||
EntityType type = entity.getType();
|
||||
DamageCause cause = event.getCause();
|
||||
|
||||
//Check for world pvp flag
|
||||
if(event instanceof EntityDamageByEntityEvent && !event.isCancelled())
|
||||
{
|
||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent)event;
|
||||
Entity defender = eventb.getEntity();
|
||||
Entity attacker = eventb.getDamager();
|
||||
|
||||
if(attacker instanceof Player && defender instanceof Player)
|
||||
{
|
||||
if(!entity.getWorld().getPVP())
|
||||
return;
|
||||
if(Party.getInstance().inSameParty((Player)defender, (Player)attacker))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
Combat.combatChecks(eventb, plugin);
|
||||
}
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case PLAYER:
|
||||
@ -106,6 +105,7 @@ public class mcEntityListener implements Listener
|
||||
if(!event.isCancelled() && event.getDamage() >= 1)
|
||||
PP.setRecentlyHurt(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
case WOLF:
|
||||
Wolf wolf = (Wolf) entity;
|
||||
if((wolf.getNoDamageTicks() < wolf.getMaximumNoDamageTicks()/2.0F) && wolf.isTamed() && wolf.getOwner() != null)
|
||||
|
Loading…
Reference in New Issue
Block a user