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

This commit is contained in:
Patrick Seidel authored and GJ committed 2013-03-24 14:04:27 -04:00
1 parent b532042973
commit 7c40a073d8
2 files changed
+13

No files matched your search

@@ -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;