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 Paint not showing up?

Joined
Jan 23, 2017
Messages
9
The paint will not show up at all.

I've implemented the PaintListener, added the listener to the onStart


Code:
@Override
public void onStart(String... args) {
    getEventDispatcher().addListener(this);
    setLoopDelay(250, 500);
}

Code:
@Override
public void onPaint(Graphics2D g){
    g.drawString("Test", 100, 100);
}
 
Client Developer
Joined
Oct 12, 2015
Messages
3,760
JavaFX written onto the Embeddable UI, as shown in the link above.
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
It's a long shot for me, but i'll try it. Do I update the stats of the bot in the loop?
You really should not be doing that. Ideally you would want to update all your tracked statistics like experience of a certain skill through SkillListener, making it event driven will make it way more efficient than updating it every X milliseconds.
 
Joined
Jan 23, 2017
Messages
9
You really should not be doing that. Ideally you would want to update all your tracked statistics like experience of a certain skill through SkillListener, making it event driven will make it way more efficient than updating it every X milliseconds.
Will this work?

Code:
@Override
public void onItemAdded(ItemEvent itemEvent) {
    ItemDefinition def = itemEvent.getItem().getDefinition();
    if (def != null && def.getName().equals(finishedPotion)) {
        potionsMade++;
        potsPerHour = (int) (potionsMade * 3600000D / runTime.getRuntime());
    }
}
 
Go check out new bots and give helpful feedback.
Joined
Jan 31, 2016
Messages
5,413
Will this work?

Code:
@Override
public void onItemAdded(ItemEvent itemEvent) {
    ItemDefinition def = itemEvent.getItem().getDefinition();
    if (def != null && def.getName().equals(finishedPotion)) {
        potionsMade++;
        potsPerHour = (int) (potionsMade * 3600000D / runTime.getRuntime());
    }
}
#getName can return null so you need to save that and null check it as well. not sure what 3600000D means, but you will need to cast to a double to get a number that isnt an int from the division.
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
Will this work?

Code:
@Override
public void onItemAdded(ItemEvent itemEvent) {
    ItemDefinition def = itemEvent.getItem().getDefinition();
    if (def != null && def.getName().equals(finishedPotion)) {
        potionsMade++;
        potsPerHour = (int) (potionsMade * 3600000D / runTime.getRuntime());
    }
}
1) You can check the name easier by making a query and checking if it accepts the item. Inventory.newQuery().names(finishedPotion).accepts(itemEvent.getItem())
2) You can use CommonMath class in order to calculate the xp/hr more elegantly.
 
#getName can return null so you need to save that and null check it as well. not sure what 3600000D means, but you will need to cast to a double to get a number that isnt an int from the division.
the "D" at the end of the number will make it a double value.
 
Joined
Jan 23, 2017
Messages
9
#getName can return null so you need to save that and null check it as well. not sure what 3600000D means, but you will need to cast to a double to get a number that isnt an int from the division.
I followed the EmbeddableUI tutorial and it works. However, when I'm having trouble closing the GUI and opening the paint when the start button is clicked.
Code:
private EventHandler<ActionEvent> getStartButtonAction() {
    return event -> {
      Herblore.setPotion(choosePotion.getSelectionModel().getSelectedItem());
      Herblore.setPreset(choosePreset.getSelectionModel().getSelectedItem());

      Herblore.guiReturnCode = 0;

    };
 
Client Developer
Joined
Oct 12, 2015
Messages
3,760
Like I said before I highly recommend you joining the #development channel on Slack.
 
Top