Coyote™ Posted December 12, 2009 Posted December 12, 2009 Well, hello everybody! Lately, as I was making my AIO topic, I've seen many FloodProtections for a few clientpackets. Well, I thought that it's useless to search for FloodProtectors one by one, if you are able to create your own! In this guide, we will learn how to create a FloodProtector, how to make the value configurable, what FloodProtectors are and a few more things! Pay attention to this: Today we will talk for the L2jIT Flood Protector, so if you are using any kind of l2jfree, you can't follow this guide. And also, if you are using l2j G Final, you can get some advice, but you can't follow the guide! Are you ready? ;-) Introduction The FloodProtectors (IT always) are a quite easy way to protect your server from unwanted floods or attacks. It is not the best way to protect your server from hacks and exploits, although it's an easy one and almost everyone can (or at least will be able to) create. The FloodProtectors set a delay for the actions to be done. For example, by floodprotecting multisell with 10 secs delay, you simply stop players by buying stuff, if 10 seconds don't pass. Quite easy, right? The IT Flood Protector Well, the FloodProtector file is located at net.sf.l2j.gameserver.util and is named FloodProtector.java I will not start talking on how to floodprotect files in the normal way, cuz I promised you to show how to make them configurable. Sooo.. Configuring Well, we will start by creating our Properties File. So, go at your configs and create a file named FloodProtector.properties (or any other name you want) Add any description if you want, but don't forget the "#" symbol at the start of each line. Then, copy paste these: # FloodProtected UseItem ProtectedUseItem = 4 # FloodProtected RollDice ProtectedRollDice = 42 # FloodProtected Firework ProtectedFireWork = 42 # FloodProtected Item / Pet Summon ProtectedItemPetSummon = 16 # FloodProtected Hero Voice ProtectedHeroVoice = 100 Now, let's register the new Config file at our GS. Go at net/sf/l2j/Config.java and find the following line: public static final String L2JMOD_CONFIG_FILE = "./config/l2jmods.properties"; It is about at line 64 Under this, add this line public static final String FLOODPROTECTOR_CONFIG_FILE = "./config/FloodProtector.properties"; Now let's find another line public static int L2JMOD_WEDDING_DIVORCE_COSTS; This line's number is 800++ Now, create a new line, leave it empty, and create a few more lines, where you will add these things. Just copy/paste them, as I have them: /** FloodProtector - Start */ public static int PROTECTED_USEITEM; public static int PROTECTED_ROLLDICE; public static int PROTECTED_FIREWORK; public static int PROTECTED_ITEMPETSUMMON; public static int PROTECTED_HEROVOICE; /** FloodProtector - End */ Last step is to find this line // pvp config Which is line near 2000+ Above this line, you have to copy paste the following stuff (Don't leave any empty lines, they are not needed). // Actions FloodProtector try { Properties FloodProtector = new Properties(); InputStream is = new FileInputStream(new File(FLOODPROTECTOR_CONFIG_FILE)); FloodProtector.load(is); is.close(); PROTECTED_USEITEM = Integer.parseInt(FloodProtector.getProperty("ProtectedUseItem", "4")); PROTECTED_ROLLDICE = Integer.parseInt(FloodProtector.getProperty("ProtectedRollDice", "42")); PROTECTED_FIREWORK = Integer.parseInt(FloodProtector.getProperty("ProtectedFireWork", "42")); PROTECTED_ITEMPETSUMMON = Integer.parseInt(FloodProtector.getProperty("ProtectedItemPetSummon", "16")); PROTECTED_HEROVOICE = Integer.parseInt(FloodProtector.getProperty("ProtectedHeroVoice", "100")); } catch (Exception e) { e.printStackTrace(); throw new Error("Failed to Load "+FLOODPROTECTOR_CONFIG_FILE+" File."); } Remember, that the values there, are the values that you have set as default at your config file! Okay, now let's move on the FloodProtector.java file, in order to make some changes, since we have added a config file! Open the file and find line 53 private static final int[] REUSEDELAY = new int[]{ 4, 42, 42, 16, 100 }; Delete this line, and then copy/paste the following: private static final int[] REUSEDELAY = new int[] { Config.PROTECTED_USEITEM, Config.PROTECTED_ROLLDICE, Config.PROTECTED_FIREWORK, Config.PROTECTED_ITEMPETSUMMON, Config.PROTECTED_HEROVOICE }; And that's it! You have now your FloodProtector config file! Let's move to the next part Flood Protecting an Action Well, everything's fine with the default protected actions. But what's going on when we have to protect our own action? ;) In this guide I will show you how to protect the multisell actions. Although you can protect many other actions as well. Let's start by adding it at our config file: Open the config and add these # FloodProtected Multisell ProtectedMultisell = 4 Now, let's add them at Config.java! Open it and find line 2000+ PROTECTED_HEROVOICE = Integer.parseInt(FloodProtector.getProperty("ProtectedHeroVoice", "100")); After this line, add this: PROTECTED_MULTISELL = Integer.parseInt(FloodProtector.getProperty("ProtectedMultisell", "4")); And you're done with this file as well. Let's move on the FloodProtector.java file! Open it and find line 57 Config.PROTECTED_ITEMPETSUMMON, Config.PROTECTED_HEROVOICE Delete this line, and add this in its position Config.PROTECTED_ITEMPETSUMMON, Config.PROTECTED_HEROVOICE, Config.PROTECTED_MULTISELL And then, find the line 65 public static final int PROTECTED_HEROVOICE = 4; And under this line add this: public static final int PROTECTED_MULTISELL = 5; Okay we are done with this as well! The last step is to protect the specified action! We open the proper clientpacket first (in our case it is MultiSellChoose.java) Then, we add the FloodProtector java file at the imports: import net.sf.l2j.gameserver.util.FloodProtector; And last, we must find the proper place to add the code. In this case search for line if(player == null) return; which is line 70++ Then we leave an empty line and, under the empty line we add our code! if (!FloodProtector.getInstance().tryPerformAction(player.getObjectId(), FloodProtector.PROTECTED_MULTISELL)) { player.sendMessage("You Can't Buy Items so Fast! Try again!"); return; } And that's how we floodprotected one more action! ;) Now, if you study a bit these steps, you will be able to add many floodprotections at many packets! As I told, it's a quite nice way to protect your server (even if it's not the best). Credits & BBs Well, First of all I would like to thank my teacher Intrepid who started teaching me a few things. Also, I would like to say that this guide was created by me, so all the credits go to me. If you want to leech it, then I'll rape you :) Best Regards, Coyote. Quote
Chandy Posted December 12, 2009 Posted December 12, 2009 Nice guide m8,useful :) Keep up and thx. Quote
SySt3MGaM3RFr3aKs Posted December 12, 2009 Posted December 12, 2009 Hehe, i was getting ready to share something like this. But you.. :D Great Share. keep Up. You deserve a karma ( But i won't give you, let the others give you ) ::) Quote
Stefoulis15 Posted December 12, 2009 Posted December 12, 2009 yes ,thats what i call great. good job. FULL Explained guide , really detailed. great job mate. Quote
Alexi Posted December 12, 2009 Posted December 12, 2009 Very nC guide thnx for this you deserve karma but unfortunately i dont have the permission to give you... Quote
Coyote™ Posted December 12, 2009 Author Posted December 12, 2009 Thanks everybody, glad that it helps you :) And I am quite happy to receive this comment from Stef. Today I will correct any little mistakes, cuz I made this guide yesterday night at 2:30 =P Quote
MasterDisaster Posted December 12, 2009 Posted December 12, 2009 Such guides make me wanna start learning L2J... KIU Dude :D Quote
DominiQue Posted December 12, 2009 Posted December 12, 2009 Thx Coyote™ for this great SHARE ! Fully explained guide :P Quote
Coyote™ Posted December 12, 2009 Author Posted December 12, 2009 Thanks Guys! For any problems, don't hesitate to make a post. Quote
sweetparanoid Posted December 12, 2009 Posted December 12, 2009 You Have One Mistake My Friend...There You Puted Somewhere In The Middle Config.PROTECTED_ITEMPETSUMMON, Config.PROTECTED_HEROVOICE, Config.PROTECTED_SUBCLASS It Should Be Config.PROTECTED_ITEMPETSUMMON, Config.PROTECTED_HEROVOICE, Config.PROTECTED_MULTISELL Quote
Coyote™ Posted December 12, 2009 Author Posted December 12, 2009 You Have One Mistake My Friend...There You Puted Somewhere In The Middle Config.PROTECTED_ITEMPETSUMMON, Config.PROTECTED_HEROVOICE, Config.PROTECTED_SUBCLASS It Should Be Config.PROTECTED_ITEMPETSUMMON, Config.PROTECTED_HEROVOICE, Config.PROTECTED_MULTISELL yes, you're right xD Take a look at the time when I made this guide, and you'll understand why =P Anyway, thanks for reporting it! Quote
takhs7 Posted December 28, 2009 Posted December 28, 2009 hhmmm... sorry for the question but doesnt l2j includes floodprotection like this one :S ? Quote
Coyote™ Posted December 30, 2009 Author Posted December 30, 2009 hhmmm... sorry for the question but doesnt l2j includes floodprotection like this one :S ? Only the Gracia Final L2j Project. The Interlude floodprotectors - the ones I am talking about - need rework. There are not even configurations about floodprotectors. So, this is a nice way to start using them configurable. Quote
cr0nos Posted December 31, 2009 Posted December 31, 2009 Cool! guide, i use it and work at first! thanks man!! Quote
Belzebul Posted January 12, 2010 Posted January 12, 2010 Pro guides by coyote, keep it like this. thank you. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.