private static final Pattern namePattern =
Pattern.compile("[a-zA-Z0-9_-]{3,12}");
if (player.getName().length() < 3 ||
player.getName().length() > 12 ||
namePattern.matcher(player.getName()).matches()) {
player.ban("[Autoban] Character-name PE", true);
return;
}
The code is kinda obvious, I hope
If the players name is longer than 12 or shorter then 3, or have any symbols that shouldnt be i a name = BAM, ban!
but even thought my player name is like Chaos or test, it gets autobanned by this code.
idk if the namepattern Pattern blocks characters aswell, I just it to block symbols like "!#&%¤/&%(/)(/(=)$@£$@£{€@£ yeh...
What am I doing wrong :(?