程序包 org.bukkit.event.entity

# 类 EntityDamageEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.entity.EntityEvent
org.bukkit.event.entity.EntityDamageEvent

所有已实现的接口:
  `Cancellable`

直接已知子类:
  `EntityDamageByBlockEvent`, `EntityDamageByEntityEvent`

public class EntityDamageEvent extends EntityEvent implements Cancellable
储存伤害事件的数据

- ## 嵌套类概要

  嵌套类
  修饰符和类型
  类
  说明
  `static enum`
  `EntityDamageEvent.DamageCause`
  造成伤害的原因.
  `static enum`
  `EntityDamageEvent.DamageModifier`
  已过时。
  这个API被废弃了，具体见后面的网址，很快就要被移除了，就不深入解释了.This API is responsible for a large number of implementation problems and is in general unsustainable to maintain.

  ## 从类继承的嵌套类/接口 org.bukkit.event.Event

  `Event.Result`

- ## 字段概要

  ### 从类继承的字段 org.bukkit.event.entity.EntityEvent

  `entity`

- ## 构造器概要

  构造器
  构造器
  说明
  `EntityDamageEvent(@NotNull Entity damagee, @NotNull EntityDamageEvent.DamageCause cause, double damage)`
  已过时, 待删除: 此 API 元素将从以后的版本中删除。
  `EntityDamageEvent(@NotNull Entity damagee, @NotNull EntityDamageEvent.DamageCause cause, @NotNull Map<EntityDamageEvent.DamageModifier,Double> modifiers, @NotNull Map<EntityDamageEvent.DamageModifier,? extends Function<? super Double,Double>> modifierFunctions)`
  已过时, 待删除: 此 API 元素将从以后的版本中删除。
  `EntityDamageEvent(@NotNull Entity damagee, @NotNull EntityDamageEvent.DamageCause cause, @NotNull DamageSource damageSource, double damage)`
  `EntityDamageEvent(@NotNull Entity damagee, @NotNull EntityDamageEvent.DamageCause cause, @NotNull DamageSource damageSource, @NotNull Map<EntityDamageEvent.DamageModifier,Double> modifiers, @NotNull Map<EntityDamageEvent.DamageModifier,? extends Function<? super Double,Double>> modifierFunctions)`

- ## 方法概要

  修饰符和类型
  方法
  说明
  `@NotNull EntityDamageEvent.DamageCause`
  `getCause()`
  Gets the cause of the damage.
  `double`
  `getDamage()`
  返回本次事件收到伤害的值.
  `double`
  `getDamage(@NotNull EntityDamageEvent.DamageModifier type)`
  通过特定修饰符返回伤害值.
  `@NotNull DamageSource`
  `getDamageSource()`
  Get the source of damage.
  `final double`
  `getFinalDamage()`
  返回此次事件最终的伤害值 (经过护甲等的修改).
  `static @NotNull HandlerList`
  `getHandlerList()`
  `@NotNull HandlerList`
  `getHandlers()`
  `double`
  `getOriginalDamage(@NotNull EntityDamageEvent.DamageModifier type)`
  获取指定伤害类型的原始伤害,作为本次事件的结构定义 .
  `boolean`
  `isApplicable(@NotNull EntityDamageEvent.DamageModifier type)`
  该方法将检查特定的伤害原因是否是本次触发的原因, 例如 `setDamage(DamageModifier, double)` 将不会抛出 `UnsupportedOperationException` 异常
  `boolean`
  `isCancelled()`
  获取这个事件是否被取消.一个被取消的事件不会在服务器里执行，但是仍然会传递事件到其他插件.
  `void`
  `setCancelled(boolean cancel)`
  取消这个事件.
  `void`
  `setDamage(double damage)`
  Sets the raw amount of damage caused by the event.
  `void`
  `setDamage(@NotNull EntityDamageEvent.DamageModifier type, double damage)`
  设置指定伤害类型的伤害.

  ### 从类继承的方法 org.bukkit.event.entity.EntityEvent

  `getEntity, getEntityType`

  ### 从类继承的方法 org.bukkit.event.Event

  `getEventName, isAsynchronous`

  ### 从类继承的方法 java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 构造器详细资料

  - ### EntityDamageEvent

    @Deprecated(forRemoval=true) public EntityDamageEvent(@NotNull @NotNull Entity damagee, @NotNull @NotNull EntityDamageEvent.DamageCause cause, double damage)
    已过时, 待删除: 此 API 元素将从以后的版本中删除。

  - ### EntityDamageEvent

    public EntityDamageEvent(@NotNull @NotNull Entity damagee, @NotNull @NotNull EntityDamageEvent.DamageCause cause, @NotNull @NotNull DamageSource damageSource, double damage)

  - ### EntityDamageEvent

    @Deprecated(forRemoval=true) public EntityDamageEvent(@NotNull @NotNull Entity damagee, @NotNull @NotNull EntityDamageEvent.DamageCause cause, @NotNull @NotNull Map<EntityDamageEvent.DamageModifier,Double> modifiers, @NotNull @NotNull Map<EntityDamageEvent.DamageModifier,? extends Function<? super Double,Double>> modifierFunctions)
    已过时, 待删除: 此 API 元素将从以后的版本中删除。

  - ### EntityDamageEvent

    public EntityDamageEvent(@NotNull @NotNull Entity damagee, @NotNull @NotNull EntityDamageEvent.DamageCause cause, @NotNull @NotNull DamageSource damageSource, @NotNull @NotNull Map<EntityDamageEvent.DamageModifier,Double> modifiers, @NotNull @NotNull Map<EntityDamageEvent.DamageModifier,? extends Function<? super Double,Double>> modifierFunctions)

- ## 方法详细资料

  - ### isCancelled

    public boolean isCancelled()
    从接口复制的说明: `Cancellable`
    获取这个事件是否被取消.一个被取消的事件不会在服务器里执行，但是仍然会传递事件到其他插件.

    原文：Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins

    指定者:
      `isCancelled` 在接口中 `Cancellable`
    返回:
      如果事件已经被取消，则为true

  - ### setCancelled

    public void setCancelled(boolean cancel)
    从接口复制的说明: `Cancellable`
    取消这个事件. 一个被取消的事件不会在 服务器里执行，但是仍然会传递事件到其他插件.

    原文：Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.

    指定者:
      `setCancelled` 在接口中 `Cancellable`
    参数:
      `cancel` - 如果你想取消这个事件，则为true

  - ### getOriginalDamage

    public double getOriginalDamage(@NotNull @NotNull EntityDamageEvent.DamageModifier type) throws IllegalArgumentException
    获取指定伤害类型的原始伤害,作为本次事件的结构定义 .

    原文:Gets the original damage for the specified modifier, as defined at this event's construction.

    参数:
      `type` - (DamageModifier) 伤害类型
    返回:
      原始伤害
    抛出:
      `IllegalArgumentException` - 如果参数(DamageModifier)是null时

  - ### setDamage

    public void setDamage(@NotNull @NotNull EntityDamageEvent.DamageModifier type, double damage) throws IllegalArgumentException, UnsupportedOperationException
    设置指定伤害类型的伤害.

    原文:Sets the damage for the specified modifier.

    参数:
      `type` - 伤害类型
      `damage` - 伤害值
    抛出:
      `IllegalArgumentException` - 如果类型是null时
      `UnsupportedOperationException` - 如果触发该事件的实体不支持该伤害类型, 或者受到修改,当 `isApplicable(DamageModifier)` 返回false
    另请参阅:
      - `getFinalDamage()`

  - ### getDamage

    public double getDamage(@NotNull @NotNull EntityDamageEvent.DamageModifier type) throws IllegalArgumentException
    通过特定修饰符返回伤害值.

    原文:Gets the damage change for some modifier

    参数:
      `type` - 伤害类型
    返回:
      引起该事件的原始伤害
    抛出:
      `IllegalArgumentException` - 如果类型是null
    另请参阅:
      - `EntityDamageEvent.DamageModifier.BASE`

  - ### isApplicable

    public boolean isApplicable(@NotNull @NotNull EntityDamageEvent.DamageModifier type) throws IllegalArgumentException
    该方法将检查特定的伤害原因是否是本次触发的原因, 例如 `setDamage(DamageModifier, double)` 将不会抛出 `UnsupportedOperationException` 异常

    `EntityDamageEvent.DamageModifier.BASE` 总是适用的.

    原文:This checks to see if a particular modifier is valid for this event's caller, such that, `setDamage(DamageModifier, double)` will not throw an `UnsupportedOperationException`.

    `EntityDamageEvent.DamageModifier.BASE` is always applicable.

    参数:
      `type` - 伤害原因
    返回:
      当伤害原因与事件触发的原因相同时返回true 反之返回false
    抛出:
      `IllegalArgumentException` - 如何传入的参数是null时

  - ### getDamage

    public double getDamage()
    返回本次事件收到伤害的值.

    原文:Gets the raw amount of damage caused by the event

    返回:
      一个没有进过别的处理的 伤害值
    另请参阅:
      - `EntityDamageEvent.DamageModifier.BASE`

  - ### getFinalDamage

    public final double getFinalDamage()
    返回此次事件最终的伤害值 (经过护甲等的修改).

    原文:Gets the amount of damage caused by the event after all damage reduction is applied.

    返回:
      此次事件最终的伤害值

  - ### setDamage

    public void setDamage(double damage)
    Sets the raw amount of damage caused by the event.

    For compatibility this also recalculates the modifiers and scales them by the difference between the modifier for the previous damage value and the new one.

    参数:
      `damage` - The raw amount of damage caused by the event

  - ### getCause

    @NotNull public @NotNull EntityDamageEvent.DamageCause getCause()
    Gets the cause of the damage.

    While a DamageCause may indicate a specific Bukkit-assigned cause of damage, `getDamageSource()` may expose additional types of damage such as custom damage types provided by data packs, as well as any direct or indirect entities, locations, or other contributing factors to the damage being inflicted. The alternative is generally preferred, but DamageCauses provided to this event should largely encompass most common use cases for developers if a simple cause is required.

    返回:
      a DamageCause value detailing the cause of the damage.

  - ### getDamageSource

    @NotNull public @NotNull DamageSource getDamageSource()
    Get the source of damage.
    返回:
      a DamageSource detailing the source of the damage.

  - ### getHandlers

    @NotNull public @NotNull HandlerList getHandlers()
    指定者:
      `getHandlers` 在类中 `Event`

  - ### getHandlerList

    @NotNull public static @NotNull HandlerList getHandlerList()