Jump to content

Custom quick dropping method [Req]


Recommended Posts

Posted
	public void dropAll(Script script, ArrayList<String> exceptionList) throws InterruptedException {
		Item[] i = script.inventory.getItems();
		for (Item inventoryItem : i) {
			if ((exceptionList == null || !exceptionList.contains(inventoryItem.getName())) && Arrays.asList(inventoryItem.getDefinition().getActions()).contains("Drop")) {
				int s = script.inventory.getSlot(inventoryItem);
				Timer failsafe = new Timer();
				while (script.inventory.getSlot(inventoryItem) == s && failsafe.getElapsed() < 5000L) {
					inventoryItem.interact("Drop");
					Script.sleep(Script.random(600, 1200));
				}
			}
			if (script.inventory.isItemSelected()) {
				script.inventory.deselectItem();
			}
		}
	}

Not sure if it's faster considering it relies on the API's interaction method.

Posted
	public void dropAll(Script script, ArrayList<String> exceptionList) throws InterruptedException {
		Item[] i = script.inventory.getItems();
		for (Item inventoryItem : i) {
			if ((exceptionList == null || !exceptionList.contains(inventoryItem.getName())) && Arrays.asList(inventoryItem.getDefinition().getActions()).contains("Drop")) {
				int s = script.inventory.getSlot(inventoryItem);
				Timer failsafe = new Timer();
				while (script.inventory.getSlot(inventoryItem) == s && failsafe.getElapsed() < 5000L) {
					inventoryItem.interact("Drop");
					Script.sleep(Script.random(600, 1200));
				}
			}
			if (script.inventory.isItemSelected()) {
				script.inventory.deselectItem();
			}
		}
	}

Not sure if it's faster considering it relies on the API's interaction method.

 

Good looking man,

Thanks

Posted

Just revisited the class in question:

	public static void wholeInventory(Script script, ArrayList<String> exceptionList, boolean dropCondition) throws InterruptedException {
		if (dropCondition) {
			Item[] i = script.inventory.getItems();
			for (Item inventoryItem : i) {
				if (!dropCondition) {
					break;
				}
				if ((exceptionList == null || !exceptionList.contains(inventoryItem.getName())) && Arrays.asList(inventoryItem.getDefinition().getActions()).contains("Drop")) {
					int s = script.inventory.getSlot(inventoryItem);
					Timer failsafe = new Timer();
					while (script.inventory.getSlot(inventoryItem) == s && failsafe.getElapsed() < 5000L) {
						inventoryItem.interact("Drop");
						Script.sleep(Script.random(600, 1200));
					}
				}
				if (script.inventory.isItemSelected()) {
					script.inventory.deselectItem();
				}
			}
		}
	}

	public static void inventoryItems(Script script, ArrayList<String> itemList, boolean dropCondition) throws InterruptedException {
		if (dropCondition) {
			Item[] i = script.inventory.getItems();
			for (Item inventoryItem : i) {
				if (!dropCondition) {
					break;
				}
				if (itemList != null) {
					if (itemList.contains(inventoryItem.getName()) && Arrays.asList(inventoryItem.getDefinition().getActions()).contains("Drop")) {
						int s = script.inventory.getSlot(inventoryItem);
						Timer failsafe = new Timer();
						while (script.inventory.getSlot(inventoryItem) == s && failsafe.getElapsed() < 5000L) {
							inventoryItem.interact("Drop");
							Script.sleep(Script.random(600, 1200));
						}
					}
				}
				if (script.inventory.isItemSelected()) {
					script.inventory.deselectItem();
				}
			}
		}
	}
Posted (edited)

You can also change the itemName to drop, to exception if you'd prefer that. Should be fairly easy to change.

	public void dropAll(String itemName) throws InterruptedException {
		Inventory inv = client.getInventory();
		if (inv.contains(itemName)) {
			for (Item item : inv.getItems()) {
				if (item.getName().equalsIgnoreCase(itemName)) {
					MouseDestination slotDestination = new RectangleDestination(
							inv.getDestinationForSlot(inv
									.getSlotForName(itemName)));
					if (client
							.moveMouseTo(slotDestination, false, false, false)) {
						client.clickMouse(true);
						int i = findOption("Drop");
						if (i > 0) {
							if (client.moveMouseTo(new RectangleDestination(
									client.getMenuX(), client.getMenuY() + 5
											+ (i * 15),
									client.getMenuWidth() - 3, 6), false, true,
									false)) {
								sleep(random(150, 300));
							}
						}
					}
				}
			}
		}
	}
	
	public int findOption(String option) {
		int i = 0;
		Iterator<Option> it1 = client.getMenu().iterator();
		while (it1.hasNext()) {
			++i;
			Option temp = it1.next();
			if (temp.action.equalsIgnoreCase(option)) {
				return i;
			}
		}
		return 0;
	}
Edited by Nitrousek
Posted (edited)


private void dropAll() throws InterruptedException {

        for (int slot = 0; slot < 28; slot++) {

            Item item = client.getInventory().getItems()[slot];

                if (item == null)

                    continue;

                    client.getInventory().interactWithSlot(slot, "Drop");

        }

    }

Edited by Pseudo
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...