Bukkit/CraftBukkit — pull request #644 by wilsonsd (2012-01-18 04:07:57+00:00)
Title: Properly cancel BlockPlaceEvent when redstone and tnt is placed.

This commit fixes three related problems:
1. If a tnt block is placed next to a powered redstone torch, and the
BlockPlaceEvent is cancelled, the TNT explodes, rather than returning to
the players inventory.
2. If a redstone torch is placed and the BlockPlaceEvent is cancelled,
the torch still momentarily powers adjacent blocks.
3. If a redstone wire is placed and the BlockPlaceEvent is cancelled,
the wire still momentarily transmits power.

Reason for bug: in BlockTNT, BlockRedstoneTorch and BlockRedstoneWire,
the code in onPlace happens before Bukkit plugins have a chance to
cancel the BlockPlaceEvent (which is created after onPlace is called).

Fix:
1. Move the code in onPlace to postPlace, which is called after plugins
have a chance to cancel the BlockPlaceEvent.
2. In ItemRedstone.a, call postPlace. (Otherwise, redstone wires that
plugins allow to be placed don't have their powered state update right
away like they should.)
3. In BlockTorch.onPlace, change the calls to setData to setRawData.
Otherwise, the call to setData would cause redstone torches to power
adjacent blocks before plugins have a chance to cancel the
BlockPlaceEvent.

This fixes issue BUKKIT-89:
https://bukkit.atlassian.net/browse/BUKKIT-89
and replaces CraftBukkit pull request 603:
https://github.com/Bukkit/CraftBukkit/pull/603