diff options
author | md_5 <git@md-5.net> | 2016-03-04 15:24:51 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-03-04 15:24:51 +1100 |
commit | 5a3813d7fe49a683eee4a9fdea1ad0725591eec5 (patch) | |
tree | d7d7dcf386662519de2b973058d41526b6db44a2 /src/main/java/org/bukkit | |
parent | 3e3516e3b29763ccd3c20650a41d378857093280 (diff) | |
download | craftbukkit-5a3813d7fe49a683eee4a9fdea1ad0725591eec5.tar craftbukkit-5a3813d7fe49a683eee4a9fdea1ad0725591eec5.tar.gz craftbukkit-5a3813d7fe49a683eee4a9fdea1ad0725591eec5.tar.lz craftbukkit-5a3813d7fe49a683eee4a9fdea1ad0725591eec5.tar.xz craftbukkit-5a3813d7fe49a683eee4a9fdea1ad0725591eec5.zip |
SPIGOT-1608: Add a way to get the hand used in PlayerInteract*Events
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index f9ab0622..131792b1 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -58,6 +58,7 @@ import org.bukkit.event.inventory.PrepareAnvilEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.*; import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.meta.BookMeta; @@ -182,18 +183,18 @@ public class CraftEventFactory { /** * Player Interact event */ - public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack) { + public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack, EnumHand hand) { if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) { throw new AssertionError(String.format("%s performing %s with %s", who, action, itemstack)); } - return callPlayerInteractEvent(who, action, new BlockPosition(0, 256, 0), EnumDirection.SOUTH, itemstack); + return callPlayerInteractEvent(who, action, new BlockPosition(0, 256, 0), EnumDirection.SOUTH, itemstack, hand); } - public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, BlockPosition position, EnumDirection direction, ItemStack itemstack) { - return callPlayerInteractEvent(who, action, position, direction, itemstack, false); + public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, BlockPosition position, EnumDirection direction, ItemStack itemstack, EnumHand hand) { + return callPlayerInteractEvent(who, action, position, direction, itemstack, false, hand); } - public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, BlockPosition position, EnumDirection direction, ItemStack itemstack, boolean cancelledBlock) { + public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, BlockPosition position, EnumDirection direction, ItemStack itemstack, boolean cancelledBlock, EnumHand hand) { Player player = (who == null) ? null : (Player) who.getBukkitEntity(); CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack); @@ -219,7 +220,7 @@ public class CraftEventFactory { itemInHand = null; } - PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace); + PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace, (hand == null) ? null : ((hand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); if (cancelledBlock) { event.setUseInteractedBlock(Event.Result.DENY); } |