Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question InventoryListener

Joined
Dec 19, 2017
Messages
5
Im having trouble starting InventoryListener

1. Ive added the getEventDispatcher.addListener(this)
2. I implement InventoryListener as part of the public class
3. I tried to write:

private void onItemRemoved(ItemEvent ddd){

}

but it says its never used

Any reason?
 
Joined
Jan 25, 2015
Messages
121
private void onItemRemoved(ItemEvent ddd){

}

Try setting your method to a public acess:

JavaScript:
@Override
public void onItemRemoved(ItemEvent event){
    //pass
}

@Override
public void onItemAdded(ItemEvent event){
    //pass
}

Obs.: make sure to override both methods as said by Cloud here.
 
Joined
Dec 19, 2017
Messages
5
Try setting your method to a public acess:

JavaScript:
@Override
public void onItemRemoved(ItemEvent event){
    //pass
}

@Override
public void onItemAdded(ItemEvent event){
    //pass
}

Obs.: make sure to override both methods.

setting them public doesn't fix the issue ;/

I still get the same error with override
 
Joined
Dec 19, 2017
Messages
5
Do you have overrided both methods? In this case share us some more code.
Code:
package com.RunnerKing.bots.div_bot;

import com.runemate.game.api.hybrid.entities.GameObject;
import com.runemate.game.api.hybrid.entities.Item;
import com.runemate.game.api.hybrid.entities.Npc;
import com.runemate.game.api.hybrid.entities.Player;
import com.runemate.game.api.hybrid.local.Camera;
import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
import com.runemate.game.api.hybrid.location.navigation.basic.ViewportPath;
import com.runemate.game.api.hybrid.region.GameObjects;
import com.runemate.game.api.hybrid.region.Npcs;
import com.runemate.game.api.hybrid.region.Players;
import com.runemate.game.api.script.Execution;
import com.runemate.game.api.script.framework.LoopingBot;
import com.runemate.game.api.script.framework.listeners.InventoryListener;
import java.awt.event.ItemEvent;
import java.util.regex.Pattern;

public class DivBot extends LoopingBot implements InventoryListener{

    private Npc wisp;
    private GameObject rift;


    @Override
    public void onStart(String... args) {

        setLoopDelay(100,200);
        getEventDispatcher().addListener(this);

        System.out.println(getEventDispatcher().getListeners());
    }
  
    @Override
    public void onItemRemoved(ItemEvent event){}
    @Override
    public void onItemAdded(ItemEvent event){}


    @Override
    public void onLoop() {
        final Player me = Players.getLocal();

        wisp = Npcs.newQuery().names("Gleaming wisp").reachable().results().nearest();

        rift = GameObjects.newQuery().names(Pattern.compile("^Energy")).results().nearest();

        if(Inventory.isFull()){
            if(me.getAnimationId() != -1){
                System.out.println("Dumping");
            }else{
                if(rift != null){
                    if(rift.getPosition().distanceTo(me.getPosition()) > 5){
                        Camera.turnTo(rift);
                    }
                    rift.interact("Convert to enhanced experience");
                    Execution.delayWhile(()->Inventory.containsAnyOf("Enriched gleaming memory", "Gleaming memory"), 45000);
                }else{
                    System.out.println("Cant find rift");
                }

            }
        }else{
            if(me.getTarget() != null || me.getAnimationId() != -1){
                System.out.println("Harvesting");
            }else{
                if(wisp.getPosition().distanceTo(me.getPosition()) > 5){
                    Camera.turnTo(wisp);
                }
                wisp.interact("Harvest");
                Execution.delayUntil(()-> me.getAnimationId() != -1, 2000);
            }
        }



    }
}
 
Top