geforkt von Mirrors/Paper
handle BODY slot for non-mobs (#10822)
Dieser Commit ist enthalten in:
Ursprung
cae5734b19
Commit
82ece252bc
@ -182,6 +182,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ *
|
||||
+ * @param slot the equipment slot to get
|
||||
+ * @return the ItemStack in the equipment slot
|
||||
+ * @throws IllegalArgumentException if the slot is invalid for the entity
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ ItemStack getItem(@NotNull final org.bukkit.inventory.EquipmentSlot slot);
|
||||
@ -192,6 +193,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ *
|
||||
+ * @param slot the equipment slot to set
|
||||
+ * @param item the item to hold
|
||||
+ * @throws IllegalArgumentException if the slot is invalid for the entity
|
||||
+ */
|
||||
+ void setItem(@NotNull final org.bukkit.inventory.EquipmentSlot slot, @Nullable final ItemStack item);
|
||||
+
|
||||
|
@ -17,6 +17,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public EquipmentSlot getSlot() {
|
||||
return slot == EquipmentSlotGroup.ANY ? null : slot.getExample();
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/EntityEquipment.java b/src/main/java/org/bukkit/inventory/EntityEquipment.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/EntityEquipment.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/EntityEquipment.java
|
||||
@@ -0,0 +0,0 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param slot the slot to put the ItemStack
|
||||
* @param item the ItemStack to set
|
||||
+ * @throws IllegalArgumentException if the slot is invalid for the entity
|
||||
*/
|
||||
public void setItem(@NotNull EquipmentSlot slot, @Nullable ItemStack item);
|
||||
|
||||
@@ -0,0 +0,0 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param slot the slot to put the ItemStack
|
||||
* @param item the ItemStack to set
|
||||
- * @param silent whether or not the equip sound should be silenced
|
||||
+ * @param silent whether the equip sound should be silenced
|
||||
+ * @throws IllegalArgumentException if the slot is invalid for the entity
|
||||
*/
|
||||
public void setItem(@NotNull EquipmentSlot slot, @Nullable ItemStack item, boolean silent);
|
||||
|
||||
@@ -0,0 +0,0 @@ public interface EntityEquipment {
|
||||
*
|
||||
* @param slot the slot to get the ItemStack
|
||||
* @return the ItemStack in the given slot
|
||||
+ * @throws IllegalArgumentException if the slot is invalid for the entity
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getItem(@NotNull EquipmentSlot slot);
|
||||
diff --git a/src/main/java/org/bukkit/inventory/EquipmentSlotGroup.java b/src/main/java/org/bukkit/inventory/EquipmentSlotGroup.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/EquipmentSlotGroup.java
|
||||
|
@ -23,13 +23,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
+ @Override
|
||||
+ public ItemStack getItem(org.bukkit.inventory.EquipmentSlot slot) {
|
||||
+ com.google.common.base.Preconditions.checkNotNull(slot, "slot");
|
||||
+ com.google.common.base.Preconditions.checkArgument(slot != null, "slot");
|
||||
+ com.google.common.base.Preconditions.checkArgument(slot != EquipmentSlot.BODY, "Cannot get body item");
|
||||
+ return getHandle().getItemBySlot(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot)).asBukkitMirror();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setItem(org.bukkit.inventory.EquipmentSlot slot, ItemStack item) {
|
||||
+ com.google.common.base.Preconditions.checkNotNull(slot, "slot");
|
||||
+ com.google.common.base.Preconditions.checkArgument(slot != null, "slot");
|
||||
+ com.google.common.base.Preconditions.checkArgument(slot != EquipmentSlot.BODY, "Cannot set body item");
|
||||
+ switch (slot) {
|
||||
+ case HAND:
|
||||
+ getEquipment().setItemInMainHand(item);
|
||||
|
@ -5,6 +5,32 @@ Subject: [PATCH] Fix equipment slot and group API
|
||||
|
||||
Add test for EquipmentSlotGroup
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
|
||||
@@ -0,0 +0,0 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
|
||||
case HEAD:
|
||||
this.setHelmet(item);
|
||||
break;
|
||||
+ // Paper start
|
||||
+ case BODY:
|
||||
+ throw new IllegalArgumentException("BODY is not valid for players!");
|
||||
+ // Paper end
|
||||
default:
|
||||
throw new IllegalArgumentException("Not implemented. This is a bug");
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
|
||||
return java.util.Objects.requireNonNullElseGet(this.getChestplate(), () -> new ItemStack(org.bukkit.Material.AIR)); // Paper - make nonnull
|
||||
case HEAD:
|
||||
return java.util.Objects.requireNonNullElseGet(this.getHelmet(), () -> new ItemStack(org.bukkit.Material.AIR)); // Paper - make nonnull
|
||||
+ // Paper start
|
||||
+ case BODY:
|
||||
+ throw new IllegalArgumentException("BODY is not valid for players!");
|
||||
+ // Paper end
|
||||
default:
|
||||
throw new IllegalArgumentException("Not implemented. This is a bug");
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren