Make sure we only listen to direct attacks and no other types of

damage
This commit is contained in:
Evenprime 2011-11-13 22:13:24 +01:00
parent 17dac93056
commit cfd8661f3f
2 changed files with 5 additions and 2 deletions

View File

@ -111,7 +111,7 @@ public class CheckUtil {
public static final boolean isSprinting(final Player player) {
return !(player instanceof CraftPlayer) || (player.isSprinting() && player.getFoodLevel() > 5);
return !(player.isSprinting() && player.getFoodLevel() > 5);
}
/**

View File

@ -14,6 +14,7 @@ import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerChatEvent;
@ -254,7 +255,8 @@ public abstract class EventManager {
final EntityDamageByEntityEvent event2 = (EntityDamageByEntityEvent) event;
if(!(event2.getDamager() instanceof Player))
// Only if player really attacked other player
if(!(event2.getDamager() instanceof Player) || !event2.getCause().equals(DamageCause.ENTITY_ATTACK))
return;
/** Only now measure time and dispatch event */
@ -288,6 +290,7 @@ public abstract class EventManager {
case PLAYER:
Bukkit.getServer().getPluginManager().registerEvent(type, new PlayerL(this, priority, ignoreCancelled, performance), priority, plugin);
break;
case LIVING_ENTITY:
case ENTITY:
Bukkit.getServer().getPluginManager().registerEvent(type, new EntityL(this, priority, ignoreCancelled, performance), priority, plugin);
break;