2018-02-02 05:30:57 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
|
2018-02-03 20:54:33 +01:00
|
|
|
import us.tastybento.bskyblock.BSkyBlock;
|
2018-02-02 05:30:57 +01:00
|
|
|
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 {
|
|
|
|
|
2018-02-03 20:54:33 +01:00
|
|
|
public BucketListener(BSkyBlock plugin) {
|
|
|
|
super(plugin);
|
|
|
|
}
|
|
|
|
|
2018-02-02 05:30:57 +01:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|