Can someone tell me my mistake?
One should only send a message once and the second time it should be blocked. However, that does not work that way.
private static string msg = "";
@EventHandler
public void onAntiSpam (AsyncPlayerChatEvent e) {
Player p = e.getPlayer ();
main.msgWdh.toUpperCase ();
if (! (p.hasPermission {"lobby.spam" {
if (e.getMessage (). ToUpperCase () == main.msgWdh) {
e.setCancelled (true);
p.sendMessage (main.prefix + "Please do not spam!");
} else {
main.msgWdh = e.getMessage (). ToUpperCase ();
I would make it quite different in spirit somehow.
Strings are compared to equals and not ==.
if (e.getMessage (). ToUpperCase (). Equals (main.msgWdh)) {