Paper/patches/api/0062-Improve-the-Saddle-API-for-Horses.patch

89 lines
3.2 KiB
Diff
Raw Permalink Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 10 Dec 2016 16:12:48 -0500
Subject: [PATCH] Improve the Saddle API for Horses
Not all horses with Saddles have armor. This lets us break up the horses with saddles
and access their saddle state separately from an interface shared with Armor.
diff --git a/src/main/java/org/bukkit/inventory/ArmoredHorseInventory.java b/src/main/java/org/bukkit/inventory/ArmoredHorseInventory.java
new file mode 100644
index 0000000000000000000000000000000000000000..994f34ac2062c092c2b4e5ff364067482d19588c
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/org/bukkit/inventory/ArmoredHorseInventory.java
@@ -0,0 +1,22 @@
2021-06-11 14:02:28 +02:00
+package org.bukkit.inventory;
+
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
2021-06-11 14:02:28 +02:00
+
+@NullMarked
2021-06-11 14:02:28 +02:00
+public interface ArmoredHorseInventory extends AbstractHorseInventory {
+
+ /**
+ * Gets the item in the horse's armor slot.
+ *
+ * @return the armor item
+ */
+ @Nullable ItemStack getArmor();
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Sets the item in the horse's armor slot.
+ *
+ * @param stack the new item
+ */
+ void setArmor(@Nullable ItemStack stack);
+}
diff --git a/src/main/java/org/bukkit/inventory/HorseInventory.java b/src/main/java/org/bukkit/inventory/HorseInventory.java
index 608e99c4207405bf9dd88d44ad8e82eefa19e45c..53498debe4cfb80592ef3025270bc8e5df4a5fec 100644
--- a/src/main/java/org/bukkit/inventory/HorseInventory.java
+++ b/src/main/java/org/bukkit/inventory/HorseInventory.java
@@ -5,20 +5,4 @@ import org.jetbrains.annotations.Nullable;
/**
* An interface to the inventory of a Horse.
*/
-public interface HorseInventory extends AbstractHorseInventory {
-
- /**
- * Gets the item in the horse's armor slot.
- *
- * @return the armor item
- */
- @Nullable
- ItemStack getArmor();
-
- /**
- * Sets the item in the horse's armor slot.
- *
- * @param stack the new item
- */
- void setArmor(@Nullable ItemStack stack);
-}
+public interface HorseInventory extends AbstractHorseInventory, ArmoredHorseInventory {}
diff --git a/src/main/java/org/bukkit/inventory/LlamaInventory.java b/src/main/java/org/bukkit/inventory/LlamaInventory.java
index 2fa2c9d07ecbafaf2396d913af90f1f4d432b238..5ac1afb8a213fa0fe344db4730ecbc5de6eed445 100644
--- a/src/main/java/org/bukkit/inventory/LlamaInventory.java
+++ b/src/main/java/org/bukkit/inventory/LlamaInventory.java
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable;
/**
* An interface to the inventory of a {@link Llama}.
*/
-public interface LlamaInventory extends AbstractHorseInventory {
+public interface LlamaInventory extends SaddledHorseInventory {
/**
* Gets the item in the llama's decor slot.
diff --git a/src/main/java/org/bukkit/inventory/SaddledHorseInventory.java b/src/main/java/org/bukkit/inventory/SaddledHorseInventory.java
new file mode 100644
index 0000000000000000000000000000000000000000..0f508a8df87f1e23764152d00e02a3da5131f034
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/org/bukkit/inventory/SaddledHorseInventory.java
@@ -0,0 +1,7 @@
2021-06-11 14:02:28 +02:00
+package org.bukkit.inventory;
+
+import org.jspecify.annotations.NullMarked;
+
+@NullMarked
+public interface SaddledHorseInventory extends AbstractHorseInventory {
+}