diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java new file mode 100644 index 00000000..a33f446f --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java @@ -0,0 +1,35 @@ +package org.bukkit.craftbukkit; + +import org.bukkit.inventory.EquipmentSlot; + +public class CraftEquipmentSlot { + + private static final int[] slots = new int[EquipmentSlot.values().length]; + private static final EquipmentSlot[] enums = new EquipmentSlot[EquipmentSlot.values().length]; + + static { + set(EquipmentSlot.HAND, 0); + set(EquipmentSlot.FEET, 1); + set(EquipmentSlot.LEGS, 2); + set(EquipmentSlot.CHEST, 3); + set(EquipmentSlot.HEAD, 4); + } + + private static void set(EquipmentSlot type, int value) { + slots[type.ordinal()] = value; + if (value < enums.length) { + enums[value] = type; + } + } + + public static EquipmentSlot getSlot(int magic) { + if (magic > 0 && magic < enums.length) { + return enums[magic]; + } + return null; + } + + public static int getSlotIndex(EquipmentSlot slot) { + return slots[slot.ordinal()]; + } +} |