Java - Minecraft - Query content & capitalization?

Jo
- in Plugins
3

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.

Bu

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

Ge

If (msg.toLowerCase (). Contains ("test") {
// Something is happening here
}

Lo

Just look at what percentage of the sentence is uppercase.