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,7 +135,6 @@ 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);
@ -143,10 +142,9 @@ public class ItemBucket extends Item {
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 (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) {