mcmonkeyprojects / Sentinel

Combat NPCs for Spigot!
MIT License
165 stars 85 forks source link

Damage of players in creative ignored #398

Closed DavideBlade closed 8 months ago

DavideBlade commented 8 months ago

The output of command /version on my server is: This server is running CraftBukkit version 4019-Spigot-864e4ac-c8b4da8 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) The output of command /version citizens on my server is: Citizens version 2.0.33-SNAPSHOT (build 3301) The output of command /version sentinel on my server is: Sentinel version 2.8.1-SNAPSHOT (build 513) A pastebin.com link to my (full!) Sentinel/config.yml file is: https://pastebin.com/H2sQjryi


NPCs do not receive damage from players in creative. This is not the default behavior on Minecraft, is not specified in Sentinel's documentation, and is not configurable in any way.

I'll leave it to you to consider whether this is intended behavior or not, but it certainly deserves a note in the documentation. In my case, I spent hours trying to figure out where the problem was in my code since I couldn't hit NPCs: actually, the problem was just due to this unexpected behavior.

The problem originates from SentinelTrait#whenAttacksHappened(), which cancels EntityDamageByEntityEvent if the attacker is ignored (SentinelTargetingHelper#isIgnored()), but not because it is added to the ignored list, but rather because it cannot be targeted by the NPC. In fact, SentinelTargetingHelper#isIgnored() invokes TargetingHelper#isUntargetable() which returns true in case the player is in creative mode.

Link to section of the saves.yml file: https://pastebin.com/1tRuG5pr

mcmonkey4eva commented 8 months ago

Support is mostly on Discord now - https://discord.gg/Q6pZGSR

Protected mode is listed in the readme and easily toggleable /sentinel protected ['true'/'false'] - Toggles whether the NPC is protected from damage by ignore targets.