From 2d9e357a45ad53d20493bba0091dd9dbeeacabd3 Mon Sep 17 00:00:00 2001 From: Strokkur24 <133226102+Strokkur424@users.noreply.github.com> Date: Tue, 24 Dec 2024 15:04:02 +0100 Subject: [PATCH] Remove thrower and 'empty' overloads --- .../java/org/bukkit/entity/HumanEntity.java | 42 ++----------------- .../craftbukkit/entity/CraftHumanEntity.java | 17 ++++---- 2 files changed, 12 insertions(+), 47 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java b/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java index f275331ac1..c293d013c7 100644 --- a/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java @@ -708,76 +708,42 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder */ public boolean dropItem(boolean dropAll); - /** - * Makes the entity drop the first declared {@link ItemStack} occurrence in the inventory - * - * @param itemStack The ItemStack to drop - * @return The dropped item, or null if the action was unsuccessful - */ - public default @Nullable Item dropItem(final @NotNull ItemStack itemStack) { - return this.dropItem(itemStack, null, false); - } - /** * Makes the entity drop an item from their inventory based on the specified ItemStack. *
- * This method calls {@link HumanEntity#dropItem(int slot, UUID thrower, boolean throwRandomly)} + * This method calls {@link HumanEntity#dropItem(int slot, boolean throwRandomly)} * with the first {@link ItemStack} occurrence in the inventory * * @param itemStack The ItemStack to drop - * @param thrower The {@link UUID} to set the resulting {@link Item}'s thrower to * @param throwRandomly Whether the item should disperse randomly. * This means that instead of the item being dropped where the player is currently looking, * it instead throws it in any direction, similar to how items drop after a player's death. * @return The dropped item, or null if the action was unsuccessful */ - public @Nullable Item dropItem(final @NotNull ItemStack itemStack, final @Nullable UUID thrower, final boolean throwRandomly); - - /** - * Makes the entity drop an item from their inventory based on the slot. - * - * @param slot The slot to drop - * @return The dropped item, or null if the action was unsuccessful - * @throws IndexOutOfBoundsException If the slot is negative or bigger than the player's inventory - */ - public default @Nullable Item dropItem(final int slot) { - return this.dropItem(slot, null, false); - } + public @Nullable Item dropItem(final @NotNull ItemStack itemStack, final boolean throwRandomly); /** * Makes the entity drop an item from their inventory based on the slot. * * @param slot The slot to drop - * @param thrower The {@link UUID} to set the resulting {@link Item}'s thrower to * @param throwRandomly Whether the item should disperse randomly. * This means that instead of the item being dropped where the player is currently looking, * it instead throws it in any direction, similar to how items drop after a player's death. * @return The dropped item entity, or null if the action was unsuccessful * @throws IndexOutOfBoundsException If the slot is negative or bigger than the player's inventory */ - public @Nullable Item dropItem(final int slot, final @Nullable UUID thrower, final boolean throwRandomly); - - /** - * Makes the entity drop an item from their inventory based on the {@link EquipmentSlot} - * - * @param slot The equipment slot to drop - * @return The dropped item entity, or null if the action was unsuccessful - */ - public default @Nullable Item dropItem(final @NotNull EquipmentSlot slot) { - return this.dropItem(slot, null, false); - } + public @Nullable Item dropItem(final int slot, final boolean throwRandomly); /** * Makes the player drop an item from their inventory based on the equipment slot. * * @param slot The equipment slot to drop - * @param thrower The {@link UUID} to set the resulting {@link Item}'s thrower to * @param throwRandomly Whether the item should disperse randomly. * This means that instead of the item being dropped where the player is currently looking, * it instead throws it in any direction, similar to how items drop after a player's death. * @return The dropped item entity, or null if the action was unsuccessful */ - public @Nullable Item dropItem(final @NotNull EquipmentSlot slot, final @Nullable UUID thrower, final boolean throwRandomly); + public @Nullable Item dropItem(final @NotNull EquipmentSlot slot, final boolean throwRandomly); /** diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 96cf69b490..f954d1b907 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -807,49 +807,48 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } @Override - public @Nullable Item dropItem(final @NotNull ItemStack itemStack, final @Nullable UUID thrower, final boolean throwRandomly) { + public @Nullable Item dropItem(final @NotNull ItemStack itemStack, final boolean throwRandomly) { final int slot = this.inventory.first(itemStack); if (slot == -1) { return null; } - return this.dropItem(slot, thrower, throwRandomly); + return this.dropItem(slot, throwRandomly); } @Override - public @Nullable Item dropItem(final int slot, final @Nullable UUID thrower, final boolean throwRandomly) { + public @Nullable Item dropItem(final int slot, final boolean throwRandomly) { // Make sure the slot is in bounds if (slot < 0 || slot >= this.inventory.getSize()) { throw new IndexOutOfBoundsException("Slot " + slot + " out of range for inventory of size " + this.inventory.getSize()); } final ItemStack stack = this.inventory.getItem(slot); - final Item itemEntity = dropItemRaw(stack, thrower, throwRandomly); + final Item itemEntity = dropItemRaw(stack, throwRandomly); this.inventory.setItem(slot, null); return itemEntity; } @Override - public @Nullable Item dropItem(final @NotNull EquipmentSlot slot, final @Nullable UUID thrower, final boolean throwRandomly) { + public @Nullable Item dropItem(final @NotNull EquipmentSlot slot, final boolean throwRandomly) { final ItemStack stack = this.inventory.getItem(slot); - final Item itemEntity = dropItemRaw(stack, thrower, throwRandomly); + final Item itemEntity = dropItemRaw(stack, throwRandomly); this.inventory.setItem(slot, null); return itemEntity; } - private Item dropItemRaw(final ItemStack itemStack, final @Nullable UUID thrower, final boolean throwRandomly) { + private Item dropItemRaw(final ItemStack itemStack, final boolean throwRandomly) { if (itemStack == null || itemStack.isEmpty()) { return null; } - final ItemEntity droppedEntity = this.getHandle().drop(CraftItemStack.asNMSCopy(itemStack), throwRandomly); + final ItemEntity droppedEntity = this.getHandle().drop(CraftItemStack.asNMSCopy(itemStack), throwRandomly, true); if (droppedEntity == null) { return null; } - droppedEntity.thrower = thrower; return (Item) droppedEntity.getBukkitEntity(); }