Add EquipmentSlot convenience methods (#8477)
This commit is contained in:
parent
4e67c73b03
commit
d713b47b14
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add LivingEntity#swingHand(EquipmentSlot) convenience method
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
index 4af5e8d0cba6555f7615e4e809d9aff221c0dc4d..319e4571aca24d1e3f6c85b7435d65c0e77a5245 100644
|
||||
index 4af5e8d0cba6555f7615e4e809d9aff221c0dc4d..435e214af7f09b3f1da078e6517cd14bb5ad2b87 100644
|
||||
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
@@ -985,5 +985,23 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
|
||||
|
@ -23,7 +23,7 @@ index 4af5e8d0cba6555f7615e4e809d9aff221c0dc4d..319e4571aca24d1e3f6c85b7435d65c0
|
|||
+ * @throws IllegalArgumentException if invalid hand is passed
|
||||
+ */
|
||||
+ default void swingHand(@NotNull org.bukkit.inventory.EquipmentSlot hand) {
|
||||
+ com.google.common.base.Preconditions.checkArgument(hand == org.bukkit.inventory.EquipmentSlot.HAND || hand == org.bukkit.inventory.EquipmentSlot.OFF_HAND, String.format("Expected a valid hand, got \"%s\" instead!", hand));
|
||||
+ com.google.common.base.Preconditions.checkArgument(hand != null && hand.isHand(), String.format("Expected a valid hand, got \"%s\" instead!", hand));
|
||||
+ if (hand == org.bukkit.inventory.EquipmentSlot.HAND) {
|
||||
+ this.swingMainHand();
|
||||
+ } else {
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
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
|
||||
index 1e7d77118a55ca9db99eabb94894e6ef3409946b..8f793982d0ceeb949422fe3f125fb08229d3266a 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/EquipmentSlot.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/EquipmentSlot.java
|
||||
@@ -8,4 +8,28 @@ public enum EquipmentSlot {
|
||||
LEGS,
|
||||
CHEST,
|
||||
HEAD
|
||||
+ // 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},
|
||||
+ * {@link #LEGS}, or {@link #FEET}
|
||||
+ *
|
||||
+ * @return whether this is an armor slot
|
||||
+ */
|
||||
+ public boolean isArmor() {
|
||||
+ return this == HEAD || this == CHEST || this == LEGS || this == FEET;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
Loading…
Reference in New Issue