3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00

Fix PlayerBucketEmptyEvent handling. Fixes BUKKIT-2002 and fixes BUKKIT-1997

The method this.a(world, d0, d1, d2, i, j, k) is responsible for
actually placing the lava or water source block in the world. The event
is currently called after this method, thus canceling the event will
cause the player to keep their water/lava bucket but the water/lava will
still appear where they attempted to place it.

In addition, the check for whether a player has creative inventory is
short circuiting before the event fires, so the event will not be called
for these players.

This moves the event call and cancelled check above these two calls to
ensure it always fires and the results of it are honored.

Closes GH-835.
Dieser Commit ist enthalten in:
Steve Anton 2012-08-03 10:07:04 -07:00 committet von Wesley Wolfe
Ursprung 02d6703da7
Commit f90bd7e7cc

Datei anzeigen

@ -135,18 +135,16 @@ public class ItemBucket extends Item {
return itemstack;
}
if (this.a(world, d0, d1, d2, i, j, k) && !entityhuman.abilities.canInstantlyBuild) {
// CraftBukkit start
PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clickedX, clickedY, clickedZ, movingobjectposition.face, itemstack);
// CraftBukkit start
PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clickedX, clickedY, clickedZ, movingobjectposition.face, itemstack);
if (event.isCancelled()) {
return itemstack;
}
// CraftBukkit end
// CraftBukkit TODO: look for all the stuff that disappeared here, and make sure this is still where it should be
// CraftBukkit start
return CraftItemStack.createNMSItemStack(event.getItemStack());
// CraftBukkit end
if (event.isCancelled()) {
return itemstack;
}
// CraftBukkit end
if (this.a(world, d0, d1, d2, i, j, k) && !entityhuman.abilities.canInstantlyBuild) {
return CraftItemStack.createNMSItemStack(event.getItemStack()); // CraftBukkit
}
}
} else if (this.a == 0 && movingobjectposition.entity instanceof EntityCow) {