Skip to content

Genie handler should close bank (or deposit box) if it has a lamp in it's inv

Summary

If a bot manages to: fire the geniehandler (get a lamp), open a bank (or depositbox) before using it, the geniehandler stops firing and regular bot execution takes over. Since the bot's state is now a bank open with an unknown object in the inv, most bots try to bank the lamp causing them to get stuck.

Steps to reproduce

Have a bot bank right after doing geniehandler

Example Code

GenieHandler.java

What is the current behavior?

Geniehandler stops firing and leaves bots stranded with a lamp in the inv and bank open, which results in most bots trying to deposit it.

What is the expected correct behavior?

Close the bank and finish handling

Relevant logs and/or screenshots

Possible fixes

Change geniehandler to close bank and finish handling the event. Something similar to (untested):

    @Override
    public boolean isValid() {
        if (failures >= MAX_FAILURES) {
            disable();
            return false;
        }
        if ((skill = OpenAccountDetails.getLampSkill()) == null) {
            return false;
        }
        lamp = Inventory.newQuery().names("Lamp").actions("Rub").results().first();
        if (lamp != null && (Bank.isOpen() || DepositBox.isOpen())) {
            return true;
        }
        final var player = Players.getLocal();
        if (player == null || player.isMoving() || Bank.isOpen() || DepositBox.isOpen() || GrandExchange.isOpen() || Trade.isOpen()) {
            return false;
        }
        if (lamp != null) {
            return true;
        }
        genie = Npcs.newQuery().levels(0).names("Genie").reachableFrom(player).visible().targeting(player).results().first();
        return genie != null;
    }

    @Override
    public void run() {
        final Player local = Players.getLocal();
        if (local == null) {
            return;
        }
        if (Bank.isOpen()) {
            log.fine("[GenieHandler] Closing bank.");
            Bank.close();
            return;
        }
        if (DepositBox.isOpen()) {
            log.fine("[GenieHandler] Closing deposit box.");
            DepositBox.close();
            return;
        }
        final var selectedItem = Inventory.getSelectedItem();
        if (selectedItem != null) {
            log.fine("[GenieHandler] Deselecting item: " + selectedItem);
            if (selectedItem.click()) {
                Execution.delayWhile(() -> Inventory.getSelectedItem() != null, 1200, 2400);
            }
            return;
        }
.....................

Related issue:

The code above is also intended to fix the issue #136 (closed). Though these are separate issues as #136 (closed) is the bot trying to continue the handler when the DepositBox is open, but this new Issue is that the bot stops continuing when bank is open.