From 5b1cf576d64a04250c665bd9606912834714c96b Mon Sep 17 00:00:00 2001 From: david Date: Sat, 31 Aug 2024 15:45:40 +0200 Subject: [PATCH] Fix incorrect flag assignment for entity attack events Adjusted the conditional logic to ensure correct flag assignment when entities attack each other. This fixes a bug where the `entityAttackEntity` flag was not being set properly, potentially causing unwanted behavior in the protection system. --- .../java/net/thenextlvl/protect/listener/EntityListener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/java/net/thenextlvl/protect/listener/EntityListener.java b/plugin/src/main/java/net/thenextlvl/protect/listener/EntityListener.java index 932b24a..8010448 100644 --- a/plugin/src/main/java/net/thenextlvl/protect/listener/EntityListener.java +++ b/plugin/src/main/java/net/thenextlvl/protect/listener/EntityListener.java @@ -53,7 +53,8 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { var area = plugin.areaProvider().getArea(event.getDamager()); var flag = event.getDamager() instanceof Player && event.getEntity() instanceof Player ? plugin.flags.playerAttackPlayer : event.getDamager() instanceof Player - ? plugin.flags.playerAttackEntity : event.getEntity() instanceof Player + ? plugin.flags.playerAttackEntity : !(event.getDamager() instanceof Player) + && event.getEntity() instanceof Player ? plugin.flags.entityAttackPlayer : plugin.flags.entityAttackEntity; event.setCancelled(!area.getFlag(flag)); }