Provide cleaner way to damage/kill Player #10538
Replies: 5 comments
-
Probably this improvement can also help with fixing Updated-NoCheatPlus/NoCheatPlus#185 |
Beta Was this translation helpful? Give feedback.
-
Currently the API not have a easy method for convert the EntityDamageEvent.DamageCause to the NMS DamageSource used in Damagable#damage.. and the DamageCause/DamageSource can use Block or Entity... maybe can work a damage method like setLastDamageCause ex: about Damagable#setHealth(0) in upstream the logic is if you set this in 0 then run a die with generic DamageSource |
Beta Was this translation helpful? Give feedback.
-
I think this PR was supposed to cover this #5191 |
Beta Was this translation helpful? Give feedback.
-
nice (looks this PR not handle damage by blocks only entity) but the PR looks only need rebase? |
Beta Was this translation helpful? Give feedback.
-
I think this is now resolved with upstream's new API thing. |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem?
Currently, we cannot kill Player with certain Damage Cause.
There is workaround for 'damaging'(not killing) player like this:
But this doesn't applied if you want to 'kill' player because what actually kills the player is
player.setHealth(0);
. This will just print `Player died', not other death message like 'Player drowned', 'Player suffocated' etc.Describe the solution you'd like.
Provide method like
Player#damage(double damage, DamageCause cause)
.This method will damage the player with damage cause provided, or if the damage is higher than Player's current health, it will kill the player with privided damage cause.
I think this would be more fit to
Damagable
as it hassetHealth(double health)
method, but I'm not sure that whether it would be useful or not to damage living entities other than Player. If it is,Damagable#damage(double damage, DamageCause cause)
would be what I suggest.Describe alternatives you've considered.
I currently cannot think of alternative way of this. If you have, please let me know about it.
Other
If you think 'Oh, that could be done with this simple code! No need to add complexity to API!', let me know about that code.
I think using
Player#damage(damage, cause)
would be much cleaner than using multiple event listener, hashset etc.Beta Was this translation helpful? Give feedback.
All reactions