mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-02 22:07:50 +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) {
|
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.block.BlockPlaceEvent;
|
||||||
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.EntityListener;
|
import org.bukkit.event.entity.EntityListener;
|
||||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
@ -254,7 +255,8 @@ public abstract class EventManager {
|
|||||||
|
|
||||||
final EntityDamageByEntityEvent event2 = (EntityDamageByEntityEvent) event;
|
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;
|
return;
|
||||||
|
|
||||||
/** Only now measure time and dispatch event */
|
/** Only now measure time and dispatch event */
|
||||||
@ -288,6 +290,7 @@ public abstract class EventManager {
|
|||||||
case PLAYER:
|
case PLAYER:
|
||||||
Bukkit.getServer().getPluginManager().registerEvent(type, new PlayerL(this, priority, ignoreCancelled, performance), priority, plugin);
|
Bukkit.getServer().getPluginManager().registerEvent(type, new PlayerL(this, priority, ignoreCancelled, performance), priority, plugin);
|
||||||
break;
|
break;
|
||||||
|
case LIVING_ENTITY:
|
||||||
case ENTITY:
|
case ENTITY:
|
||||||
Bukkit.getServer().getPluginManager().registerEvent(type, new EntityL(this, priority, ignoreCancelled, performance), priority, plugin);
|
Bukkit.getServer().getPluginManager().registerEvent(type, new EntityL(this, priority, ignoreCancelled, performance), priority, plugin);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user