22
33import org .bukkit .attribute .Attribute ;
44import org .bukkit .damage .DamageSource ;
5- import org .jetbrains .annotations .NotNull ;
6- import org .jetbrains .annotations .Nullable ;
5+ import org .bukkit .damage .DamageType ;
6+ import org .bukkit .event .entity .EntityRegainHealthEvent ;
7+ import org .jspecify .annotations .NullMarked ;
8+ import org .jspecify .annotations .Nullable ;
79
810/**
911 * Represents an {@link Entity} that has health and can take damage.
1012 */
13+ @ NullMarked
1114public interface Damageable extends Entity {
1215 /**
1316 * Deals the given amount of damage to this entity.
@@ -32,7 +35,24 @@ public interface Damageable extends Entity {
3235 * @param amount amount of damage to deal
3336 * @param damageSource source to which the damage should be attributed
3437 */
35- void damage (double amount , @ NotNull DamageSource damageSource );
38+ void damage (double amount , DamageSource damageSource );
39+
40+ /**
41+ * Sets the entity's health to 0 and kill the entity with a generic DamageSource.
42+ *
43+ * @throws IllegalStateException if is used in world generation
44+ */
45+ default void kill () {
46+ this .kill (DamageSource .builder (DamageType .GENERIC_KILL ).build ());
47+ }
48+
49+ /**
50+ * Sets the entity's health to 0 and kill the entity with the specified DamageSource.
51+ *
52+ * @param damageSource the DamageSource to use for the kill
53+ * @throws IllegalStateException if is used in world generation
54+ */
55+ void kill (DamageSource damageSource );
3656
3757 /**
3858 * Gets the entity's health from 0 to {@link #getMaxHealth()}, where 0 is dead.
@@ -57,7 +77,7 @@ public interface Damageable extends Entity {
5777 * @param amount heal amount
5878 */
5979 default void heal (final double amount ) {
60- this .heal (amount , org . bukkit . event . entity . EntityRegainHealthEvent .RegainReason .CUSTOM );
80+ this .heal (amount , EntityRegainHealthEvent .RegainReason .CUSTOM );
6181 }
6282
6383 /**
@@ -66,7 +86,7 @@ default void heal(final double amount) {
6686 * @param amount heal amount
6787 * @param reason heal reason
6888 */
69- void heal (double amount , @ NotNull org . bukkit . event . entity . EntityRegainHealthEvent .RegainReason reason );
89+ void heal (double amount , EntityRegainHealthEvent .RegainReason reason );
7090
7191 /**
7292 * Gets the entity's absorption amount.
0 commit comments