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 Summary
ConstructorsConstructorDescriptionDefault constructor for validatorReloadHandler(WeaponHandler weaponHandler) -
Method Summary
Modifier and TypeMethodDescriptionbooleanMostly this is defaulted to false.booleanconsumeAmmo(org.bukkit.inventory.ItemStack weaponStack, String weaponTitle, int amount) voidfinishReload(EntityWrapper entityWrapper, String weaponTitle, org.bukkit.inventory.ItemStack weaponStack, HandData handData, org.bukkit.inventory.EquipmentSlot slot) intgetAmmoLeft(org.bukkit.inventory.ItemStack weaponStack, String weaponTitle) Returns ammo left in weapon.voidhandleWeaponStackAmount(EntityWrapper entityWrapper, org.bukkit.inventory.ItemStack weaponStack) Drop item stacks to entity location if the weapon stack amount is more than 1booleanstartReloadWithoutTrigger(EntityWrapper entityWrapper, String weaponTitle, org.bukkit.inventory.ItemStack weaponStack, org.bukkit.inventory.EquipmentSlot slot, boolean dualWield, boolean isReloadLoop) Starts reloading without checking for trigger.booleantryUse(EntityWrapper entityWrapper, String weaponTitle, org.bukkit.inventory.ItemStack weaponStack, org.bukkit.inventory.EquipmentSlot slot, TriggerType triggerType, boolean dualWield, org.bukkit.entity.LivingEntity victim) Tries to use given trigger type to trigger some action.voidvalidate(me.deecaad.core.file.Configuration configuration, me.deecaad.core.file.SerializeData data) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.deecaad.core.file.IValidator
denyKeys, shouldValidate
-
Constructor Details
-
ReloadHandler
public ReloadHandler()Default constructor for validator -
ReloadHandler
-
-
Method Details
-
allowOtherTriggers
public boolean allowOtherTriggers()Description copied from interface:TriggerListenerMostly this is defaulted to false.- Specified by:
allowOtherTriggersin interfaceTriggerListener- 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:TriggerListenerTries to use given trigger type to trigger some action.- Specified by:
tryUsein interfaceTriggerListener- Parameters:
entityWrapper- the entity which caused triggerweaponTitle- the weapon title involvedweaponStack- the weapon stack involvedslot- the weapon slot usedtriggerType- the trigger which caused thisdualWield- whether this was dual wieldvictim- 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 reloadweaponTitle- the weapon titleweaponStack- the weapon stackslot- the slot used on reloaddualWield- whether this was dual wieldisReloadLoop- 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
Returns ammo left in weapon. If returned value is -1, then ammo is not used in this weapon stack- Parameters:
weaponStack- the weapon stackweaponTitle- 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 entityweaponStack- the item stack to give
-
getKeyword
- Specified by:
getKeywordin interfaceme.deecaad.core.file.IValidator
-
getAllowedPaths
- Specified by:
getAllowedPathsin interfaceme.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:
validatein interfaceme.deecaad.core.file.IValidator- Throws:
me.deecaad.core.file.SerializerException
-