mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 17:01:56 +01:00
Arrow pickup rule API
This commit is contained in:
parent
c385ec89b5
commit
a1de1619c6
2 changed files with 99 additions and 0 deletions
43
Spigot-API-Patches/Arrow-pickup-rule-API.patch
Normal file
43
Spigot-API-Patches/Arrow-pickup-rule-API.patch
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
||||||
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Arrow.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Arrow.java
|
||||||
|
@@ -0,0 +0,0 @@ public interface Arrow extends Projectile {
|
||||||
|
*/
|
||||||
|
public void setCritical(boolean critical);
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ /**
|
||||||
|
+ * Gets the {@link PickupRule} for this arrow.
|
||||||
|
+ *
|
||||||
|
+ * <p>This is generally {@link PickupRule#ALLOWED} only if the arrow was
|
||||||
|
+ * <b>not</b> fired from a bow with the infinity enchantment.</p>
|
||||||
|
+ *
|
||||||
|
+ * @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
|
||||||
|
{
|
||||||
|
|
||||||
|
--
|
56
Spigot-Server-Patches/Arrow-pickup-rule-API.patch
Normal file
56
Spigot-Server-Patches/Arrow-pickup-rule-API.patch
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
||||||
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
|
||||||
|
@@ -0,0 +0,0 @@ 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()
|
||||||
|
{
|
||||||
|
--
|
Loading…
Reference in a new issue