mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Prevent blocks from getting waterlogged
In some cases, the PlayerInteractEvent doesn't cancel right clicks on blocks that can be waterlogged
This commit is contained in:
parent
95f509d337
commit
81d0bf6f04
@ -82,6 +82,7 @@ import org.bukkit.FluidCollisionMode;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.data.Waterlogged;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -1070,9 +1071,16 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
|
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||||
BlockFace bf = event.getBlockFace();
|
BlockFace bf = event.getBlockFace();
|
||||||
Block block =
|
final Block block;
|
||||||
event.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ())
|
// if the block can be waterlogged, the event might waterlog the block
|
||||||
.getBlock();
|
// sometimes
|
||||||
|
if (event.getBlockClicked().getBlockData() instanceof Waterlogged) {
|
||||||
|
block = event.getBlockClicked();
|
||||||
|
} else {
|
||||||
|
block = event.getBlockClicked().getLocation()
|
||||||
|
.add(bf.getModX(), bf.getModY(), bf.getModZ())
|
||||||
|
.getBlock();
|
||||||
|
}
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user