Bow pull back event?

Discussion in 'Plugin Development' started by Elimnator, Jan 18, 2015.

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

    Elimnator

    Is there any event or way to get when a player starts charging a bow?

    I want to make a bow shoot more arrows depending on how long the bow is held back.

    Both the playerInteract and playerAnimation events don't fire when you start charging a bow.
     
  2. Offline

    567legodude

    @Elimnator The playerInteract thing isn't too correct. You should be able to use PlayerInteractEvent and check to see if they right clicked. Then you can check to see if they item in their hand is a bow.
     
  3. Offline

    Elimnator

    @567legodude
    I just said the PlayerInteractEvent does not trigger when interacting with a bow in the air...
     
  4. Offline

    lightlord323

  5. Offline

    Antybarrel

    @Elimnator
    What like this

    Code:
     @EventHandler
         public void onPlayerInteract(PlayerInteractEvent event) {
         Player player = event.getPlayer();
          if (player.getItemInHand().getType() == Material.BOW && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)){
    
          //code here?
    
          }
    
    }
    
     
  6. Offline

    Elimnator

    @lightlord323

    Code:
    @EventHandler(priority=EventPriority.HIGH)
    public void onPlayerInteract(PlayerInteractEvent e){
       System.out.println("interact");
    }
    
    It does not print interact when I use the bow.
     
  7. Offline

    lightlord323

    @Elimnator try this code:


    Code:
    @EventHandler(priority=EventPriority.HIGH)
    public void onPlayerInteract(PlayerInteractEvent e){
    
    if(e.getAction() == Action.RIGHT_CLICK_AIR) {
    
    if(e.getPlayer().getItmInHand().getType().equals(Material.BOW)) {
    e.getPlayer().sendMessage("worked")
    
    }
    }
    
    
    }
    Make sure you register the event.
     
  8. Offline

    Elimnator

    Event is registered, works when I hit with the bow.

    Your code is the same as mine.
     
  9. Offline

    1Rogue

    It will, but note that clicking air will mean the event starts as "cancelled" if you are using ignoredCancelled at all.
     
  10. Offline

    Elimnator

    @1Rogue
    Clicking the air with any other item works.
     
Thread Status:
Not open for further replies.

Share This Page