RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
EquipmentType.java
1package com.osroyale.game.world.items.containers.equipment;
2
3import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
4import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
5
6import java.util.Arrays;
7
46
47public enum EquipmentType {
48 NOT_WIELDABLE(-1, "NONE"),
49 HAT(0, "head"),
50 HELM(0, "head"),
51 MASK(0, "head"),
52 FACE(0, "head"),
53 CAPE(1, "cape"),
54 SHIELD(5, "shield"),
55 GLOVES(9, "hands"),
56 BOOTS(10, "feet"),
57 AMULET(2, "neck"),
58 RING(12, "ring"),
59 ARROWS(13, "ammo"),
60 BODY(4, "body"),
61 TORSO(4, "body"),
62 LEGS(7, "legs"),
63 WEAPON(3, "weapon");
64
65 private final int slot;
66 private final String newItemDefName;
67
68 EquipmentType(final int slot, final String newItemDefName) {
69 this.slot = slot;
70 this.newItemDefName = newItemDefName;
71 }
72
73 public int getSlot() {
74 return slot;
75 }
76
77 public String getNewItemDefName() {
78 return newItemDefName;
79 }
80
81 public static final EquipmentType[] values = values();
82
83 private static final Object2ObjectMap<String, EquipmentType> newNameToType
84 = new Object2ObjectOpenHashMap<>(values.length);
85
86 static {
87 for (EquipmentType value : values) {
88 newNameToType.putIfAbsent(value.getNewItemDefName(), value);
89 }
90 }
91
92 public static EquipmentType forNewName(final String newItemDefName) {
93 return newNameToType.get(newItemDefName);
94 }
95
96 public static EquipmentType lookup(int slot) {
97 return Arrays.stream(values()).filter(it -> it.slot == slot).findFirst().orElse(EquipmentType.NOT_WIELDABLE);
98 }
99
100}