/** * */ package us.tastybento.bskyblock.listeners.flags; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketFillEvent; import us.tastybento.bskyblock.BSkyBlock; import us.tastybento.bskyblock.lists.Flags; /** * Handles interaction with beds * Note - bed protection from breaking or placing is done elsewhere. * @author tastybento * */ public class BucketListener extends AbstractFlagListener { public BucketListener(BSkyBlock plugin) { super(plugin); } /** * Prevents emptying of buckets * @param e */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBucketEmpty(final PlayerBucketEmptyEvent e) { if (e.getBlockClicked() != null) { // This is where the water or lava actually will be dumped Block dumpBlock = e.getBlockClicked().getRelative(e.getBlockFace()); checkIsland(e, dumpBlock.getLocation(), Flags.BUCKET); } } /** * Prevents collecting of lava, water, milk. If bucket use is denied in general, it is blocked. * @param e */ @EventHandler(priority = EventPriority.LOW) public void onBucketFill(final PlayerBucketFillEvent e) { // Check filling of various liquids if (e.getItemStack().getType().equals(Material.LAVA_BUCKET)) { if (!checkIsland(e, e.getBlockClicked().getLocation(), Flags.COLLECT_LAVA)) return; } if (e.getItemStack().getType().equals(Material.WATER_BUCKET)) { if (!checkIsland(e, e.getBlockClicked().getLocation(), Flags.COLLECT_WATER)) return; } if (e.getItemStack().getType().equals(Material.MILK_BUCKET)) { if (!checkIsland(e, e.getBlockClicked().getLocation(), Flags.MILKING)) return; } // Check general bucket use checkIsland(e, e.getBlockClicked().getLocation(), Flags.BUCKET); } }