How would I replenish a player's arrow when they shoot a bow?

Discussion in 'Plugin Development' started by icc, May 11, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    icc

    I want a single arrow in a player's inventory to refresh every time it disappears. I tried using an EntityShootBowEvent, but it doesn't work and I don't know why.
    Here's my code:
    Code:
          public void skeletonShoot(EntityShootBowEvent shootEvent){
              ItemStack arrow = new ItemStack(Material.ARROW, 1);
              Player player = (Player) shootEvent.getEntity();
              Inventory inv = player.getInventory();
    
              inv.getContents();
              inv.setItem(1, arrow);
          }
    Anyone have any ideas?

    Edit: I just found a workaround solution to this by giving the player an arrow every time they click their bow with a PlayerInteractEvent. Thanks!
     
    Last edited: May 11, 2020
  2. Offline

    timtower Administrator Administrator Moderator

    @icc Do you have the @EventHandler
     
  3. Offline

    Strahan

    If you want to give them an arrow every time they shoot, why not just give their bows the infinity enchant? That'd be a lot easier.
     
Thread Status:
Not open for further replies.

Share This Page