Flub 1,288 Posted October 6, 2021 Report Share Posted October 6, 2021 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 Link to comment Share on other sites More sharing options...
TestySauce 1 Posted December 2, 2021 Report Share Posted December 2, 2021 interesting information thank you brother Link to comment Share on other sites More sharing options...
Machinee 0 Posted December 17, 2021 Report Share Posted December 17, 2021 thanks for this Link to comment Share on other sites More sharing options...
AmenityPK 0 Posted December 24, 2021 Report Share Posted December 24, 2021 Sure someone will find this useful! Nice little snippet mate! Link to comment Share on other sites More sharing options...
shadowisdom 1 Posted February 6, 2022 Report Share Posted February 6, 2022 thanks for this Link to comment Share on other sites More sharing options...
Boydie96 5 Posted March 1, 2022 Report Share Posted March 1, 2022 Thanks! Link to comment Share on other sites More sharing options...
0117be 66 Posted June 2, 2022 Report Share Posted June 2, 2022 Solid work! throwing updates like it paper Link to comment Share on other sites More sharing options...
mire 0 Posted October 29, 2022 Report Share Posted October 29, 2022 Ooooo Ill deffo be stealing that ahaha Link to comment Share on other sites More sharing options...
nsin25 0 Posted February 7, 2023 Report Share Posted February 7, 2023 Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now