From 3212d9fcf5d3eacc28e681d18f9094e116968e86 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 7 Feb 2023 07:43:20 -0800 Subject: [PATCH] Deprecate duplicate API for arrow stuck count (#8829) --- ...working-with-arrows-stuck-in-living-.patch | 35 +++++++++++++++++++ ...e-shield-blocking-delay-configurable.patch | 2 +- patches/api/Stinger-API.patch | 2 +- ...working-with-arrows-stuck-in-living-.patch | 25 +++++++++++-- ...e-shield-blocking-delay-configurable.patch | 4 +-- patches/server/Stinger-API.patch | 4 +-- 6 files changed, 63 insertions(+), 9 deletions(-) diff --git a/patches/api/Add-methods-for-working-with-arrows-stuck-in-living-.patch b/patches/api/Add-methods-for-working-with-arrows-stuck-in-living-.patch index 7bf465f971..5e04a3cb1b 100644 --- a/patches/api/Add-methods-for-working-with-arrows-stuck-in-living-.patch +++ b/patches/api/Add-methods-for-working-with-arrows-stuck-in-living-.patch @@ -3,11 +3,41 @@ From: mrapple Date: Sun, 25 Nov 2012 13:47:27 -0600 Subject: [PATCH] Add methods for working with arrows stuck in living entities +Upstream added methods for this so the original methods +are now deprecated diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java +@@ -0,0 +0,0 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource + */ + public int getArrowsInBody(); + ++ // Paper start ++ /** ++ * Set the amount of arrows in the entity's body. ++ *

++ * Does not fire the {@link org.bukkit.event.entity.ArrowBodyCountChangeEvent}. ++ * ++ * @param count amount of arrows in entity's body ++ */ ++ default void setArrowsInBody(final int count) { ++ this.setArrowsInBody(count, false); ++ } ++ // Paper end ++ + /** + * Set the amount of arrows in the entity's body. + * + * @param count amount of arrows in entity's body ++ * @param fireEvent whether to fire the {@link org.bukkit.event.entity.ArrowBodyCountChangeEvent} event + */ +- public void setArrowsInBody(int count); ++ void setArrowsInBody(int count, boolean fireEvent); // Paper + + /** + * Returns the living entity's current maximum no damage ticks. @@ -0,0 +0,0 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @return Whether the entity is invisible */ @@ -17,14 +47,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Get the number of arrows stuck in this entity + * @return Number of arrows stuck ++ * @deprecated use {@link #getArrowsInBody()} + */ ++ @Deprecated + int getArrowsStuck(); + + /** + * Set the number of arrows stuck in this entity + * + * @param arrows Number of arrows to stick in this entity ++ * @deprecated use {@link #setArrowsInBody(int, boolean)}. This method previously fired {@link org.bukkit.event.entity.ArrowBodyCountChangeEvent} so if ++ * you want to retain exact functionality, pass {@code true} for {@code fireEvent}. + */ ++ @Deprecated + void setArrowsStuck(int arrows); + // Paper end } diff --git a/patches/api/Make-shield-blocking-delay-configurable.patch b/patches/api/Make-shield-blocking-delay-configurable.patch index 4828258dbf..77ba0ca8de 100644 --- a/patches/api/Make-shield-blocking-delay-configurable.patch +++ b/patches/api/Make-shield-blocking-delay-configurable.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java @@ -0,0 +0,0 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource - * @param arrows Number of arrows to stick in this entity */ + @Deprecated void setArrowsStuck(int arrows); + + /** diff --git a/patches/api/Stinger-API.patch b/patches/api/Stinger-API.patch index 90f33b9c78..854eeae5c0 100644 --- a/patches/api/Stinger-API.patch +++ b/patches/api/Stinger-API.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/entity/LivingEntity.java @@ -0,0 +0,0 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource */ - public void setArrowsInBody(int count); + void setArrowsInBody(int count, boolean fireEvent); // Paper + // Paper Start - Bee Stinger API + /** diff --git a/patches/server/Add-methods-for-working-with-arrows-stuck-in-living-.patch b/patches/server/Add-methods-for-working-with-arrows-stuck-in-living-.patch index 7a2edb4154..ec65d40e92 100644 --- a/patches/server/Add-methods-for-working-with-arrows-stuck-in-living-.patch +++ b/patches/server/Add-methods-for-working-with-arrows-stuck-in-living-.patch @@ -3,11 +3,30 @@ From: mrapple Date: Sun, 25 Nov 2012 13:43:39 -0600 Subject: [PATCH] Add methods for working with arrows stuck in living entities +Upstream added methods for this, original methods are now +deprecated diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { + } + + @Override +- public void setArrowsInBody(int count) { ++ public void setArrowsInBody(final int count, final boolean fireEvent) { // Paper + Preconditions.checkArgument(count >= 0, "New arrow amount must be >= 0"); ++ if (!fireEvent) { // Paper + this.getHandle().getEntityData().set(net.minecraft.world.entity.LivingEntity.DATA_ARROW_COUNT_ID, count); ++ // Paper start ++ } else { ++ this.getHandle().setArrowCount(count); ++ } ++ // Paper end + } + + @Override @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { this.getHandle().persistentInvisibility = invisible; this.getHandle().setSharedFlag(5, invisible); @@ -16,12 +35,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override + public int getArrowsStuck() { -+ return getHandle().getArrowCount(); ++ return this.getHandle().getArrowCount(); + } + + @Override -+ public void setArrowsStuck(int arrows) { -+ getHandle().setArrowCount(arrows); ++ public void setArrowsStuck(final int arrows) { ++ this.getHandle().setArrowCount(arrows); + } + // Paper end } diff --git a/patches/server/Make-shield-blocking-delay-configurable.patch b/patches/server/Make-shield-blocking-delay-configurable.patch index ca6ee08753..d658efd523 100644 --- a/patches/server/Make-shield-blocking-delay-configurable.patch +++ b/patches/server/Make-shield-blocking-delay-configurable.patch @@ -39,8 +39,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { - public void setArrowsStuck(int arrows) { - getHandle().setArrowCount(arrows); + public void setArrowsStuck(final int arrows) { + this.getHandle().setArrowCount(arrows); } + + @Override diff --git a/patches/server/Stinger-API.patch b/patches/server/Stinger-API.patch index cd49e557e7..a0b14cfb94 100644 --- a/patches/server/Stinger-API.patch +++ b/patches/server/Stinger-API.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { - Preconditions.checkArgument(count >= 0, "New arrow amount must be >= 0"); - this.getHandle().getEntityData().set(net.minecraft.world.entity.LivingEntity.DATA_ARROW_COUNT_ID, count); + } + // Paper end } + // Paper Start - Bee Stinger API + @Override