#1107: Add getHand() to all relevant events

By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
CraftBukkit/Spigot
2022-10-02 09:07:14 +11:00
parent 34ab403aa0
commit 159ae52462
17 changed files with 145 additions and 82 deletions

View File

@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit;
import net.minecraft.world.EnumHand;
import net.minecraft.world.entity.EnumItemSlot;
import org.bukkit.inventory.EquipmentSlot;
@@ -29,4 +30,18 @@ public class CraftEquipmentSlot {
public static EnumItemSlot getNMS(EquipmentSlot slot) {
return slots[slot.ordinal()];
}
public static EquipmentSlot getHand(EnumHand enumhand) {
return (enumhand == EnumHand.MAIN_HAND) ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND;
}
public static EnumHand getHand(EquipmentSlot hand) {
if (hand == EquipmentSlot.HAND) {
return EnumHand.MAIN_HAND;
} else if (hand == EquipmentSlot.OFF_HAND) {
return EnumHand.OFF_HAND;
}
throw new IllegalArgumentException("EquipmentSlot." + hand + " is not a hand");
}
}