rs2d base v2.1 was used for this
this tutorial is used to make handling equiptment types alot easier
instead of using an array to find all of the item ids and then return it takes forever
it also misses alot of items
instead we are going to find the items by findind if the phrase of the word is in there name
first off head to
net.varek.rs2d.model.EquiptmentTypes
at the top add
Code:
import net.varek.rs2d.cfgloader.ItemLoader;
we'll need this for the method getNameForID
it will also find the name of the item in the item.cfg
now go find
Code:
public static int getItemSlot(int item) {
now instead of finding all the item ids from an integer we are going to find the items by there name which will be place in a txt file
first off import the java.io class so we can use the buffered reader
next add
Code:
public static boolean readEquips(String path, int item) {
String line = null;
try {
BufferedReader in = new BufferedReader(new FileReader("conf/Equips/"+path+".txt"));
ItemLoader.getNameForID(item).toLowerCase().replaceAll("_", " ");
while((line = in.readLine()) != null) {
if(ItemLoader.getNameForID(item).toLowerCase().contains(line)) {
return true;
}
}
} catch(Exception e) {
return false;
}
return false;
}
thisll be used to find the names of the item in the text file
now replace
getItemSlot
with
Code:
public static int getItemSlot(int item) {
if (readEquips("capes", item)) {
return EquipmentController.CAPE;
}
if (readEquips("boots", item)) {
return EquipmentController.FEET;
}
if (readEquips("hands", item)) {
return EquipmentController.HANDS;
}
if (readEquips("shields", item)) {
return EquipmentController.SHIELD;
}
if (readEquips("amulets", item)) {
return EquipmentController.AMULET;
}
if (readEquips("arrows", item)) {
return EquipmentController.ARROWS;
}
if (readEquips("rings", item)) {
return EquipmentController.RING;
}
if (readEquips("legs", item)) {
return EquipmentController.LEGS;
}
if (readEquips("chests", item)) {
return EquipmentController.TORSO;
}
if (readEquips("hats", item)) {
return EquipmentController.HAT;
}
// Else it is a weapon
return EquipmentController.WEAPON;
}
now add the attachment to the folder conf
save compile and run
your done