From d1017aa606641c7d6aad620918e44d5b33b4588f Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Tue, 9 Mar 2021 08:47:28 +1100 Subject: [PATCH] #591: Add option for a consumer before spawning an item By: Martoph --- paper-api/src/main/java/org/bukkit/World.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index f36ad196f5..3240d10111 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -471,6 +471,18 @@ public interface World extends PluginMessageRecipient, Metadatable { @NotNull public Item dropItem(@NotNull Location location, @NotNull ItemStack item); + /** + * Drops an item at the specified {@link Location} + * Note that functions will run before the entity is spawned + * + * @param location Location to drop the item + * @param item ItemStack to drop + * @param function the function to be run before the entity is spawned. + * @return ItemDrop entity created as a result of this method + */ + @NotNull + public Item dropItem(@NotNull Location location, @NotNull ItemStack item, @Nullable Consumer function); + /** * Drops an item at the specified {@link Location} with a random offset * @@ -481,6 +493,18 @@ public interface World extends PluginMessageRecipient, Metadatable { @NotNull public Item dropItemNaturally(@NotNull Location location, @NotNull ItemStack item); + /** + * Drops an item at the specified {@link Location} with a random offset + * Note that functions will run before the entity is spawned + * + * @param location Location to drop the item + * @param item ItemStack to drop + * @param function the function to be run before the entity is spawned. + * @return ItemDrop entity created as a result of this method + */ + @NotNull + public Item dropItemNaturally(@NotNull Location location, @NotNull ItemStack item, @Nullable Consumer function); + /** * Creates an {@link Arrow} entity at the given {@link Location} *