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) Creates an event. -
Method Summary
Modifier and TypeMethodDescriptionfloatfloatdamage()booleanReturnstrueif the action this event describes will not happen.booleanbooleandoubleplayer()Returns the player involved in this event.voidsetCancelled(boolean cancelled) Prevents or re-allows the action this event describes.voidsetDamage(float damage) voidsetKnockback(double knockback) voidsetSweeping(boolean sweeping) target()Returns the entity being hit.
-
Constructor Details
-
PlayerAttackEntityEvent
public PlayerAttackEntityEvent(Player player, Entity target, float damage, double knockback, float attackStrength, boolean critical, boolean sweeping) Creates an event.- Parameters:
player- the attacking playertarget- the entity being hitdamage- the damage about to be dealt, in half-heartsknockback- the horizontal knockback strength about to be appliedattackStrength- the attack cooldown charge of the swingcritical- whether the swing is a critical hitsweeping- whether the swing also hits the entities around the target- Since:
- 0.1.0
-
-
Method Details
-
player
Description copied from interface:PlayerEventReturns the player involved in this event.- Specified by:
playerin interfacePlayerEvent- Returns:
- the player involved in this event
-
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()Description copied from interface:CancellableReturnstrueif the action this event describes will not happen.- Specified by:
isCancelledin interfaceCancellable- Returns:
trueif the action this event describes will not happen
-
setCancelled
public void setCancelled(boolean cancelled) Description copied from interface:CancellablePrevents or re-allows the action this event describes.- Specified by:
setCancelledin interfaceCancellable- Parameters:
cancelled-trueto prevent it
-