Stacking Water/Lava Bucket issue

Discussion in 'BungeeCord Plugin Development' started by Tidal, Jan 23, 2016.

  1. Right, So I have made a plugin where water/lava buckets can stack (with no command, Basically just hover over and click a water bucket while holding another water bucket)
    But when they're stacked it uses all them.

    I have 14 stacked water buckets. When i go to use one, it uses all 14. How would i make it use 1?

    Code will be given if necessary
  2. That's bukkit my friend.
    • Agree Agree x 1
  3. Listen to the PlayerBucketEmptyEvent and remove one water/lava bucket from the stack.
    Something like this (pseudo code):
    Code (Text):

        public void onPlayerBucketEmptyEvent(PlayerBucketEmptyEvent event)
            if(event.getPlayer().getItemInHand().getAmount() == 1)
                event.getPlayer().getInventory().remove(event.getPlayer().getItemInHand()); // if they only have one bucket remove the entire stack from their inventory
                event.getPlayer().getItemInHand().setAmount(event.getPlayer().getItemInHand().getAmount() - 1); // if they have more than one bucket subtract 1 from the stack's size
            event.getPlayer().getInventory().addItem(new ItemStack(Material.BUCKET, 1)); // add an empty bucket into their inventory

Share This Page