类 EntityDamageEvent
- 所有已实现的接口:
Cancellable
-
嵌套类概要
修饰符和类型类说明static enum
造成伤害的原因.static enum
已过时。这个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) -
方法概要
修饰符和类型方法说明getCause()
Gets the cause of the damage.double
返回本次事件收到伤害的值.double
通过特定修饰符返回伤害值.Get the source of damage.final double
返回此次事件最终的伤害值 (经过护甲等的修改).static @NotNull HandlerList
double
获取指定伤害类型的原始伤害,作为本次事件的结构定义 .boolean
该方法将检查特定的伤害原因是否是本次触发的原因, 例如setDamage(DamageModifier, double)
将不会抛出UnsupportedOperationException
异常boolean
获取这个事件是否被取消.一个被取消的事件不会在服务器里执行,但是仍然会传递事件到其他插件.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
-
构造器详细资料
-
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- 另请参阅:
-
getDamage
public double getDamage(@NotNull @NotNull EntityDamageEvent.DamageModifier type) throws IllegalArgumentException 通过特定修饰符返回伤害值.原文:Gets the damage change for some modifier
- 参数:
type
- 伤害类型- 返回:
- 引起该事件的原始伤害
- 抛出:
IllegalArgumentException
- 如果类型是null- 另请参阅:
-
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 anUnsupportedOperationException
.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
- 返回:
- 一个没有进过别的处理的 伤害值
- 另请参阅:
-
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
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
Get the source of damage.- 返回:
- a DamageSource detailing the source of the damage.
-
getHandlers
- 指定者:
getHandlers
在类中Event
-
getHandlerList
-