java.lang.Object
org.bukkit.event.Event
org.bukkit.event.entity.EntityEvent
me.deecaad.weaponmechanics.weapon.weaponevents.WeaponEvent
Direct Known Subclasses:
PrepareWeaponShootEvent, ProjectileEvent, WeaponDamageEntityEvent, WeaponEquipEvent, WeaponFirearmEvent, WeaponFullAutoEvent, WeaponGenerateEvent, WeaponKillEntityEvent, WeaponMeleeHitEvent, WeaponMeleeMissEvent, WeaponPostShootEvent, WeaponPreReloadEvent, WeaponPreShootEvent, WeaponRecoilEvent, WeaponReloadCancelEvent, WeaponReloadCompleteEvent, WeaponReloadEvent, WeaponScopeEvent, WeaponSelectiveFireChangeEvent, WeaponShootEvent, WeaponSkinEvent, WeaponStopShootingEvent

public abstract class WeaponEvent extends org.bukkit.event.entity.EntityEvent
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final String
     

    Fields inherited from class org.bukkit.event.entity.EntityEvent

    entity
  • Constructor Summary

    Constructors
    Constructor
    Description
    WeaponEvent(String weaponTitle, org.bukkit.inventory.ItemStack weaponStack, org.bukkit.entity.LivingEntity shooter, org.bukkit.inventory.EquipmentSlot hand)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.inventory.EquipmentSlot
    Returns the hand involved in the event.
    getHandData(boolean noAutoAdd)
    Helper method to the HandData involved in this event.
    org.bukkit.entity.LivingEntity
    Returns the shooter involved in this event.
    getShooterWrapper(boolean noAutoAdd)
     
    org.bukkit.inventory.ItemStack
    Returns the weapon item which caused the event.
    Returns the weapon-title associated with the weapon involved.
    boolean
    Returns true if the weapon involved in this event was in the main hand.
    boolean
    Returns false if the weapon involved in this event was in the main hand.

    Methods inherited from class org.bukkit.event.entity.EntityEvent

    getEntity, getEntityType

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, getHandlers, isAsynchronous

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • weaponTitle

      protected final String weaponTitle
  • Constructor Details

    • WeaponEvent

      public WeaponEvent(String weaponTitle, org.bukkit.inventory.ItemStack weaponStack, org.bukkit.entity.LivingEntity shooter, org.bukkit.inventory.EquipmentSlot hand)
  • Method Details

    • getWeaponTitle

      @NotNull public String getWeaponTitle()
      Returns the weapon-title associated with the weapon involved. This is the same as`CustomTag.WEAPON_TITLE.getString(event.getWeaponStack())`.
      Returns:
      The non-null weapon title.
    • getWeaponStack

      public org.bukkit.inventory.ItemStack getWeaponStack()
      Returns the weapon item which caused the event. This should always be an item in the player's main hand, or off hand.
      Returns:
      The non-null weapon item.
    • getShooter

      @NotNull public org.bukkit.entity.LivingEntity getShooter()
      Returns the shooter involved in this event. This is the same as EntityEvent.getEntity() but without the added overhead from casting it to a LivingEntity.
      Returns:
      The non-null entity that fired the weapon. This will not always be a player!
    • getHand

      @Nullable public org.bukkit.inventory.EquipmentSlot getHand()
      Returns the hand involved in the event. WeaponMechanics will only ever set this to EquipmentSlot.HAND or EquipmentSlot.OFF_HAND (Other plugins may change that). This value will be null when no hand was involved (Some explosions and some API methods).
      Returns:
      The nullable hand involved.
      See Also:
    • isMainHand

      public boolean isMainHand()
      Returns true if the weapon involved in this event was in the main hand. false means the weapon was in the offhand.
      Returns:
      true if weapon is in main hand.
    • isOffHand

      public boolean isOffHand()
      Returns false if the weapon involved in this event was in the main hand. true means the weapon was in the offhand.
      Returns:
      true if weapon is in offhand.
    • getHandData

      public HandData getHandData(boolean noAutoAdd)
      Helper method to the HandData involved in this event. For player shooters, the returned value will never be null. For entities, the value might be null.
      Returns:
      The nullable hand data involved.
    • getShooterWrapper

      public EntityWrapper getShooterWrapper(boolean noAutoAdd)