hello, how to censure numeric ip and for example mc.myserver.net ? this is my plugin for censure word: Code:java @EventHandlerpublic void onChatMessage(PlayerChatEvent e) {String message = e.getMessage();String censura = e.getMessage();String parolaccia = e.getMessage();int censuraCount = 0; for(char p : censura.toLowerCase().toCharArray()){if(censura == parolaccia)censura = parolaccia.replaceAll("word", "w**d");if(censura == parolaccia)censura = parolaccia.replaceAll("WORD", "W**D"); I haven't put .equalsIgnoreCase() because all chat becomes small...
gamerover98 Couple of things: 1) Your if statements will never* be true. You're essentially checking if any of the individual characters are equal to the entire message. 2) replaceAll() is for regex. When you're just using for literals and not using regex, you should use replace(). Side note: regex is useful for finding IPs and URLs. * Well, it will be true if they have a 1 character message, but then your replaceAll() statement would never find a match...
Correction, his statements would /always/ be true. gamerover98 This kind of task is a lot more complex than the approach you are taking to it. People who want to spam/advertise in your chat won't be afraid to use my(.)coolserver - .com etc.
1Rogue My mistake. For some reason (probably the worse than useless for loop) I thought he was trying to compare the individual characters to the whole String, rather than the String to the same String. Which now I think about it, wouldn't have been false, it wouldn't have compiled. Either way, not sure the reasoning behind it and main solution would be to learn the basics of Java gamerover98