RuneHive-Game
Loading...
Searching...
No Matches
EquipmentType.java
Go to the documentation of this file.
1package com.runehive.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
8/**
9 * The enumerated types of a players equipped item slots.
10 *
11 * @author Daniel
12 */
13public enum EquipmentType {
14 NOT_WIELDABLE(-1, "NONE"),
15 HAT(0, "head"),
16 HELM(0, "head"),
17 MASK(0, "head"),
18 FACE(0, "head"),
19 CAPE(1, "cape"),
20 SHIELD(5, "shield"),
21 GLOVES(9, "hands"),
22 BOOTS(10, "feet"),
23 AMULET(2, "neck"),
24 RING(12, "ring"),
25 ARROWS(13, "ammo"),
26 BODY(4, "body"),
27 TORSO(4, "body"),
28 LEGS(7, "legs"),
29 WEAPON(3, "weapon");
30
31 private final int slot;
32 private final String newItemDefName;
33
34 EquipmentType(final int slot, final String newItemDefName) {
35 this.slot = slot;
36 this.newItemDefName = newItemDefName;
37 }
38
39 public int getSlot() {
40 return slot;
41 }
42
43 public String getNewItemDefName() {
44 return newItemDefName;
45 }
46
47 public static final EquipmentType[] values = values();
48
49 private static final Object2ObjectMap<String, EquipmentType> newNameToType
50 = new Object2ObjectOpenHashMap<>(values.length);
51
52 static {
53 for (EquipmentType value : values) {
54 newNameToType.putIfAbsent(value.getNewItemDefName(), value);
55 }
56 }
57
58 public static EquipmentType forNewName(final String newItemDefName) {
59 return newNameToType.get(newItemDefName);
60 }
61
62 public static EquipmentType lookup(int slot) {
63 return Arrays.stream(values()).filter(it -> it.slot == slot).findFirst().orElse(EquipmentType.NOT_WIELDABLE);
64 }
65
66}
static EquipmentType forNewName(final String newItemDefName)
static final Object2ObjectMap< String, EquipmentType > newNameToType
EquipmentType(final int slot, final String newItemDefName)