summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java')
-rw-r--r--src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java81
1 files changed, 81 insertions, 0 deletions
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;
+ }
+}