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-05-09 22:50:09 +02:00
|
|
|
index bbc7f97748f5b61047a9b01a2ecb8c2d0a7b677c..b14cec316b16e46d54d389650372c5c9ce1e5a4d 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-05-09 22:50:09 +02:00
|
|
|
@@ -398,13 +398,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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|