Welcome!

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

Sign up now!

Resolved getMessages returning incorrect values over time

Joined
Jun 21, 2014
Messages
350
As you can see the timestamps don't line up:
CWSyWWt.png

I'm using the following code:
Code:
System.out.println(Chatbox.getMessages().get(Chatbox.getMessages().size() - 1).getMessage().toString());
to get the latest message in the chatbox.

Steps to reproduce:
Get the latest message and print out the contents

Problem: It only works for a while, then it stops working, only solution is to relog.
Proof that it works at first using the same code:
HM626Fv.png


It seems to happen when a 'News' message is displayed, where it stops working thereafter, though this could just be a coincidence, it could be due to the messages reaching the end of the chat, I don't know.

z4yzwhK.png

 
@Cloud

Edit: Same behavior regardless of if timestamps are enabled or not
 
Last edited:
Joined
Nov 26, 2014
Messages
616
Did you try ChatBoxListener? Works fine for me.

Code:
@Override
public void onMessageReceived(MessageEvent e) {
    System.out.println(e.getMessage());
}

Code:
(05:12:34) You can access Treasure Hunter from the side panel, and you can show the button again by logging out and back in.
(05:13:00) A tasty fish.<br>GE guide price: 364 gp each
(05:13:10) An enchanted ring.<br>GE guide price: 1,835 gp each
 
Joined
Jun 21, 2014
Messages
350
Did you try ChatBoxListener? Works fine for me.

Code:
@Override
public void onMessageReceived(MessageEvent e) {
    System.out.println(e.getMessage());
}

Code:
(05:12:34) You can access Treasure Hunter from the side panel, and you can show the button again by logging out and back in.
(05:13:00) A tasty fish.<br>GE guide price: 364 gp each
(05:13:10) An enchanted ring.<br>GE guide price: 1,835 gp each
I'm using that but I need to delay until another message is sent and hence need getMessages to work.
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
Could we get a way to sort them easily, or was this restriction put in place so people used ChatboxListener instead?
It would be annoying to try and force the original order because the data comes in multiple "streams" that we then merge into a single list.
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,046
Just make a concurrent list and and every time a message is received, add it to the list.
Should be done in a bot specific context as this would be wasted usage for 99% of bots. May have been what you were suggesting, but just clarifying.
 
Top