I'm currently programming a Minecraft plugin.
Now I got the idea to create a chat filter, which also works great.
However, this only queries whether this word is contained in the message, with the specified upper and lower case.
I got the idea to use the following:
String msg = e.getMessage ();
if (msg.equalsIgnoreCase ( "test") {
// something happens here
}
There, however, the only query is whether the message is "test".
The case is not case-sensitive, but this does not work if the message "I'm a test".
So I would like to ask whether this word appears in any way in the message (msg.contains ("test")) and that the case is not case-sensitive.
This means that something happens there when you write "TeSt" without having to individually insert it into the code.
Convert all characters to upper or lower case beforehand. The class String offers corresponding methods for this.
PS.: Another option - Pattern Matching (read https://stackoverflow.com/...manner-in).
If (msg.toLowerCase (). Contains ("test") {
// Something is happening here
}
Just look at what percentage of the sentence is uppercase.