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
@ -62,30 +62,29 @@ public class mcEntityListener implements Listener
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
|
||||
{
|
||||
Entity entity = event.getEntity();
|
||||
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();
|
||||
Entity defender = event.getEntity();
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
if(attacker instanceof Player && defender instanceof Player)
|
||||
{
|
||||
if(!entity.getWorld().getPVP())
|
||||
if(!defender.getWorld().getPVP())
|
||||
return;
|
||||
if(Party.getInstance().inSameParty((Player)defender, (Player)attacker))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
Combat.combatChecks(eventb, plugin);
|
||||
Combat.combatChecks(event, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
Entity entity = event.getEntity();
|
||||
EntityType type = entity.getType();
|
||||
DamageCause cause = event.getCause();
|
||||
|
||||
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