Class PlayerAttackEntityEvent
java.lang.Object
fr.fidorial.event.player.PlayerAttackEntityEvent
- All Implemented Interfaces:
Cancellable, Event, PlayerEvent
Fired when a player swings at an entity, before any damage is applied.
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerAttackEntityEvent(Player player, Entity target, float damage, double knockback, float attackStrength, boolean critical, boolean sweeping) -
Method Summary
Modifier and TypeMethodDescriptionfloatfloatdamage()booleanbooleanbooleandoubleplayer()voidsetCancelled(boolean cancelled) voidsetDamage(float damage) voidsetKnockback(double knockback) voidsetSweeping(boolean sweeping) target()
-
Constructor Details
-
PlayerAttackEntityEvent
-
-
Method Details
-
player
- Specified by:
playerin interfacePlayerEvent
-
target
-
damage
public float damage()- Returns:
- the damage about to be dealt, in half-hearts, critical already applied
-
setDamage
public void setDamage(float damage) - Parameters:
damage- the damage to deal instead;<= 0makes the hit harmless
-
knockback
public double knockback()- Returns:
- the horizontal knockback strength about to be applied
-
setKnockback
public void setKnockback(double knockback) - Parameters:
knockback- the knockback strength to apply instead;0disables it
-
attackStrength
public float attackStrength()- Returns:
- the attack cooldown charge of this swing, between
0.2and1
-
isCritical
public boolean isCritical()- Returns:
truewhen this swing landed as a critical hit
-
isSweeping
public boolean isSweeping()- Returns:
truewhen this swing also hits the entities around the target
-
setSweeping
public void setSweeping(boolean sweeping) - Parameters:
sweeping-falseto keep the hit on the primary target only
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceCancellable
-
setCancelled
public void setCancelled(boolean cancelled) - Specified by:
setCancelledin interfaceCancellable
-