Solved How to check if a player's chat message contains something

Discussion in 'Plugin Development' started by sammyg7241, May 18, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    sammyg7241

    Hello, I am looking for a way to check to see if a player's chat message contains something. Thanks!
     
  2. Offline

    ForsakenRealmz

    What are you going to be checking it with? A list of words, a single word, etc..
     
  3. Offline

    dontjudgeme1243

    Haha, I just answered a question similar to this.
    First off, make sure you register your events in onEnable. (I hope you know how to do this already, if you do not I suggest watching some tutorials on line)
    Then put
    Code:
    @EventHandler
        public void chat(AsyncPlayerChatEvent event)
        {
            if(event.getMessage().toLowerCase().contains("example words here"))
            {
                do stuff....
            }
        }
    P.S: I'm not positive but pretty sure you're new to this, and that's why I'm treating you a little noobie :p
     
  4. Offline

    sammyg7241

    @dontjudgeme1243 Yes, I'm new to Java, thanks will try this now :)

    Thanks this worked :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
Thread Status:
Not open for further replies.

Share This Page