Add ability to change player item in hand. Adds BUKKIT-3318

This commit is contained in:
Patrick Seidel
2012-12-27 16:30:08 -05:00
committed by GJ
parent b532042973
commit 7c40a073d8
2 changed files with 13 additions and 0 deletions

View File

@@ -760,6 +760,10 @@ public class PlayerConnection extends Connection {
if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex < PlayerInventory.getHotbarSize()) {
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex);
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
this.sendPacket(new Packet16BlockItemSwitch(this.player.inventory.itemInHandIndex));
return;
}
// CraftBukkit end
this.player.inventory.itemInHandIndex = packet16blockitemswitch.itemInHandIndex;