Jump to content
Existing user? Sign In

Sign In



Sign Up

[Ruse] Command to find what NPC drops a specified item


Flub

Recommended Posts

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

  • 1 month later...
  • 2 weeks later...
  • 1 month later...
  • 4 weeks later...
  • 3 months later...
  • 4 months later...
  • 3 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

Contact

[email protected]

astra.security

What is a RSPS?

A RSPS, also known as RuneScape private server, is an online game based on RuneScape, and controlled by independent individuals.

Popular RSPS Servers

Runewild Ikov RedemptionRSPS

Disclaimer

Runesuite is not affiliated with runescape, jagex in any way & exists solely for educational purposes.

×
×
  • Create New...