summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/bukkit/entity/HumanEntity.java2
-rw-r--r--src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java39
2 files changed, 40 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java
index 1ceb0728..be7c3655 100644
--- a/src/main/java/org/bukkit/entity/HumanEntity.java
+++ b/src/main/java/org/bukkit/entity/HumanEntity.java
@@ -38,7 +38,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, Permissible, Inv
public Inventory getEnderChest();
/**
- * Gets the players selected main hand
+ * Gets the player's selected main hand
*
* @return the players main hand
*/
diff --git a/src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java b/src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java
new file mode 100644
index 00000000..2a154462
--- /dev/null
+++ b/src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java
@@ -0,0 +1,39 @@
+package org.bukkit.event.player;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.inventory.MainHand;
+
+/**
+ * Called when a player changes their main hand in the client settings.
+ */
+public class PlayerChangedMainHandEvent extends PlayerEvent {
+
+ private static final HandlerList handlers = new HandlerList();
+ //
+ private final MainHand mainHand;
+
+ public PlayerChangedMainHandEvent(Player who, MainHand mainHand) {
+ super(who);
+ this.mainHand = mainHand;
+ }
+
+ /**
+ * Gets the new main hand of the player. The old hand is still momentarily
+ * available via {@link Player#getMainHand()}.
+ *
+ * @return the new {@link MainHand} of the player
+ */
+ public MainHand getMainHand() {
+ return mainHand;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}