Question Could someone help please?

Discussion in 'Community Feedback and Suggestions' started by Crafter145, Apr 18, 2017.

  1. How do i right an event where if someone is shifting and right clicking a stick it will run a command that i already have?
    I know this is easy but i cant think of it.
     
  2. @EventHandler
    public void onClick(PlayerInteractEvent e){
    if(e.getPlayer().isSneaking()){
    if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
    Bukkit.getServer().dispatchCommand(e.getPlayer(), YOUR COMMAND);
    }
    }
    }
     
    #2 Jobsms, Apr 19, 2017
    Last edited: Apr 19, 2017
  3. You are litteraly missing half of the code.

    Use this:

    Code (Text):
    @EventHandler
    public void onClick(PlayerInteractEvent e){
        if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
            if(e.getItem().getType().equals(Material.STICK) && e.getPlayer().isSneaking()){
                Bukkit.getServer().dispatchCommand(e.getPlayer(), "/command here");
            }
        }
    }
     
  4. Oops, I forgot the Stick :)
     
  5. I like your point.