summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFearThe1337 <admin@fearthe1337.com>2014-12-10 12:29:58 +0100
committermd_5 <git@md-5.net>2015-02-15 12:20:22 +1100
commit0f0e31b86bec91e2c1d5d4186e722c863b6b644c (patch)
tree8c8a7ba9ad300dfb954462f8e93d19e0e31ecb00
parente1f54099c8d6ba708c2895803464a0b89cacd3b9 (diff)
downloadbukkit-0f0e31b86bec91e2c1d5d4186e722c863b6b644c.tar
bukkit-0f0e31b86bec91e2c1d5d4186e722c863b6b644c.tar.gz
bukkit-0f0e31b86bec91e2c1d5d4186e722c863b6b644c.tar.lz
bukkit-0f0e31b86bec91e2c1d5d4186e722c863b6b644c.tar.xz
bukkit-0f0e31b86bec91e2c1d5d4186e722c863b6b644c.zip
Implement armor stand event.
-rw-r--r--src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java75
-rw-r--r--src/main/java/org/bukkit/inventory/EquipmentSlot.java10
2 files changed, 85 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java b/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java
new file mode 100644
index 00000000..a9950e0e
--- /dev/null
+++ b/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java
@@ -0,0 +1,75 @@
+package org.bukkit.event.player;
+
+import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.ArmorStand;
+import org.bukkit.event.HandlerList;
+import org.bukkit.inventory.ItemStack;
+
+/**
+ * Called when a player interacts with an armor stand and will either swap, retrieve or place an item.
+ */
+public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent {
+
+ private static final HandlerList handlers = new HandlerList();
+
+ private final ItemStack playerItem;
+ private final ItemStack armorStandItem;
+ private final EquipmentSlot slot;
+
+ public PlayerArmorStandManipulateEvent(final Player who, final ArmorStand clickedEntity, final ItemStack playerItem, final ItemStack armorStandItem, final EquipmentSlot slot) {
+ super(who, clickedEntity);
+ this.playerItem = playerItem;
+ this.armorStandItem = armorStandItem;
+ this.slot = slot;
+ }
+
+ /**
+ * Returns the item held by the player. If this Item is null and the armor stand Item is also null,
+ * there will be no transaction between the player and the armor stand.
+ * If the Player's item is null, but the armor stand item is not then the player will obtain the armor stand item.
+ * In the case that the Player's item is not null, but the armor stand item is null, the players item will be placed on the armor stand.
+ * If both items are not null, the items will be swapped.
+ * In the case that the event is cancelled the original items will remain the same.
+ * @return the item held by the player.
+ */
+ public ItemStack getPlayerItem() {
+ return this.playerItem;
+ }
+
+ /**
+ * Returns the item held by the armor stand.
+ * If this Item is null and the player's Item is also null, there will be no transaction between the player and the armor stand.
+ * If the Player's item is null, but the armor stand item is not then the player will obtain the armor stand item.
+ * In the case that the Player's item is not null, but the armor stand item is null, the players item will be placed on the armor stand.
+ * If both items are not null, the items will be swapped.
+ * In the case that the event is cancelled the original items will remain the same.
+ * @return the item held by the armor stand.
+ */
+ public ItemStack getArmorStandItem() {
+ return this.armorStandItem;
+ }
+
+ /**
+ * Returns the raw item slot of the armor stand in this event.
+ *
+ * @return the index of the item obtained or placed of the armor stand.
+ */
+ public EquipmentSlot getSlot() {
+ return this.slot;
+ }
+
+ @Override
+ public ArmorStand getRightClicked() {
+ return (ArmorStand) this.clickedEntity;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/org/bukkit/inventory/EquipmentSlot.java b/src/main/java/org/bukkit/inventory/EquipmentSlot.java
new file mode 100644
index 00000000..0b2eb984
--- /dev/null
+++ b/src/main/java/org/bukkit/inventory/EquipmentSlot.java
@@ -0,0 +1,10 @@
+package org.bukkit.inventory;
+
+public enum EquipmentSlot {
+
+ HAND,
+ FEET,
+ LEGS,
+ CHEST,
+ HEAD
+}