Yeah, my bad, here
Code:
public static int getSlot(Client client, int id) {
String itemName = ItemAssistant.getName(id).toLowerCase();
for (Type type : Type.values()) {
for (String names : type.names) {
if (names.contains(itemName)) {
return type.ordinal();
}
}
}
return 3; //default slot
}
This is how I just added it to my server btw:
Code:
private enum Type {
HELMET(Equipment.HELMET_SLOT, "helm", "hat", "hood"),
CAPE(Equipment.CAPE_SLOT, "cape"),
AMULET(Equipment.AMULET_SLOT, "amulet", "necklace"),
CHEST(Equipment.BODY_SLOT, "body", "chest", "top"),
SHIELD(Equipment.SHIELD_SLOT, "shield"),
LEGS(Equipment.LEG_SLOT, "legs", "bottom"),
GLOVES(Equipment.HANDS_SLOT, "gloves", "gauntlets"),
RING(Equipment.RING_SLOT, "ring"),
AMMUNITION(Equipment.AMMUNITION_SLOT, "arrow", "bolt");
private Type(int slot, String... names) {
this.slot = slot;
this.names = names;
}
private int slot;
private String[] names;
}
private static void addSlotDefinition(int id) {
for (Type type : Type.values()) {
for (String names : type.names) {
if (forId(id).name.toLowerCase().contains(names)) {
forId(id).slot = type.slot;
System.out.println("Added slot for item " + id + " to slot " + type.slot);
}
}
}
}
private void getValues(DataInputStream in) {
try {
do {
int opcode = in.readByte();
if(opcode == 0)
return;
if(opcode == 1) {
name = in.readUTF();
addSlotDefinition(id);
} else if(opcode == 2) {
....