public class EntityDamageEvent extends EntityEvent implements Cancellable
限定符和类型 | 类和说明 |
---|---|
static class |
EntityDamageEvent.DamageCause
An enum to specify the cause of the damage
|
static class |
EntityDamageEvent.DamageModifier
已过时。
这个API被废弃了,具体见后面的网址,很快就要被移除了,就不深入解释了.This API is responsible for a large number of implementation
problems and is in general unsustainable to maintain. It is likely to be
removed very soon in a subsequent release. Please see
https://www.spigotmc.org/threads/194446/ for more information.
|
Event.Result
entity
构造器和说明 |
---|
EntityDamageEvent(Entity damagee,
EntityDamageEvent.DamageCause cause,
double damage)
已过时。
|
EntityDamageEvent(Entity damagee,
EntityDamageEvent.DamageCause cause,
java.util.Map<EntityDamageEvent.DamageModifier,java.lang.Double> modifiers,
java.util.Map<EntityDamageEvent.DamageModifier,? extends <any>> modifierFunctions) |
限定符和类型 | 方法和说明 |
---|---|
EntityDamageEvent.DamageCause |
getCause()
Gets the cause of the damage.
|
double |
getDamage()
返回本次事件收到伤害的值
|
double |
getDamage(EntityDamageEvent.DamageModifier type)
返回伤害值
|
double |
getFinalDamage()
返回此次事件最终的伤害值 (经过护甲等的修改)
|
static HandlerList |
getHandlerList() |
HandlerList |
getHandlers() |
double |
getOriginalDamage(EntityDamageEvent.DamageModifier type)
获取指定伤害类型的原始伤害,作为本次事件的结构定义 ?
|
boolean |
isApplicable(EntityDamageEvent.DamageModifier type)
该方法将检查特定的伤害原因是否是本次触发的原因,
例如
setDamage(DamageModifier, double)
将不会抛出 UnsupportedOperationException 异常
EntityDamageEvent.DamageModifier.BASE 总是适用的. |
boolean |
isCancelled()
获取这个事件是否被取消.一个被取消的事件不会在服务器里被执行,但是仍然会传递事件到其他插件。
|
void |
setCancelled(boolean cancel)
取消这个事件.
|
void |
setDamage(double damage)
Sets the raw amount of damage caused by the event.
|
void |
setDamage(EntityDamageEvent.DamageModifier type,
double damage)
设置指定伤害类型的伤害
|
getEntity, getEntityType
getEventName, isAsynchronous
@Deprecated public EntityDamageEvent(Entity damagee, EntityDamageEvent.DamageCause cause, double damage)
public EntityDamageEvent(Entity damagee, EntityDamageEvent.DamageCause cause, java.util.Map<EntityDamageEvent.DamageModifier,java.lang.Double> modifiers, java.util.Map<EntityDamageEvent.DamageModifier,? extends <any>> modifierFunctions)
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
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
- 如果你想取消这个事件,则为truepublic double getOriginalDamage(EntityDamageEvent.DamageModifier type) throws java.lang.IllegalArgumentException
type
- (DamageModifier) 伤害类型type
- the modifierjava.lang.IllegalArgumentException
- 如果参数(DamageModifier)是null时
原文:
Gets the original damage for the specified modifier, as defined at this
event's construction.java.lang.IllegalArgumentException
- if type is nullpublic void setDamage(EntityDamageEvent.DamageModifier type, double damage) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
type
- 伤害类型damage
- 伤害值type
- the damage modifierdamage
- the scalar value of the damage's modifierjava.lang.IllegalArgumentException
- 如果类型是null时java.lang.UnsupportedOperationException
- 如果触发该事件的实体不支持该伤害类型,
或者受到修改,当 isApplicable(DamageModifier)
返回false
原文:
Sets the damage for the specified modifier.java.lang.IllegalArgumentException
- if type is nulljava.lang.UnsupportedOperationException
- if the caller does not support
the particular DamageModifier, or to rephrase, when isApplicable(DamageModifier)
returns falsegetFinalDamage()
,
getFinalDamage()
public double getDamage(EntityDamageEvent.DamageModifier type) throws java.lang.IllegalArgumentException
type
- 伤害类型type
- the damage modifierjava.lang.IllegalArgumentException
- 如果类型是nulljava.lang.IllegalArgumentException
- if type is null原文:
Gets the damage change for some modifier
,
EntityDamageEvent.DamageModifier.BASE
public boolean isApplicable(EntityDamageEvent.DamageModifier type) throws java.lang.IllegalArgumentException
setDamage(DamageModifier, double)
将不会抛出 UnsupportedOperationException
异常
type
- 伤害原因type
- the modifierjava.lang.IllegalArgumentException
- 如何传入的参数是null时
原文:
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.
java.lang.IllegalArgumentException
- if type is nullpublic double getDamage()
原文:
Gets the raw amount of damage caused by the event
,
EntityDamageEvent.DamageModifier.BASE
public final double getFinalDamage()
public void setDamage(double damage)
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 eventpublic EntityDamageEvent.DamageCause getCause()
public HandlerList getHandlers()
getHandlers
在类中 Event
public static HandlerList getHandlerList()