only do stuff if it has right name

Discussion in 'Plugin Development' started by nbkburns, Aug 29, 2014.

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

    nbkburns

    i want my custom item to shoot arrows but the normal item (a stick) shoots the arrow aswell
    Code:
    @EventHandler(priority = EventPriority.HIGH)
        public void onInteract(PlayerInteractEvent event) {
            Player player = event.getPlayer();
            if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) {
                 
            }
            if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                if (player.getItemInHand().getType() == Material.STICK) {
                    player.launchProjectile(Arrow.class);
                    if (player.getItemInHand().getType() == Material.STICK) {
                        ItemStack Kunai = (player.getItemInHand());
                        if (Kunai.hasItemMeta()
                                && Kunai.getItemMeta().hasDisplayName()
                                && Kunai.getItemMeta().getDisplayName().equalsIgnoreCase("Kunai")) {
                       
                        player.launchProjectile(Arrow.class);
                        ItemStack item =  player.getInventory().getItem(player.getInventory().first (Material.STICK));
                        if(item.getAmount() ==1)
                        {
                        player.getInventory().remove(item);
                        }
                        else
                        {
                        item.setAmount(item.getAmount()-1);
                        }
                    }
                }
     
  2. Offline

    Necrodoom

    Well, you could remove the duplicate spawn projectile line.
     
  3. Offline

    nbkburns

    thanks, lol didnt see that
     
Thread Status:
Not open for further replies.

Share This Page