001 package org.bukkit.entity; 002 003 /** 004 * Represents an {@link Entity} that has health and can take damage. 005 */ 006 public interface Damageable extends Entity { 007 /** 008 * Deals the given amount of damage to this entity. 009 * 010 * @param amount Amount of damage to deal 011 */ 012 void damage(double amount); 013 014 /** 015 * This method exists for legacy reasons to provide backwards 016 * compatibility. It will not exist at runtime and should not be used 017 * under any circumstances. 018 */ 019 @Deprecated 020 void _INVALID_damage(int amount); 021 022 /** 023 * Deals the given amount of damage to this entity, from a specified 024 * entity. 025 * 026 * @param amount Amount of damage to deal 027 * @param source Entity which to attribute this damage from 028 */ 029 void damage(double amount, Entity source); 030 031 /** 032 * This method exists for legacy reasons to provide backwards 033 * compatibility. It will not exist at runtime and should not be used 034 * under any circumstances. 035 */ 036 @Deprecated 037 void _INVALID_damage(int amount, Entity source); 038 039 /** 040 * Gets the entity's health from 0 to {@link #getMaxHealth()}, where 0 is dead. 041 * 042 * @return Health represented from 0 to max 043 */ 044 double getHealth(); 045 046 /** 047 * This method exists for legacy reasons to provide backwards 048 * compatibility. It will not exist at runtime and should not be used 049 * under any circumstances. 050 */ 051 @Deprecated 052 int _INVALID_getHealth(); 053 054 /** 055 * Sets the entity's health from 0 to {@link #getMaxHealth()}, where 0 is 056 * dead. 057 * 058 * @param health New health represented from 0 to max 059 * @throws IllegalArgumentException Thrown if the health is < 0 or > 060 * {@link #getMaxHealth()} 061 */ 062 void setHealth(double health); 063 064 /** 065 * This method exists for legacy reasons to provide backwards 066 * compatibility. It will not exist at runtime and should not be used 067 * under any circumstances. 068 */ 069 @Deprecated 070 void _INVALID_setHealth(int health); 071 072 /** 073 * Gets the maximum health this entity has. 074 * 075 * @return Maximum health 076 */ 077 double getMaxHealth(); 078 079 /** 080 * This method exists for legacy reasons to provide backwards 081 * compatibility. It will not exist at runtime and should not be used 082 * under any circumstances. 083 */ 084 @Deprecated 085 int _INVALID_getMaxHealth(); 086 087 /** 088 * Sets the maximum health this entity can have. 089 * <p> 090 * If the health of the entity is above the value provided it will be set 091 * to that value. 092 * <p> 093 * Note: An entity with a health bar ({@link Player}, {@link EnderDragon}, 094 * {@link Wither}, etc...} will have their bar scaled accordingly. 095 * 096 * @param health amount of health to set the maximum to 097 */ 098 void setMaxHealth(double health); 099 100 /** 101 * This method exists for legacy reasons to provide backwards 102 * compatibility. It will not exist at runtime and should not be used 103 * under any circumstances. 104 */ 105 @Deprecated 106 void _INVALID_setMaxHealth(int health); 107 108 /** 109 * Resets the max health to the original amount. 110 */ 111 void resetMaxHealth(); 112 }