From 7ac2b8139e4a482a804d9df2b48469e16fd48554 Mon Sep 17 00:00:00 2001 From: kashike Date: Fri, 22 Apr 2016 00:07:16 -0700 Subject: [PATCH] Arrow pickup rule API --- .../0037-Arrow-pickup-rule-API.patch | 45 ++++++++++++++ .../0145-Arrow-pickup-rule-API.patch | 58 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 Spigot-API-Patches/0037-Arrow-pickup-rule-API.patch create mode 100644 Spigot-Server-Patches/0145-Arrow-pickup-rule-API.patch diff --git a/Spigot-API-Patches/0037-Arrow-pickup-rule-API.patch b/Spigot-API-Patches/0037-Arrow-pickup-rule-API.patch new file mode 100644 index 0000000000..7486907629 --- /dev/null +++ b/Spigot-API-Patches/0037-Arrow-pickup-rule-API.patch @@ -0,0 +1,45 @@ +From 1d016100e49bc72ca46633c664e9d3632029ccda Mon Sep 17 00:00:00 2001 +From: Jedediah Smith +Date: Fri, 4 Mar 2016 03:13:18 -0500 +Subject: [PATCH] Arrow pickup rule API + + +diff --git a/src/main/java/org/bukkit/entity/Arrow.java b/src/main/java/org/bukkit/entity/Arrow.java +index e7a32f7..08095b9 100644 +--- a/src/main/java/org/bukkit/entity/Arrow.java ++++ b/src/main/java/org/bukkit/entity/Arrow.java +@@ -40,6 +40,31 @@ public interface Arrow extends Projectile { + */ + public void setCritical(boolean critical); + ++ // Paper start ++ /** ++ * Gets the {@link PickupRule} for this arrow. ++ * ++ *

This is generally {@link PickupRule#ALLOWED} only if the arrow was ++ * not fired from a bow with the infinity enchantment.

++ * ++ * @return The pickup rule ++ */ ++ PickupRule getPickupRule(); ++ ++ /** ++ * Set the rule for which players can pickup this arrow as an item. ++ * ++ * @param rule The pickup rule ++ */ ++ void setPickupRule(PickupRule rule); ++ ++ enum PickupRule { ++ DISALLOWED, ++ ALLOWED, ++ CREATIVE_ONLY; ++ } ++ // Paper end ++ + public class Spigot extends Entity.Spigot + { + +-- +2.7.4 + diff --git a/Spigot-Server-Patches/0145-Arrow-pickup-rule-API.patch b/Spigot-Server-Patches/0145-Arrow-pickup-rule-API.patch new file mode 100644 index 0000000000..991bfb6371 --- /dev/null +++ b/Spigot-Server-Patches/0145-Arrow-pickup-rule-API.patch @@ -0,0 +1,58 @@ +From 938a57611c9161b6d96210b64980c239fb22c0f7 Mon Sep 17 00:00:00 2001 +From: Jedediah Smith +Date: Fri, 4 Mar 2016 03:16:11 -0500 +Subject: [PATCH] Arrow pickup rule API + + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +index 2a3482c..fbf289f 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +@@ -72,6 +72,44 @@ public class CraftArrow extends AbstractProjectile implements Arrow { + getHandle().shooter = ((CraftLivingEntity) shooter).getHandle(); + } + ++ // Paper start ++ @Override ++ public PickupRule getPickupRule() { ++ return convertPickupRule(this.getHandle().fromPlayer); ++ } ++ ++ @Override ++ public void setPickupRule(PickupRule rule) { ++ this.getHandle().fromPlayer = convertPickupRule(rule); ++ } ++ ++ public static PickupRule convertPickupRule(EntityArrow.PickupStatus nms) { ++ switch (nms) { ++ case DISALLOWED: ++ return PickupRule.DISALLOWED; ++ case ALLOWED: ++ return PickupRule.ALLOWED; ++ case CREATIVE_ONLY: ++ return PickupRule.CREATIVE_ONLY; ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ ++ public static EntityArrow.PickupStatus convertPickupRule(PickupRule bukkit) { ++ switch (bukkit) { ++ case DISALLOWED: ++ return EntityArrow.PickupStatus.DISALLOWED; ++ case ALLOWED: ++ return EntityArrow.PickupStatus.ALLOWED; ++ case CREATIVE_ONLY: ++ return EntityArrow.PickupStatus.CREATIVE_ONLY; ++ default: ++ throw new IllegalStateException(); ++ } ++ } ++ // Paper end ++ + // Spigot start + private final Arrow.Spigot spigot = new Arrow.Spigot() + { +-- +2.7.4 +