From 5361df84ceb641b1d0df428949c923107e4484db Mon Sep 17 00:00:00 2001 From: Strokkur24 <133226102+Strokkur424@users.noreply.github.com> Date: Tue, 24 Dec 2024 13:15:32 +0100 Subject: [PATCH] Reduce and replace implemented methods with defaults --- .../java/org/bukkit/entity/HumanEntity.java | 48 ++++--------------- .../craftbukkit/entity/CraftHumanEntity.java | 30 ------------ 2 files changed, 10 insertions(+), 68 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 b1d1b759af..91cc11b5f0 100644 --- a/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java @@ -708,27 +708,14 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder // Paper start - Extend HumanEntity#dropItem API /** - * Makes the entity drop an item from their inventory. - *
- * This method calls {@link HumanEntity#dropItem(int slot)} - * with the first {@link ItemStack} occurrence in the inventory + * 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 @Nullable Item dropItem(final @NotNull ItemStack itemStack); - - /** - * Makes the entity drop an item from their inventory. - *
- * This method calls {@link HumanEntity#dropItem(int slot, java.util.UUID thrower)} - * with the first {@link ItemStack} occurrence in the inventory - * - * @param itemStack The ItemStack to drop from their inventory - * @param thrower The {@link java.util.UUID} to set the resulting {@link Item}'s thrower to - * @return The dropped item, or null if the action was unsuccessful - */ - public @Nullable Item dropItem(final @NotNull ItemStack itemStack, final @Nullable java.util.UUID thrower); + 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. @@ -752,17 +739,9 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @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 @Nullable Item dropItem(final int slot); - - /** - * Makes the entity drop an item from their inventory based on the slot. - * - * @param slot The slot to drop - * @param thrower The {@link java.util.UUID} to set the resulting {@link Item}'s thrower to - * @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 @Nullable Item dropItem(final int slot, final @Nullable java.util.UUID thrower); + public default @Nullable Item dropItem(final int slot) { + return this.dropItem(slot, null, false); + } /** * Makes the entity drop an item from their inventory based on the slot. @@ -783,16 +762,9 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @param slot The equipment slot to drop * @return The dropped item entity, or null if the action was unsuccessful */ - public @Nullable Item dropItem(final @NotNull org.bukkit.inventory.EquipmentSlot slot); - - /** - * Makes the entity drop an item from their inventory based on the {@link org.bukkit.inventory.EquipmentSlot} - * - * @param slot The equipment slot to drop - * @param thrower The {@link java.util.UUID} to set the resulting {@link Item}'s thrower to - * @return The dropped item entity, or null if the action was unsuccessful - */ - public @Nullable Item dropItem(final @NotNull org.bukkit.inventory.EquipmentSlot slot, final @Nullable java.util.UUID thrower); + public default @Nullable Item dropItem(final @NotNull org.bukkit.inventory.EquipmentSlot slot) { + return this.dropItem(slot, null, false); + } /** * Makes the player drop an item from their inventory based on the equipment slot. 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 3b225dc19e..a43845e0f9 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 @@ -804,16 +804,6 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } // Paper start - Extend HumanEntity#dropItem API - @Override - public @Nullable org.bukkit.entity.Item dropItem(final @NotNull ItemStack itemStack) { - return this.dropItem(itemStack, null, false); - } - - @Override - public @Nullable org.bukkit.entity.Item dropItem(final @NotNull ItemStack itemStack, final @Nullable java.util.UUID thrower) { - return this.dropItem(itemStack, thrower, false); - } - @Override public @Nullable org.bukkit.entity.Item dropItem(final @NotNull ItemStack itemStack, final @Nullable java.util.UUID thrower, final boolean throwRandomly) { final int slot = this.inventory.first(itemStack); @@ -824,16 +814,6 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return this.dropItem(slot, thrower, throwRandomly); } - @Override - public @Nullable org.bukkit.entity.Item dropItem(final int slot) { - return this.dropItem(slot, null, false); - } - - @Override - public @Nullable org.bukkit.entity.Item dropItem(final int slot, final @Nullable java.util.UUID thrower) { - return this.dropItem(slot, thrower, false); - } - @Override public @Nullable org.bukkit.entity.Item dropItem(final int slot, final @Nullable java.util.UUID thrower, final boolean throwRandomly) { // Make sure the slot is in bounds @@ -848,16 +828,6 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return itemEntity; } - @Override - public @Nullable org.bukkit.entity.Item dropItem(final @NotNull org.bukkit.inventory.EquipmentSlot slot) { - return dropItem(slot, null, false); - } - - @Override - public @Nullable org.bukkit.entity.Item dropItem(final @NotNull org.bukkit.inventory.EquipmentSlot slot, final @Nullable java.util.UUID thrower) { - return dropItem(slot, thrower, false); - } - @Override public @Nullable org.bukkit.entity.Item dropItem(final @NotNull org.bukkit.inventory.EquipmentSlot slot, final @Nullable java.util.UUID thrower, final boolean throwRandomly) { final ItemStack stack = this.inventory.getItem(slot);