mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00: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
1 changed files with 11 additions and 3 deletions
|
@ -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 a new issue