Jump to content

[Guide]L2j IT Flood Protectors: Configuring, Adding, Learning.


Coyote™
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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 ) ::)

Link to comment
Share on other sites

yes ,thats what i call great. good job.

FULL Explained guide , really detailed.

great job mate.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • 3 weeks later...

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.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock