Jump to content

How to store a chat message into a variable


imJordanB

Recommended Posts

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 :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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