mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-30 20:37:52 +01:00
Make sure we only listen to direct attacks and no other types of
damage
This commit is contained in:
parent
17dac93056
commit
cfd8661f3f
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user