Package de.eimmer.ereignis.wesen
Class WesenBeschaedigeEreignis
java.lang.Object
de.eimmer.ereignis.Ereignis
de.eimmer.ereignis.wesen.WesenEreignis
de.eimmer.ereignis.wesen.WesenBeschaedigeEreignis
- All Implemented Interfaces:
Abbrechbar
- Direct Known Subclasses:
WesenBeschaedigeDurchBlockEreignis
,WesenBeschaedigeDurchWesenEreignis
Stores data for damage events
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
An enum to specify the cause of the damagestatic enum
Deprecated.This API is responsible for a large number of implementation problems and is in general unsustainable to maintain.Nested classes/interfaces inherited from class de.eimmer.ereignis.Ereignis
Ereignis.Result
-
Field Summary
Fields inherited from class de.eimmer.ereignis.wesen.WesenEreignis
wesen
-
Constructor Summary
ConstructorsConstructorDescriptionWesenBeschaedigeEreignis
(Wesen damagee, WesenBeschaedigeEreignis.DamageCause cause, double damage) WesenBeschaedigeEreignis
(Wesen damagee, WesenBeschaedigeEreignis.DamageCause cause, Map<WesenBeschaedigeEreignis.DamageModifier, Double> modifiers, Map<WesenBeschaedigeEreignis.DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) -
Method Summary
Modifier and TypeMethodDescriptiongetCause()
Gets the cause of the damage.double
Gets the raw amount of damage caused by the ereignisdouble
Gets the damage change for some modifierfinal double
Gets the amount of damage caused by the ereignis after all damage reduction is applied.static HandhaberListe
double
Gets the original damage for the specified modifier, as defined at this ereignis's construction.boolean
This checks to see if a particular modifier is valid for this ereignis's caller, such that,setDamage(DamageModifier, double)
will not throw anUnsupportedOperationException
.boolean
Gets the cancellation state of this ereignis.void
setCancelled
(boolean cancel) Sets the cancellation state of this ereignis.void
setDamage
(double damage) Sets the raw amount of damage caused by the ereignis.void
setDamage
(WesenBeschaedigeEreignis.DamageModifier type, double damage) Sets the damage for the specified modifier.Methods inherited from class de.eimmer.ereignis.wesen.WesenEreignis
getEntity, getEntityType
Methods inherited from class de.eimmer.ereignis.Ereignis
getEventName, isAsynchronous
-
Constructor Details
-
WesenBeschaedigeEreignis
public WesenBeschaedigeEreignis(@NotNull Wesen damagee, @NotNull WesenBeschaedigeEreignis.DamageCause cause, double damage) -
WesenBeschaedigeEreignis
public WesenBeschaedigeEreignis(@NotNull Wesen damagee, @NotNull WesenBeschaedigeEreignis.DamageCause cause, @NotNull Map<WesenBeschaedigeEreignis.DamageModifier, Double> modifiers, @NotNull Map<WesenBeschaedigeEreignis.DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions)
-
-
Method Details
-
isCancelled
public boolean isCancelled()Description copied from interface:Abbrechbar
Gets the cancellation state of this ereignis. A cancelled ereignis will not be executed in the server, but will still pass to other plugins- Specified by:
isCancelled
in interfaceAbbrechbar
- Returns:
- true if this ereignis is cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:Abbrechbar
Sets the cancellation state of this ereignis. A cancelled ereignis will not be executed in the server, but will still pass to other plugins.- Specified by:
setCancelled
in interfaceAbbrechbar
- Parameters:
cancel
- true if you wish to cancel this ereignis
-
getOriginalDamage
public double getOriginalDamage(@NotNull WesenBeschaedigeEreignis.DamageModifier type) throws IllegalArgumentException Gets the original damage for the specified modifier, as defined at this ereignis's construction.- Parameters:
type
- the modifier- Returns:
- the original damage
- Throws:
IllegalArgumentException
- if type is null
-
setDamage
public void setDamage(@NotNull WesenBeschaedigeEreignis.DamageModifier type, double damage) throws IllegalArgumentException, UnsupportedOperationException Sets the damage for the specified modifier.- Parameters:
type
- the damage modifierdamage
- the scalar value of the damage's modifier- Throws:
IllegalArgumentException
- if type is nullUnsupportedOperationException
- if the caller does not support the particular DamageModifier, or to rephrase, whenisApplicable(DamageModifier)
returns false- See Also:
-
getDamage
public double getDamage(@NotNull WesenBeschaedigeEreignis.DamageModifier type) throws IllegalArgumentException Gets the damage change for some modifier- Parameters:
type
- the damage modifier- Returns:
- The raw amount of damage caused by the ereignis
- Throws:
IllegalArgumentException
- if type is null- See Also:
-
isApplicable
public boolean isApplicable(@NotNull WesenBeschaedigeEreignis.DamageModifier type) throws IllegalArgumentException This checks to see if a particular modifier is valid for this ereignis's caller, such that,setDamage(DamageModifier, double)
will not throw anUnsupportedOperationException
.WesenBeschaedigeEreignis.DamageModifier.BASE
is always applicable.- Parameters:
type
- the modifier- Returns:
- true if the modifier is supported by the caller, false otherwise
- Throws:
IllegalArgumentException
- if type is null
-
getDamage
public double getDamage()Gets the raw amount of damage caused by the ereignis- Returns:
- The raw amount of damage caused by the ereignis
- See Also:
-
getFinalDamage
public final double getFinalDamage()Gets the amount of damage caused by the ereignis after all damage reduction is applied.- Returns:
- the amount of damage caused by the ereignis
-
setDamage
public void setDamage(double damage) Sets the raw amount of damage caused by the ereignis.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.
- Parameters:
damage
- The raw amount of damage caused by the ereignis
-
getCause
Gets the cause of the damage.- Returns:
- A DamageCause value detailing the cause of the damage.
-
getHandlers
- Specified by:
getHandlers
in classEreignis
-
getHandlerList
-