Need an Event for Drinking Potions

Discussion in 'Bukkit Discussion' started by foxwillow, Aug 18, 2012.

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

    CookCreeperz

    user
    User shows an error in eclipse.
     
    Tehmaker likes this.
  2. Offline

    Darvin939

    try this
    Code:
     @EventHandler(priority = EventPriority.NORMAL)
        public void onPotionDrink(PlayerInteractEvent event) {
            Player player = event.getPlayer();
            if (((event.getAction() == Action.RIGHT_CLICK_AIR) || (event.getAction() == Action.RIGHT_CLICK_BLOCK)) && (player.getItemInHand().getType() == Material.POTION)) {
                int hs = p.getInventory().getHeldItemSlot();
                drink(p,hs);
            }
        }
     
        public void drink(final Player player, int hs) {
            plg.getServer().getScheduler().scheduleSyncDelayedTask(plg, new Runnable() {
                public void run() {
                    if (player.getInventory().getItem(hs).getType() == Material.GLASS_BOTTLE) {
                        // then ...
                    }
                }
            }, 35);
        }
    The number 35 must be at least 30, else Potion bottle will not be empty
     
Thread Status:
Not open for further replies.

Share This Page