These commands use the lists already in your server files and is a lot quicker to use IMO then going to your lists and doing ctrl + f to find the item id you want or npc id you want, etc.
Here is the first command, ::finditem "Item Name"
Searches for any item name that contains the word you input.
Here is the second command, ::findnpc "Npc Name"
Searches for any npc name that contains the word you input.
Item Id Finder:
Code:
if (playerCommand.startsWith("finditem")) {
try {
String item = playerCommand.substring(9).toLowerCase();
String itemName = "";
int totalItemsFound = 0;
boolean noFoundItems = true;
c.sendMessage("Searching item database for item names containing the word '"+item+"'...");
for(int i = 0; i < Config.ITEM_LIMIT; i++) {
if(Server.itemHandler.ItemList[i] != null) {
itemName = Server.itemHandler.ItemList[i].itemName.replaceAll("_", " ").toLowerCase();;
if(itemName.contains(item) || itemName.startsWith(item) || itemName.endsWith(item) || itemName.equalsIgnoreCase(item)) {
c.sendMessage(Server.itemHandler.ItemList[i].itemName+", ID: "+Server.itemHandler.ItemList[i].itemId);
totalItemsFound++;
noFoundItems = false;
}
}
}
if(noFoundItems)
c.sendMessage("Could not find any item names containing the word '"+item+"'.");
else
c.sendMessage("Found "+totalItemsFound+" item names containing the word '"+item+"'.");
} catch(Exception e) {
}
}
Npc Id Finder:
Code:
if (playerCommand.startsWith("findnpc")) {
try {
String npc = playerCommand.substring(8).toLowerCase();
String npcName = "";
int totalNpcsFound = 0;
boolean noFoundNpcs = true;
c.sendMessage("Searching npc database for npc names containing the word '"+npc+"'...");
for(int i = 0; i < Server.npcHandler.maxListedNPCs; i++) {
if(Server.npcHandler.NpcList[i] != null) {
npcName = Server.npcHandler.NpcList[i].npcName.replaceAll("_", " ").toLowerCase();
if(npcName.contains(npc) || npcName.startsWith(npc) || npcName.endsWith(npc) || npcName.equalsIgnoreCase(npc)) {
c.sendMessage(Server.npcHandler.NpcList[i].npcName.replaceAll("_", " ")+", ID: "+Server.npcHandler.NpcList[i].npcId);
totalNpcsFound++;
noFoundNpcs = false;
}
}
}
if(noFoundNpcs)
c.sendMessage("Could not find any npc names containing the word '"+npc+"'.");
else
c.sendMessage("Found "+totalNpcsFound+" npc names containing the word'"+npc+"'.");
} catch(Exception e) {
}
}
NOTE:
This can spam up your chat box if you search for non specific things like 'sword'.