nano mano Posted February 20, 2018 Share Posted February 20, 2018 How do I get the last chatbox message or the one which is previous it? I tried chatbox.getMessages().get(chatbox.getMessages().size()-1); That @Team Cape provided here but it doesn't work Writing the code will be very useful, thanks! Quote Link to comment Share on other sites More sharing options...
Alek Posted February 20, 2018 Share Posted February 20, 2018 It's the first message in the list Quote Link to comment Share on other sites More sharing options...
nano mano Posted February 20, 2018 Author Share Posted February 20, 2018 12 minutes ago, Alek said: It's the first message in the list Yes, but it doesn't even work. Quote Link to comment Share on other sites More sharing options...
dreameo Posted February 20, 2018 Share Posted February 20, 2018 According to Alek you want: chatbox.getMessages().get(0); If there is an error, then post the logs. Quote Link to comment Share on other sites More sharing options...
Alek Posted February 20, 2018 Share Posted February 20, 2018 It does work Quote Link to comment Share on other sites More sharing options...
nano mano Posted February 20, 2018 Author Share Posted February 20, 2018 9 minutes ago, dreameo said: According to Alek you want: chatbox.getMessages().get(0); If there is an error, then post the logs. @Alek https://imgur.com/a/S9l0g from logger I get this java.lang.NullPointerException at org.osbot.rs07.api.Chatbox.getMessages(he:258) Quote Link to comment Share on other sites More sharing options...
Juggles Posted February 20, 2018 Share Posted February 20, 2018 onMessage Quote Link to comment Share on other sites More sharing options...
nano mano Posted February 20, 2018 Author Share Posted February 20, 2018 5 minutes ago, Juggles said: onMessage No error logs but doesn't print out the message Quote Link to comment Share on other sites More sharing options...
Team Cape Posted February 20, 2018 Share Posted February 20, 2018 22 minutes ago, nano mano said: No error logs but doesn't print out the message Would recommend using onMessage() getMessages() is bugged. How are you trying to print it? Also, my mistake - it should've been getMessages().get(0) not the other way around ! Quote Link to comment Share on other sites More sharing options...
dreameo Posted February 20, 2018 Share Posted February 20, 2018 (edited) lol my bad, kinda rushed it but, you want this: getChatbox().getMessages(Chatbox.MessageType.ALL).get(0); change type of message if you don't want all. the only reason you're getting null is because of poor referencing Edited February 20, 2018 by dreameo Quote Link to comment Share on other sites More sharing options...
nano mano Posted February 20, 2018 Author Share Posted February 20, 2018 17 minutes ago, Team Cape said: Would recommend using onMessage() getMessages() is bugged. How are you trying to print it? Also, my mistake - it should've been getMessages().get(0) not the other way around ! 16 minutes ago, dreameo said: lol my bad, kinda rushed it but, you want this: getChatbox().getMessages(Chatbox.MessageType.ALL).get(0); change type of message if you don't want all. the only reason you're getting null is because of poor referencing I tried onMessage(Chatbox.MessageType.ALL).get(0) and getChatbox().getMessages(Chatbox.MessageType.ALL).get(0); I get an error from eclipse. Quote Link to comment Share on other sites More sharing options...
nano mano Posted February 20, 2018 Author Share Posted February 20, 2018 @dreameo @Team Cape @Juggles Sorry for spam. Please help I have been 3 hours trying to figure it out with no luck Quote Link to comment Share on other sites More sharing options...
Night Posted February 20, 2018 Share Posted February 20, 2018 Implement the MessageListening interface in your main class and use that to process messages as they come in. Quote Link to comment Share on other sites More sharing options...
nano mano Posted February 20, 2018 Author Share Posted February 20, 2018 8 minutes ago, Night said: Implement the MessageListening interface in your main class and use that to process messages as they come in. Thanks Quote Link to comment Share on other sites More sharing options...