Commits

FearThe1337 authored and md_5 committed 0f0e31b86be
Implement armor stand event.
No tags

src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java

Added
1 +package org.bukkit.event.player;
2 +
3 +import org.bukkit.inventory.EquipmentSlot;
4 +import org.bukkit.entity.Player;
5 +import org.bukkit.entity.ArmorStand;
6 +import org.bukkit.event.HandlerList;
7 +import org.bukkit.inventory.ItemStack;
8 +
9 +/**
10 + * Called when a player interacts with an armor stand and will either swap, retrieve or place an item.
11 + */
12 +public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent {
13 +
14 + private static final HandlerList handlers = new HandlerList();
15 +
16 + private final ItemStack playerItem;
17 + private final ItemStack armorStandItem;
18 + private final EquipmentSlot slot;
19 +
20 + public PlayerArmorStandManipulateEvent(final Player who, final ArmorStand clickedEntity, final ItemStack playerItem, final ItemStack armorStandItem, final EquipmentSlot slot) {
21 + super(who, clickedEntity);
22 + this.playerItem = playerItem;
23 + this.armorStandItem = armorStandItem;
24 + this.slot = slot;
25 + }
26 +
27 + /**
28 + * Returns the item held by the player. If this Item is null and the armor stand Item is also null,
29 + * there will be no transaction between the player and the armor stand.
30 + * If the Player's item is null, but the armor stand item is not then the player will obtain the armor stand item.
31 + * 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.
32 + * If both items are not null, the items will be swapped.
33 + * In the case that the event is cancelled the original items will remain the same.
34 + * @return the item held by the player.
35 + */
36 + public ItemStack getPlayerItem() {
37 + return this.playerItem;
38 + }
39 +
40 + /**
41 + * Returns the item held by the armor stand.
42 + * 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.
43 + * If the Player's item is null, but the armor stand item is not then the player will obtain the armor stand item.
44 + * 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.
45 + * If both items are not null, the items will be swapped.
46 + * In the case that the event is cancelled the original items will remain the same.
47 + * @return the item held by the armor stand.
48 + */
49 + public ItemStack getArmorStandItem() {
50 + return this.armorStandItem;
51 + }
52 +
53 + /**
54 + * Returns the raw item slot of the armor stand in this event.
55 + *
56 + * @return the index of the item obtained or placed of the armor stand.
57 + */
58 + public EquipmentSlot getSlot() {
59 + return this.slot;
60 + }
61 +
62 + @Override
63 + public ArmorStand getRightClicked() {
64 + return (ArmorStand) this.clickedEntity;
65 + }
66 +
67 + @Override
68 + public HandlerList getHandlers() {
69 + return handlers;
70 + }
71 +
72 + public static HandlerList getHandlerList() {
73 + return handlers;
74 + }
75 +}

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut