ProjectileHitEvent How to get the bow ?

Discussion in 'Plugin Development' started by RFUDEO9EH, Mar 5, 2020.

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

    RFUDEO9EH

    Hello everyone , I have a plugin which is teleport people where the arrow is shot if the bow isn't enchanted.
    And if the bow have Flame, the arrow explode when it hit the ground. The problem is that I don't know how to get the bow which the player use. (I use ProjectileHitEvent) help me pls

    code:

    https://pastebin.com/RLJkNkid
     
  2. Offline

    wand555

    You already have the player, you can check their inventory
     
  3. Offline

    timtower Administrator Administrator Moderator

    @RFUDEO9EH Save the bow type when they shoot the arrow, then they can't switch bows while the arrow is flying.
     
  4. Offline

    RFUDEO9EH

    Thanks for your answer but I don't know how to do that can you explain pls ?

    this doesn't work

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Mar 5, 2020
  5. Offline

    Kars

  6. Offline

    Machine Maker

    I think what timtower was suggesting, was you listen to two events, the EntityShootBowEvent, and the ProjectileHitEvent. You keep track of each arrow entity and what shot it from the first event, and then in the second event, you can check the projectile against that saved entity and then do what you want based on that.
     
    Kars and timtower like this.
  7. Offline

    Kars

    But make sure to have it forget about arrows after a certain time or you'll have a memory leak.
     
Thread Status:
Not open for further replies.

Share This Page