Class ReloadHandler

java.lang.Object
me.deecaad.weaponmechanics.weapon.reload.ReloadHandler
All Implemented Interfaces:
me.deecaad.core.file.IValidator, TriggerListener

public class ReloadHandler extends Object implements me.deecaad.core.file.IValidator, TriggerListener
  • Constructor Details

    • ReloadHandler

      public ReloadHandler()
      Default constructor for validator
    • ReloadHandler

      public ReloadHandler(WeaponHandler weaponHandler)
  • Method Details

    • allowOtherTriggers

      public boolean allowOtherTriggers()
      Description copied from interface: TriggerListener
      Mostly this is defaulted to false.
      Specified by:
      allowOtherTriggers in interface TriggerListener
      Returns:
      true if other triggers can occur even after this trigger is valid
    • tryUse

      public boolean tryUse(EntityWrapper entityWrapper, String weaponTitle, org.bukkit.inventory.ItemStack weaponStack, org.bukkit.inventory.EquipmentSlot slot, TriggerType triggerType, boolean dualWield, @Nullable org.bukkit.entity.LivingEntity victim)
      Description copied from interface: TriggerListener
      Tries to use given trigger type to trigger some action.
      Specified by:
      tryUse in interface TriggerListener
      Parameters:
      entityWrapper - the entity which caused trigger
      weaponTitle - the weapon title involved
      weaponStack - the weapon stack involved
      slot - the weapon slot used
      triggerType - the trigger which caused this
      dualWield - whether this was dual wield
      victim - if there is known victim
      Returns:
      true if was able to use
    • startReloadWithoutTrigger

      public boolean startReloadWithoutTrigger(EntityWrapper entityWrapper, String weaponTitle, org.bukkit.inventory.ItemStack weaponStack, org.bukkit.inventory.EquipmentSlot slot, boolean dualWield, boolean isReloadLoop)
      Starts reloading without checking for trigger. Used for example when trying to shoot without ammo.
      Parameters:
      entityWrapper - the entity who used reload
      weaponTitle - the weapon title
      weaponStack - the weapon stack
      slot - the slot used on reload
      dualWield - whether this was dual wield
      isReloadLoop - whether this is reloading loop
      Returns:
      true if was able to start reloading
    • finishReload

      public void finishReload(EntityWrapper entityWrapper, String weaponTitle, org.bukkit.inventory.ItemStack weaponStack, HandData handData, org.bukkit.inventory.EquipmentSlot slot)
    • getAmmoLeft

      public int getAmmoLeft(org.bukkit.inventory.ItemStack weaponStack, String weaponTitle)
      Returns ammo left in weapon. If returned value is -1, then ammo is not used in this weapon stack
      Parameters:
      weaponStack - the weapon stack
      weaponTitle - the weapon title
      Returns:
      -1 if infinity, otherwise current ammo amount
    • consumeAmmo

      public boolean consumeAmmo(org.bukkit.inventory.ItemStack weaponStack, String weaponTitle, int amount)
      Returns:
      false if can't consume ammo (no enough ammo left)
    • handleWeaponStackAmount

      public void handleWeaponStackAmount(EntityWrapper entityWrapper, org.bukkit.inventory.ItemStack weaponStack)
      Drop item stacks to entity location if the weapon stack amount is more than 1
      Parameters:
      entityWrapper - the entity
      weaponStack - the item stack to give
    • getKeyword

      public String getKeyword()
      Specified by:
      getKeyword in interface me.deecaad.core.file.IValidator
    • getAllowedPaths

      public List<String> getAllowedPaths()
      Specified by:
      getAllowedPaths in interface me.deecaad.core.file.IValidator
    • validate

      public void validate(me.deecaad.core.file.Configuration configuration, me.deecaad.core.file.SerializeData data) throws me.deecaad.core.file.SerializerException
      Specified by:
      validate in interface me.deecaad.core.file.IValidator
      Throws:
      me.deecaad.core.file.SerializerException