Anti Spam

Discussion in 'Spigot Plugin Development' started by LazerShadow, Jun 23, 2015.

  1. What would be the best way to create an anti spam?
     
  2. count the number of times a user chats in a set amount of time. Like, if a user chats 5 times in 5 seconds, consider it spam. ;)
     
    • Like Like x 1
    • Agree Agree x 1
  3. or if you want to go into more detail, log the words everyone types into a hash map containing the player name and the message they just typed, and if they type the exact same thing again, consider it spam :)
     
  4. hm....... do you mean this?: heeeeeeeeeeeeeeeeeeeeeeeelooooooooooooooo
    or: hihihihihihihihihi
    or both?
    or the time between messages?
     
  5. I think using a a delayed task is a solver:
    Code (Text):
                    cooldown.add(p.getName()); // Adding cooldown
                    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new BukkitRunnable(){
                        public void run(){
                            cooldown.remove(p.getName()); // Removing cooldown
                           
                                }
                            }, 100L); // How long is the delay
                        }
                    }
                }
            }
        }
    If you're wondering where's the cooldown comefrom, you can use arraylist
     
  6. chat cooldown or count the player chat if he chat the word with same as next then
    Code (Text):
    e.setCancelled(true);
    // and send a message
     
  7. if(p.getName().equals("Raymart") {
    p.setCoolness("100%");
    }
     
  8. :p