aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0366-Add-EquipmentSlot-convenience-methods.patch
diff options
context:
space:
mode:
authorFabrizio La Rosa <[email protected]>2024-09-08 22:12:36 +0200
committerGitHub <[email protected]>2024-09-08 22:12:36 +0200
commit971a7a5511b3c656b96a9be66ec9848915eb6d3d (patch)
tree14db760bce66a267a4e0bdbb7da01a675c2bf750 /patches/api/0366-Add-EquipmentSlot-convenience-methods.patch
parentb09eaf2e8d15fea856005f6727638b753850c8d1 (diff)
downloadPaper-971a7a5511b3c656b96a9be66ec9848915eb6d3d.tar.gz
Paper-971a7a5511b3c656b96a9be66ec9848915eb6d3d.zip
Add Decorated Pot Cracked API (#11365)
Diffstat (limited to 'patches/api/0366-Add-EquipmentSlot-convenience-methods.patch')
-rw-r--r--patches/api/0366-Add-EquipmentSlot-convenience-methods.patch53
1 files changed, 53 insertions, 0 deletions
diff --git a/patches/api/0366-Add-EquipmentSlot-convenience-methods.patch b/patches/api/0366-Add-EquipmentSlot-convenience-methods.patch
new file mode 100644
index 0000000000..f7e2301f31
--- /dev/null
+++ b/patches/api/0366-Add-EquipmentSlot-convenience-methods.patch
@@ -0,0 +1,53 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: SoSeDiK <[email protected]>
+Date: Sun, 16 Oct 2022 15:28:49 +0300
+Subject: [PATCH] Add EquipmentSlot convenience methods
+
+
+diff --git a/src/main/java/org/bukkit/inventory/EquipmentSlot.java b/src/main/java/org/bukkit/inventory/EquipmentSlot.java
+index 5642d8af60b6649497aba9b0f6ab7bba7702b9ee..c1c69ba4c361740f0ad422a7840a7f0f055c186a 100644
+--- a/src/main/java/org/bukkit/inventory/EquipmentSlot.java
++++ b/src/main/java/org/bukkit/inventory/EquipmentSlot.java
+@@ -33,4 +33,42 @@ public enum EquipmentSlot {
+ public EquipmentSlotGroup getGroup() {
+ return group.get();
+ }
++ // Paper start
++ /**
++ * Checks whether this equipment slot is a hand:
++ * either {@link #HAND} or {@link #OFF_HAND}
++ *
++ * @return whether this is a hand slot
++ */
++ public boolean isHand() {
++ return this == HAND || this == OFF_HAND;
++ }
++
++ /**
++ * Gets the opposite hand
++ *
++ * @return the opposite hand
++ * @throws IllegalArgumentException if this equipment slot is not a hand
++ * @see #isHand()
++ */
++ public @NotNull EquipmentSlot getOppositeHand() {
++ return switch (this) {
++ case HAND -> OFF_HAND;
++ case OFF_HAND -> HAND;
++ default -> throw new IllegalArgumentException("Unable to determine an opposite hand for equipment slot: " + name());
++ };
++ }
++
++ /**
++ * Checks whether this equipment slot
++ * is one of the armor slots:
++ * {@link #HEAD}, {@link #CHEST},
++ * {@link #LEGS}, {@link #FEET}, or {@link #BODY}
++ *
++ * @return whether this is an armor slot
++ */
++ public boolean isArmor() {
++ return this == HEAD || this == CHEST || this == LEGS || this == FEET || this == BODY;
++ }
++ // Paper end
+ }