From 71c03637bfce74548ab3bfd560e23e8baa3e1e05 Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Wed, 1 May 2024 20:14:27 +0300 Subject: [PATCH] Add EquipmentSlot#getOppositeHand (#10632) --- .../Add-EquipmentSlot-convenience-methods.patch | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/patches/api/Add-EquipmentSlot-convenience-methods.patch b/patches/api/Add-EquipmentSlot-convenience-methods.patch index ad15663718..af4d2da510 100644 --- a/patches/api/Add-EquipmentSlot-convenience-methods.patch +++ b/patches/api/Add-EquipmentSlot-convenience-methods.patch @@ -24,6 +24,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** ++ * 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},