Jump to content

How to store a chat message into a variable


Recommended Posts

Posted

So I'm trying to store a chat message into a variable and String doesn't work, i'm new to Java and don't really know how to go about this as it seems that getChatbox().getMessages(MessageType.PLAYER) does not return something that can simply go under a String variable. I am currently working on a mimmick bot and will store the players message to then output it. I have tried simply outputting without saving to a variable also, with the line: getKeyboard().typeString(getChatbox().getMessages(MessageType.PLAYER)); (This is probably horribly wrong, i am completely new to the keyboard api.

 

Any help is appreciated :)

Posted (edited)

So I'm trying to store a chat message into a variable and String doesn't work, i'm new to Java and don't really know how to go about this as it seems that getChatbox().getMessages(MessageType.PLAYER) does not return something that can simply go under a String variable. I am currently working on a mimmick bot and will store the players message to then output it. I have tried simply outputting without saving to a variable also, with the line: getKeyboard().typeString(getChatbox().getMessages(MessageType.PLAYER)); (This is probably horribly wrong, i am completely new to the keyboard api.

 

Any help is appreciated smile.png

List<String> messages = getChatbox().getMessages(MessageType.PLAYER);

it returns a list of messages, not a single message.

 

Edit: If you are trying to get the most recent message you would use something like:

List<String> messages = getChatbox().getMessages(MessageType.PLAYER);
String message = messages.get(messages.size() - 1);
Edited by Explv
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...