PlayerPickupArrowEvent

XMLWordPrintable

    • Type: New Feature
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • Environment:

      N/A - Not necessary for a request

    • N/A - Spigot API Request

      As of now, to check when a Player picks up an arrow, we are forced to use the following code:

      @EventHandler
      public void onPickupArrow(PlayerPickupItemEvent event){
          if (event.getItem().getItemStack().equals(new ItemStack(Material.ARROW))){
              //Do whatever
          }
      }

      Now, that's not bad, though it's very limiting as to what we can do with this. In this case, we have no specific instance of the Arrow that is being picked up. Without an instance of the Arrow, we are unable to modify, manipulate, or reference the arrow in any way possible. For example, in my case and the reason I'm creating this request ticket, is because I need to check if the arrow being picked up is an instanceof another class

      As of now, it's impossible due to the fact that we can only get either and Item entity, or an ItemStack (Neither of which can return an instance of the Arrow)

      The event may look something similar to this:

      public class PlayerPickupArrowEvent extends Event implements Cancellable{
      	private static final HandlerList handlers = new HandlerList();
      	
      	private boolean cancelled = false;
      	private Arrow arrow;
      	private Player player;
      	public PlayerPickupArrowEvent(Arrow arrow, Player player){
      		this.arrow = arrow;
      		this.player = player;
      	}
      	
      	@Override
      	public boolean isCancelled(){
      		return cancelled;
      	}
      
      	@Override
      	public void setCancelled(boolean cancel) {
      		this.cancelled = cancel;
      	}
      	
      	public Arrow getArrow() {
      		return arrow;
      	}
      	
      	public Player getPlayer() {
      		return player;
      	}
      
      	@Override
      	public HandlerList getHandlers() {
      		return handlers;
      	}
      }

            Assignee:
            Unassigned
            Reporter:
            Parker Hawke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: