How do i say "If chat text contains"

Discussion in 'Plugin Development' started by isleepzzz, Jul 24, 2012.

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


    (notice: im suuuper new to coding plugins)

    How do i make it say "if chat contains any of these" then:
    do not send the chat text. and send the play a message?
  2. Offline


  3. Offline


    I recommend you use the Bukkit configuration API to store the strings as a list. Then all you would have to do would be:

    for (String s : getConfig().getStringList("Blocked-Words")
      if (event.getMessage().contains(s)
    Otherwise, you would have to loop through the text file with a Buffered Reader which is slightly more complicated than this but not so much.
    RazorFlint likes this.
  4. Offline


    Or that xD
  5. Offline


    ehh my script doesnt recognize what even is sooo what should i do? It wont let me import it and idk if its an integer or string or boolean or what?:/ im new:/
  6. Offline


    event needs to be inside a PlayerChatEvent function

    function onPlayerChat(PlayerChatEvent event) {
    ... code in here...

    Then it will know what "event" is. But you still have to register the event with the plugin so it knows to fire it when chat occurs.
  7. Offline


Thread Status:
Not open for further replies.

Share This Page