3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00
Paper/patches/api/0376-Add-EquipmentSlot-convenience-methods.patch

39 Zeilen
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: SoSeDiK <mrsosedik@gmail.com>
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
2024-04-23 19:02:08 +02:00
index d776a0c183737efcaf94f0911f3a8c1adc2c5ada..e19e708e9bda10e99c07763d162cb140d0189147 100644
--- a/src/main/java/org/bukkit/inventory/EquipmentSlot.java
+++ b/src/main/java/org/bukkit/inventory/EquipmentSlot.java
2024-04-23 19:02:08 +02:00
@@ -32,4 +32,27 @@ public enum EquipmentSlot {
public EquipmentSlotGroup getGroup() {
return group;
}
+ // 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;
+ }
+
+ /**
+ * Checks whether this equipment slot
+ * is one of the armor slots:
+ * {@link #HEAD}, {@link #CHEST},
2024-04-23 19:02:08 +02:00
+ * {@link #LEGS}, {@link #FEET}, or {@link #BODY}
+ *
+ * @return whether this is an armor slot
+ */
+ public boolean isArmor() {
2024-04-23 19:02:08 +02:00
+ return this == HEAD || this == CHEST || this == LEGS || this == FEET || this == BODY;
+ }
+ // Paper end
}