Posted October 6, 20213 yr comment_63111 Hi guys, Here is a command I created to discover what NPC's drop an item. Main code (I put mine inside ItemDefinition so that I can use ItemDefinition.whatDrops(player, name))``` public static void whatDrops(Player player, String name) { int itemID = getItemId(name); if (itemID == -1) { player.getPacketSender().sendMessage("Item not found!"); return; } ItemDefinition itemDef = ItemDefinition.forId(itemID); List<Integer> previouslyListed = new ArrayList<>(); try { for (NPCDrops npcDrops : NPCDrops.getDrops().values()) { if (npcDrops != null) { for (NPCDrops.NpcDropItem item : npcDrops.getDropList()) { if (item != null && item.getId() == itemID) { for (int npcId : npcDrops.getNpcIds()) { if (npcId == -1) return; NpcDefinition npcDef = NpcDefinition.forId(npcId); if (npcDef != null && !npcDef.getName().equalsIgnoreCase("null") && !previouslyListed.contains(npcId)) { previouslyListed.add(npcId); player.getPacketSender().sendMessage(itemDef.getName() + " are dropped by " + npcDef.getName() + "! Noted: " + (itemDef.isNoted() ? "True" : "False")); break; } } } } } } } catch (Exception ignored) { } if (previouslyListed.isEmpty()) { player.getPacketSender().sendMessage("Unable to find an NPC that drops: " + itemDef.getName()); } previouslyListed.clear(); } Command code: if (command[0].equals("whatdrops")) { String item = wholeCommand.substring(command[0].length() + 1); player.getPacketSender().sendMessage("Searching for " + item); ItemDefinition.whatDrops(player, item); } Usage: ::whatdrops Rune Platebody
Create an account or sign in to comment