Fix emptying buckets in plot border (#3192)

* Fix emptying buckets in plot border

* Note on 1.13 compatibility for bucket-empty event

Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
Traks 2021-08-03 23:03:53 +02:00 committed by GitHub
parent fd4cec39c4
commit a405611b3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1167,10 +1167,15 @@ public class PlayerEventListener extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
BlockFace bf = event.getBlockFace();
// Note: a month after Bukkit 1.14.4 released, they added the API method
// PlayerBucketEmptyEvent#getBlock(), which returns the block the
// bucket contents is going to be placed at. Currently we determine this
// block ourselves to retain compatibility with 1.13.
final Block block;
// if the block can be waterlogged, the event might waterlog the block
// sometimes
if (event.getBlockClicked().getBlockData() instanceof Waterlogged) {
if (event.getBlockClicked().getBlockData() instanceof Waterlogged waterlogged
&& !waterlogged.isWaterlogged() && event.getBucket() != Material.LAVA_BUCKET) {
block = event.getBlockClicked();
} else {
block = event.getBlockClicked().getLocation()