Extend HumanEntity#dropItem API (#11810)

This commit is contained in:
Strokkur24
2024-12-28 23:47:21 +01:00
committed by GitHub
parent 18da1ae4c0
commit 93a3df085c
4 changed files with 168 additions and 6 deletions

View File

@@ -1342,17 +1342,18 @@
}
public SectionPos getLastSectionPos() {
@@ -1930,21 +_,54 @@
@@ -1930,21 +_,55 @@
}
@Override
- public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem) {
+ public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem, boolean callEvent) { // CraftBukkit - SPIGOT-2942: Add boolean to call event
+ public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem, boolean callEvent, @Nullable java.util.function.Consumer<org.bukkit.entity.Item> entityOperation) { // Paper start - Extend HumanEntity#dropItem API
ItemEntity itemEntity = this.createItemStackToDrop(droppedItem, dropAround, traceItem);
if (itemEntity == null) {
return null;
} else {
+ // CraftBukkit start - fire PlayerDropItemEvent
+ if (entityOperation != null) entityOperation.accept((org.bukkit.entity.Item) itemEntity.getBukkitEntity());
+ if (callEvent) {
+ org.bukkit.entity.Player player = this.getBukkitEntity();
+ org.bukkit.entity.Item drop = (org.bukkit.entity.Item) itemEntity.getBukkitEntity();