Hi everybody, I wanted to make an plugin, that if you swear 1 time, you will be warned. But if you swear a second time that you will be kicked. It kind of works, when you swear, you will recieve the message, but if you swear the second time, you will get the message again and you will not be kicked. Help! P.S. Gesencuurde woorden and Schelden is not english, i know. Its dutch Code:java ArrayList<Player> Schelden = new ArrayList<Player>(); @EventHandler public void onPlayerChat(AsyncPlayerChatEvent e) { Player p = e.getPlayer(); for (String word : e.getMessage().split(" ")) { if (plugin.getConfig().getStringList("Gesencuurde woorden") .contains(word)) { e.setCancelled(true); e.getPlayer().sendMessage(ChatColor.RED + "Dont swear!"); Schelden.add(p); if(Schelden.contains(p) == true){ p.kickPlayer("Dont swear!"); }
Schelden.contains(p) == true can be: if(Schelden.contains(p)) It is a good idea not to keep player objects in classes once they may cause ram leakage if not handled correctly Code:java for (String word : e.getMessage().split(" ")) { if (plugin.getConfig().getStringList("Gesencuurde woorden") .contains(word)) { e.setCancelled(true); e.getPlayer().sendMessage(ChatColor.RED + "Dont swear!"); Schelden.add(p); if(Schelden.contains(p) == true){ p.kickPlayer("Dont swear!"); } here^ you loop through evey word, check if the confic contains the word, cancel the event, send the message and then put him in the arrray list and then check if the array list contains the player (it does all the time because you add him right before the if) and kick him.
Shadownd63 I did see you are dutch. But ontopic. If i may give a suggestion. Don't use spaces in configuration paths. And next, Listen to mine-care, he is right.
Shadownd63 It also might be a good idea to add: Code:java Schelden.remove(p); Otherwise they will continue to get kicked everytime he chats