2021-01-30 17:09:13 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: BillyGalbreath <blake.galbreath@gmail.com>
|
|
|
|
Date: Wed, 20 Jan 2021 14:23:37 -0600
|
|
|
|
Subject: [PATCH] Allow adding items to BlockDropItemEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2021-03-03 23:43:45 +01:00
|
|
|
index 479270bae88f10de80c6fe97536ac7d2c198a6f2..82e36ba35c0bd4d5b3e13281bad1a0664c25c6e0 100644
|
2021-01-30 17:09:13 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2021-03-03 23:43:45 +01:00
|
|
|
@@ -381,13 +381,30 @@ public class CraftEventFactory {
|
2021-01-30 17:09:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void handleBlockDropItemEvent(Block block, BlockState state, EntityPlayer player, List<EntityItem> items) {
|
|
|
|
- BlockDropItemEvent event = new BlockDropItemEvent(block, state, player.getBukkitEntity(), Lists.transform(items, (item) -> (org.bukkit.entity.Item) item.getBukkitEntity()));
|
|
|
|
+ // Paper start
|
|
|
|
+ List<Item> list = new ArrayList<>();
|
|
|
|
+ for (EntityItem item : items) {
|
|
|
|
+ list.add((Item) item.getBukkitEntity());
|
|
|
|
+ }
|
|
|
|
+ BlockDropItemEvent event = new BlockDropItemEvent(block, state, player.getBukkitEntity(), list);
|
|
|
|
+ // Paper end
|
|
|
|
Bukkit.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
- for (EntityItem item : items) {
|
|
|
|
- item.world.addEntity(item);
|
|
|
|
+ // Paper start
|
|
|
|
+ for (Item bukkit : list) {
|
|
|
|
+ if (!bukkit.isValid()) {
|
|
|
|
+ Entity item = ((org.bukkit.craftbukkit.entity.CraftItem) bukkit).getHandle();
|
|
|
|
+ item.world.addEntity(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (Item bukkit : list) {
|
|
|
|
+ if (bukkit.isValid()) {
|
|
|
|
+ bukkit.remove();
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|