Class PlayerCustomKnockbackEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
de.marcely.bedwars.api.event.player.PlayerCustomKnockbackEvent
All Implemented Interfaces:
ArenaEvent

public class PlayerCustomKnockbackEvent extends PlayerEvent implements ArenaEvent
Gets called when a player gets hurt and therefore receives a custom knockback.
  • Constructor Details

    • PlayerCustomKnockbackEvent

      public PlayerCustomKnockbackEvent(Player player, Arena arena, Entity damager, boolean hitSelf, float damageMultiplier, float addKnockbackY, float multiplierKnockbackY, float multiplierKnockbackXZ, float maxVelocityY, float maxVelocityXZ)
  • Method Details

    • getArena

      public Arena getArena()
      Get the arena in which the player is currently in.
      Specified by:
      getArena in interface ArenaEvent
      Returns:
      The arena that is involved in this event
    • getDamager

      public Entity getDamager()
      Get the entity that caused the knockback.

      This may e.g. be the fireball that hit the player, or a player that hit the player.

      Returns:
      The entity that caused the knockback
    • isHitSelf

      public boolean isHitSelf()
      Check if the player hit themselves.

      A player can hit themselve with e.g. a fireball, or if one of their companions (i.a. own arrow) hits them.

      Returns:
      true if the player hit themselves, false otherwise
    • getDamageMultiplier

      public float getDamageMultiplier()
      Get the damage multiplier that is being applied to the player as a result of the damage.

      It uses the formula finalDamage = originalDamage * damageMultiplier. Therefore, set it to 1.0f to keep the vanilla damage.

      Returns:
      The damage multiplier
    • setDamageMultiplier

      public void setDamageMultiplier(float damageMultiplier)
      Set the damage multiplier that is being applied to the player as a result of the damage.

      It uses the formula finalDamage = originalDamage * damageMultiplier. Therefore, set it to 1.0f to keep the vanilla damage.

      Parameters:
      damageMultiplier - The new damage multiplier
    • getAddKnockbackY

      public float getAddKnockbackY()
      Get the knockback that is being added (addition) to the player's current Y velocity.
      Returns:
      The added Y velocity
    • getMultiplierKnockbackY

      public float getMultiplierKnockbackY()
      Get the knockback that is being multiplied with the player's current Y velocity.
      Returns:
      The new multiplier for the Y velocity
    • getMultiplierKnockbackXZ

      public float getMultiplierKnockbackXZ()
      Get the knockback that is being multiplied with the player's current XZ velocity.
      Returns:
      The new multiplier for the XZ velocities
    • getMaxVelocityY

      public float getMaxVelocityY()
      Get the maximum Y velocity that is being applied to the player.

      The result of getAddKnockbackY() and getMultiplierKnockbackY() will never exceed this value.

      Returns:
      The maximum Y velocity
    • getMaxVelocityXZ

      public float getMaxVelocityXZ()
      Get the maximum XZ velocity that is being applied to the player.

      The result of getMultiplierKnockbackXZ() will never exceed this value.

      Returns:
      The maximum XZ velocity
    • setKnockback

      public void setKnockback(float addKnockbackY, float multiplierKnockbackY, float multiplierKnockbackXZ)
      Set the velocity modifications that are being applied to the player.
      Parameters:
      addKnockbackY - The added Y velocity
      multiplierKnockbackY - The new multiplier for the Y velocity
      multiplierKnockbackXZ - The new multiplier for the XZ velocities
      See Also:
    • setVanillaKnockback

      public void setVanillaKnockback()
      Set the knockback to the vanilla values.

      This means no additional Y velocity, and no multipliers for the XZ and Y velocities. As a result, MBedwars will not modify the knockback at all.

      See Also:
    • setMaxVelocity

      public void setMaxVelocity(float maxVeloY, float maxVeloXZ)
      Set the maximum velocities that are being applied to the player.
      Parameters:
      maxVeloY - The maximum Y velocity
      maxVeloXZ - The maximum XZ velocity
      See Also:
    • setNoMaxVelocity

      public void setNoMaxVelocity()
      Removes the max velocities a player may get applied.

      This means that players may receive uncapped knockback velocities.

      See Also:
    • getHandlers

      public HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      public static HandlerList getHandlerList()