Class DamageRequest
java.lang.Object
studio.magemonkey.codex.api.damage.DamageRequest
A description of a hit, written by the plugin that deals it and read by the plugin that calculates it.
Without a request, a plugin handling an EntityDamageEvent can only guess what a call to
damage() was meant to be. A request states it up front. It is handed over through
DamageContexts.
A request is immutable. Build one with builder().
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbooleandoubleadjustWeaponDamage(String type, double amount) Applies this request's scale and bonus to one damage type of the attacker's weapon: the amount is multiplied by the scale, then the bonus is added.static DamageRequest.Builderbuilder()The damage of the hit, by damage type, in the order the amounts were added.org.bukkit.event.entity.EntityDamageEvent.DamageCausegetCause()The cause the dealer wants the damage to have, or null to leave it as Bukkit reports it.What kind of thing deals the damage.org.bukkit.entity.LivingEntityThe entity the damage is attributed to, or null if there is none.doublegetTotal()doubleWhat is added to every damage type of the attacker's weapon, unless a type has its own amount.doublegetWeaponBonus(String type) doubleWhat every damage type of the attacker's weapon is multiplied by, unless a type has its own factor. 1 leaves the weapon's damage as it is.doublegetWeaponScale(String type) How the attacker's equipment should take part in the hit.booleantoString()
-
Method Details
-
builder
-
hasKnockback
public boolean hasKnockback()- Returns:
- whether the hit should knock the target back
-
getWeaponScale
- Parameters:
type- a damage type id of the plugin that calculates the damage, without a namespace- Returns:
- what the weapon's damage of that type is multiplied by
-
getWeaponBonus
- Parameters:
type- a damage type id of the plugin that calculates the damage, without a namespace- Returns:
- what is added to the weapon's damage of that type
-
adjustsWeaponDamage
public boolean adjustsWeaponDamage()- Returns:
- whether this request changes the weapon's damage at all
-
adjustWeaponDamage
Applies this request's scale and bonus to one damage type of the attacker's weapon: the amount is multiplied by the scale, then the bonus is added.A type the weapon does not deal stays at 0, so a bonus never gives a weapon a damage type it does not have. The result can be negative when the bonus is; what to do with that is up to the caller.
This only means something where the weapon's damage is part of the hit, which is
WeaponStatsMode.ADD.- Parameters:
type- the damage type id, without a namespaceamount- the weapon's damage of that type- Returns:
- the adjusted amount
-
getTotal
public double getTotal()- Returns:
- the sum of all amounts
-
getOrigin
What kind of thing deals the damage. -
getSource
@Nullable public org.bukkit.entity.LivingEntity getSource()The entity the damage is attributed to, or null if there is none. -
getCause
@Nullable public org.bukkit.event.entity.EntityDamageEvent.DamageCause getCause()The cause the dealer wants the damage to have, or null to leave it as Bukkit reports it. -
getAmounts
-
getWeaponStats
How the attacker's equipment should take part in the hit. -
getWeaponScale
public double getWeaponScale()What every damage type of the attacker's weapon is multiplied by, unless a type has its own factor. 1 leaves the weapon's damage as it is. SeeadjustWeaponDamage(String, double). -
getWeaponBonus
public double getWeaponBonus()What is added to every damage type of the attacker's weapon, unless a type has its own amount. It may be negative. SeeadjustWeaponDamage(String, double). -
toString
-