nano mano Posted February 20, 2018 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!
nano mano Posted February 20, 2018 Author Posted February 20, 2018 12 minutes ago, Alek said: It's the first message in the list Yes, but it doesn't even work.
dreameo Posted February 20, 2018 Posted February 20, 2018 According to Alek you want: chatbox.getMessages().get(0); If there is an error, then post the logs.
nano mano Posted February 20, 2018 Author 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)
nano mano Posted February 20, 2018 Author Posted February 20, 2018 5 minutes ago, Juggles said: onMessage No error logs but doesn't print out the message
Team Cape Posted February 20, 2018 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 !
dreameo Posted February 20, 2018 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
nano mano Posted February 20, 2018 Author 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.
nano mano Posted February 20, 2018 Author 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
Night Posted February 20, 2018 Posted February 20, 2018 Implement the MessageListening interface in your main class and use that to process messages as they come in.
nano mano Posted February 20, 2018 Author 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