mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-09 16:42:03 -07:00
@@ -1,82 +1,82 @@
|
|||||||
package org.bukkit.event.player;
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player interacts with an armor stand and will either swap, retrieve or place an item.
|
* Called when a player interacts with an armor stand and will either swap, retrieve or place an item.
|
||||||
*/
|
*/
|
||||||
public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent {
|
public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private final ItemStack playerItem;
|
private final ItemStack playerItem;
|
||||||
private final ItemStack armorStandItem;
|
private final ItemStack armorStandItem;
|
||||||
private final EquipmentSlot slot;
|
private final EquipmentSlot slot;
|
||||||
|
|
||||||
public PlayerArmorStandManipulateEvent(@NotNull final Player who, @NotNull final ArmorStand clickedEntity, @NotNull final ItemStack playerItem, @NotNull final ItemStack armorStandItem, @NotNull final EquipmentSlot slot) {
|
public PlayerArmorStandManipulateEvent(@NotNull final Player who, @NotNull final ArmorStand clickedEntity, @NotNull final ItemStack playerItem, @NotNull final ItemStack armorStandItem, @NotNull final EquipmentSlot slot) {
|
||||||
super(who, clickedEntity);
|
super(who, clickedEntity);
|
||||||
this.playerItem = playerItem;
|
this.playerItem = playerItem;
|
||||||
this.armorStandItem = armorStandItem;
|
this.armorStandItem = armorStandItem;
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the item held by the player. If this Item is null and the armor stand Item is also null,
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* In the case that the event is cancelled the original items will remain the same.
|
||||||
* @return the item held by the player.
|
* @return the item held by the player.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public ItemStack getPlayerItem() {
|
public ItemStack getPlayerItem() {
|
||||||
return this.playerItem;
|
return this.playerItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the item held by the armor stand.
|
* 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 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.
|
* 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.
|
* 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.
|
* 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.
|
* In the case that the event is cancelled the original items will remain the same.
|
||||||
* @return the item held by the armor stand.
|
* @return the item held by the armor stand.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public ItemStack getArmorStandItem() {
|
public ItemStack getArmorStandItem() {
|
||||||
return this.armorStandItem;
|
return this.armorStandItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the raw item slot of the armor stand in this event.
|
* 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.
|
* @return the index of the item obtained or placed of the armor stand.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public EquipmentSlot getSlot() {
|
public EquipmentSlot getSlot() {
|
||||||
return this.slot;
|
return this.slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getRightClicked() {
|
public ArmorStand getRightClicked() {
|
||||||
return (ArmorStand) this.clickedEntity;
|
return (ArmorStand) this.clickedEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user