Solved Disable arrow pickup in 1.16

Discussion in 'Plugin Development' started by Valkyrie6, Jul 10, 2021.

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

    Valkyrie6

    I have been searching for ages trying to work out how to cancel the arrow pickup event. Currently it appears as thought the PlayerPickupArrowEvent#setCancelled() method is depreciated and I cannot find an alternative.

    I also looked into PlayerPickupItemEvent but that seems to be depreciated too.

    Currently it seems as though I will just have to remove the arrow when the event is called however this is not ideal for my circumstance.

    Any help would be appreciated :)

    (My current code for removing the arrow)
    Code:
    @EventHandler
    public void onArrowPickup(PlayerPickupArrowEvent e) {
        Player p = e.getPlayer();
        if (Main.isSpectating(p)) e.getArrow().remove();
    }
    [EDIT] The code above does not remove the arrow by the way...

    Solution -
    Using @SuppressWarnings("deprecation") like below works fine, it was only depreciated because of the parent class.
    Code:
    @SuppressWarnings("deprecation")
    @EventHandler
    public void onArrowPickup(PlayerPickupArrowEvent e) {
        Player p = e.getPlayer();
        if (Main.isSpectating(p)) e.setCancelled(true);
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 11, 2021
  2. Offline

    Tim_M

    Hello. Events thats might/will change in the future as marked as deprecated. Check the documentation for your version to see the new event.
     
Thread Status:
Not open for further replies.

Share This Page