A Duck Tale 0 #1 Posted June 28, 2014 (edited) EDIT: Ok so I had decided not to sleep and just get it done. there were few errors(due to typos) that made me take it off but I've managed to find and fix them. Enjoy :) Just made a simple anti-spam for my Project Insanity server and thought I should share. Currently, it blocks out auto typers as well as people spamming the server. The first thing you'll need to do is to locate your Chat.java Under the line "public class Chat implements PacketType" put: [CODE] // Anti-Spam Check By: A Duck Tale int spamsAllowed = 8; // amount of spams allowed int timeAllowed = 5 * 1000; // time to wait in milliseconds. // Initialize variables int spamCount = 0; long timeWaited = 0; long startTime = 0; long endTime = 0; byte[] message = null; byte[] storeMessage = null;[/CODE] then under the line "c.inStream.readBytes_reverseA(c.getChatText(), c.getChatTextSize(), 0);" place: [CODE] message = c.getChatText(); if (storeMessage == null){ storeMessage = message; } else if (storeMessage != null){ if (storeMessage == message){ spamCount++; if(startTime == 0){ startTime = System.currentTimeMillis(); } if (spamCount >= spamsAllowed){ endTime = System.currentTimeMillis(); timeWaited = endTime - startTime; if (timeWaited < timeAllowed){ System.out.println("Kicking...."); startTime = 0; spamCount = 0; timeWaited = 0; endTime = 0; storeMessage = null; message = null; c.logout(); } else if(timeWaited >= timeAllowed){ startTime = 0; spamCount = 0; timeWaited = 0; endTime = 0; storeMessage = null; message = null; } } } else if (storeMessage != message){ spamCount = 0; startTime = 0; storeMessage = message; } }[/CODE] now there are only two things you'll need to change to suit your needs. The first one is the variable 'spamsAllowed', which will be the number of messages the user can type in a given time before kicking them. The second one is 'timeAllowed', which is said 'given time' and determines how long the player must wait until their spam count resets. Let me know if you are having troubles with the code below :) Edited June 30, 2014 by A Duck Tale Share this post Link to post Share on other sites
KronikXDev 0 #2 Posted July 21, 2014 Nice thank you, will use. Share this post Link to post Share on other sites
Pccdrom10 0 #3 Posted July 22, 2014 Thanks i will use . Share this post Link to post Share on other sites
TheDevinM 0 #4 Posted August 13, 2014 Will use, simple and effective. Thanks. Share this post Link to post Share on other sites
NoahLH 0 #6 Posted August 15, 2014 nice, but wont use Share this post Link to post Share on other sites
bitmask 4 #7 Posted August 16, 2014 Could be done alot better, thanks though! Share this post Link to post Share on other sites
Silentkid 0 #9 Posted January 6, 2015 Very nice, I like it. I might use it as it's very efficient. :) Share this post Link to post Share on other sites