From a63b264027e186d73adc5131056271aa4e28af8d Mon Sep 17 00:00:00 2001 From: MinusKube Date: Wed, 2 Mar 2016 05:16:35 +0100 Subject: SPIGOT-1532: Add PlayerSwapHandItemsEvent --- .../event/player/PlayerSwapHandItemsEvent.java | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java (limited to 'src/main/java/org') diff --git a/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java b/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java new file mode 100644 index 00000000..483eb17e --- /dev/null +++ b/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java @@ -0,0 +1,81 @@ +package org.bukkit.event.player; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; + +/** + * Called when a player swap items between main hand and off hand using the + * hotkey. + */ +public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + // + private ItemStack mainHandItem; + private ItemStack offHandItem; + private boolean cancelled; + + public PlayerSwapHandItemsEvent(Player player, ItemStack mainHandItem, ItemStack offHandItem) { + super(player); + + this.mainHandItem = mainHandItem; + this.offHandItem = offHandItem; + } + + /** + * Gets the item switched to the main hand. + * + * @return item in the main hand + */ + public ItemStack getMainHandItem() { + return mainHandItem; + } + + /** + * Sets the item in the main hand. + * + * @param mainHandItem new item in the main hand + */ + public void setMainHandItem(ItemStack mainHandItem) { + this.mainHandItem = mainHandItem; + } + + /** + * Gets the item switched to the off hand. + * + * @return item in the off hand + */ + public ItemStack getOffHandItem() { + return offHandItem; + } + + /** + * Sets the item in the off hand. + * + * @param offHandItem new item in the off hand + */ + public void setOffHandItem(ItemStack offHandItem) { + this.offHandItem = offHandItem; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} -- cgit v1.2.3