-
-
Notifications
You must be signed in to change notification settings - Fork 980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix /kill
behaving differently to /minecraft:kill
#5850
base: 2.x
Are you sure you want to change the base?
Conversation
…le)` Using Float.MAX_VALUE as that is what `/minecraft:kill` uses Fixes EssentialsX#5842
I thought it intentionally was different to vanilla behavior - this change would also break /kill bypassing god mode iirc |
Thanks for pointing that out, it does indeed break when in god mode. If older versions had a damage cause, could just use that but doesn't seem they do. Other solution I can think of is to check for |
- Remove phantom EntityDamageEvent - Check if `/kill` command used by checking if `getDamage() == Float.MAX_VALUE`
Unlike Here's how another plugin implemented this fix: ChanceSD/PvPManager@aa358e9 In general, the condition vanilla Minecraft uses to check if an invulnerable player should be damaged is whether the source damage type is in the Might want to apply this to |
@@ -29,12 +28,7 @@ protected void updatePlayer(final Server server, final CommandSource sender, fin | |||
if (sender.isPlayer() && user.isAuthorized("essentials.kill.exempt") && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.kill.force")) { | |||
throw new PlayerExemptException("killExempt", matchPlayer.getDisplayName()); | |||
} | |||
final EntityDamageEvent ede = ess.getDamageEventProvider().callDamageEvent(matchPlayer, sender.isPlayer() && sender.getPlayer().getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, Float.MAX_VALUE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the damage sources here and all the cancellation and permission checks below definitely isn't the way to go. Please see my previous comment on the PR.
Thanks for sharing! I did miss those things. I wonder how legacy versions of MC implemented the vanilla kill command to account for invulnerability 🤔. Might take a look at that. I'm sorry I haven't addressed this earlier, have been absolutely battered at work recently. |
It seems that all Minecraft versions use a damage source from 1.8 onwards to account for invulnerability. Just to satisfy my curiosity and also to get back into touch with plugin dev and nms work I decided to make a version agnostic simple kill command (basically just suicide) @ https://github.com/zp4rker/bukkitplayground/blob/kill_command/src/main/java/com/zp4rker/bukkitplayground/commands/CmdKill.java (warning: it's a little messy. Tested on Paper 1.8-1.21, haven't tested on Spigot yet but in theory should work) I could probably implement this into a reflection provider but I don't know if I'm missing some better way to do this. |
Information
This PR fixes #5842.
Details
Proposed fix:
Damageable#setHealth(double)
/minecraft:kill
usesEnvironments tested:
OS: Windows 11
Java version: Corretto-21.0.3.9.1
Demonstration:
Triggers
minecraft:entity_hurt_player
which was previously not being triggered as mentioned in #5842