Class SentinelItemHelper

java.lang.Object
org.mcmonkey.sentinel.SentinelHelperObject
org.mcmonkey.sentinel.SentinelItemHelper

public class SentinelItemHelper extends SentinelHelperObject
Helper for item management.
  • Field Summary

    Fields inherited from class org.mcmonkey.sentinel.SentinelHelperObject

    attackHelper, itemHelper, sentinel, targetingHelper, weaponHelper
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.inventory.ItemStack
    autoRedirect(org.bukkit.inventory.ItemStack stack)
    Processes weapon redirection for an item, returning the redirected item (or an unchanged one).
    org.bukkit.inventory.ItemStack
    Gets the correct ArrowItem type for the NPC based on inventory items (can be null if the NPC needs ammo but has none).
    org.bukkit.inventory.ItemStack
    Returns the item held by an NPC.
    void
    Grabs the next item for an NPC to use and moves it into the NPC's hand.
    boolean
    Returns whether the NPC is holding a shield in its offhand.
    boolean
    isMeleeWeapon(org.bukkit.inventory.ItemStack item)
    Returns whether the item is some form of melee weapon.
    boolean
    Returns whether the NPC is holding a ranged weapon.
    boolean
    isRanged(org.bukkit.inventory.ItemStack item)
    Returns whether the NPC is holding a ranged weapon.
    void
    Reduces the durability of the NPC's held item.
    boolean
    Returns whether the NPC can take durability from the held item.
    void
    swapToMatch(java.util.function.Function<org.bukkit.inventory.ItemStack,Boolean> doSwap, boolean isRanged)
    Swaps weapon to the first item that matches the input function.
    void
    Swaps the NPC to a melee weapon if possible.
    void
    Swaps the NPC to an open hand if possible.
    void
    Swaps the NPC to a ranged weapon if possible.
    boolean
    Swaps offhand to shield for defense, if possible.
    void
    Takes an arrow from the NPC's inventory.
    void
    Takes one item from the NPC's held items (for consumables).
    boolean
    usesBow(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using a bow item.
    boolean
    usesEgg(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using an egg item.
    boolean
    usesFangsBook(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using an evoker fangs attack book.
    boolean
    usesFireball(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using a fireball item.
    boolean
    usesLightning(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using a lightning-attack item.
    boolean
    usesLlamaSpit(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using a llama spit item (white_dye).
    boolean
    usesPearl(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using a pearl item.
    boolean
    usesPotion(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using a potion item.
    boolean
    usesShulkerBullet(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using a shulker bullet item.
    boolean
    usesSnowball(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using a snowball item.
    boolean
    usesSpectral(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using a spectral-effect-attack item.
    boolean
    usesTrident(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using a trident item.
    boolean
    usesWitherSkull(org.bukkit.inventory.ItemStack it)
    Returns whether the NPC is using a wither-skull item.

    Methods inherited from class org.mcmonkey.sentinel.SentinelHelperObject

    debug, getLivingEntity, getNPC, setTraitObject

    Methods inherited from class java.lang.Object

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

    • SentinelItemHelper

      public SentinelItemHelper()
  • Method Details

    • getArrow

      public org.bukkit.inventory.ItemStack getArrow()
      Gets the correct ArrowItem type for the NPC based on inventory items (can be null if the NPC needs ammo but has none).
    • reduceDurability

      public void reduceDurability()
      Reduces the durability of the NPC's held item.
    • takeArrow

      public void takeArrow()
      Takes an arrow from the NPC's inventory.
    • takeOne

      public void takeOne()
      Takes one item from the NPC's held items (for consumables).
    • grabNextItem

      public void grabNextItem()
      Grabs the next item for an NPC to use and moves it into the NPC's hand.
    • swapToShield

      public boolean swapToShield()
      Swaps offhand to shield for defense, if possible. Returns true if a shield was equipped.
    • swapToMatch

      public void swapToMatch(java.util.function.Function<org.bukkit.inventory.ItemStack,Boolean> doSwap, boolean isRanged)
      Swaps weapon to the first item that matches the input function.
    • swapToOpenHand

      public void swapToOpenHand()
      Swaps the NPC to an open hand if possible.
    • swapToRanged

      public void swapToRanged()
      Swaps the NPC to a ranged weapon if possible.
    • swapToMelee

      public void swapToMelee()
      Swaps the NPC to a melee weapon if possible.
    • hasShield

      public boolean hasShield()
      Returns whether the NPC is holding a shield in its offhand.
    • isMeleeWeapon

      public boolean isMeleeWeapon(org.bukkit.inventory.ItemStack item)
      Returns whether the item is some form of melee weapon.
    • isRanged

      public boolean isRanged()
      Returns whether the NPC is holding a ranged weapon.
    • isRanged

      public boolean isRanged(org.bukkit.inventory.ItemStack item)
      Returns whether the NPC is holding a ranged weapon.
    • autoRedirect

      public org.bukkit.inventory.ItemStack autoRedirect(org.bukkit.inventory.ItemStack stack)
      Processes weapon redirection for an item, returning the redirected item (or an unchanged one).
    • getHeldItem

      public org.bukkit.inventory.ItemStack getHeldItem()
      Returns the item held by an NPC.
    • usesBow

      public boolean usesBow(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using a bow item.
    • usesFireball

      public boolean usesFireball(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using a fireball item.
    • usesSnowball

      public boolean usesSnowball(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using a snowball item.
    • usesLightning

      public boolean usesLightning(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using a lightning-attack item.
    • usesEgg

      public boolean usesEgg(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using an egg item.
    • usesPearl

      public boolean usesPearl(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using a pearl item.
    • usesWitherSkull

      public boolean usesWitherSkull(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using a wither-skull item.
    • usesTrident

      public boolean usesTrident(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using a trident item.
    • usesSpectral

      public boolean usesSpectral(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using a spectral-effect-attack item.
    • usesPotion

      public boolean usesPotion(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using a potion item.
    • usesLlamaSpit

      public boolean usesLlamaSpit(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using a llama spit item (white_dye).
    • usesShulkerBullet

      public boolean usesShulkerBullet(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using a shulker bullet item.
    • usesFangsBook

      public boolean usesFangsBook(org.bukkit.inventory.ItemStack it)
      Returns whether the NPC is using an evoker fangs attack book.
    • shouldTakeDura

      public boolean shouldTakeDura()
      Returns whether the NPC can take durability from the held item.