Jump to content
  • 0

[help] Subclass Java


Question

Posted

Hi,

i want to compile subclass...

What should i write in L2Villagemasterinstance.java

where is Subclass changing configs,

that you can change subclasss only every 15s?

7 answers to this question

Recommended Posts

  • 0
Posted

Hi,

i want to compile subclass...

What should i write in L2Villagemasterinstance.java

where is Subclass changing configs,

that you can change subclasss only every 15s?

well this changet :), use flood protection now!

 

 

well go /gameserver/util/FloodProtector.java

 

this is ur code,or smthink like this! a part of code!

// protected actions
public static final int PROTECTED_USEITEM = 0;
public static final int PROTECTED_ROLLDICE = 1;
public static final int PROTECTED_FIREWORK = 2;
public static final int PROTECTED_ITEMPETSUMMON = 3;
public static final int PROTECTED_HEROVOICE = 4;
public static final int PROTECTED_DROPITEM = 6;

 

Add

	public static final int PROTECTED_SUBCLASS = 5;

 

 

2nd STEP

 

go /gameserver/model/actor/instance/L2VillageMasterInstance.java

 

in imports add this

import com.l2jfree.gameserver.util.FloodProtector;

 

And Before This

player.setActiveClass(paramOne); 
      
                                     content.append("Change Subclass:<br>Your active sub class is now a <font color=\"LEVEL\">" 

 

Add This

 

                           /* 
                                      * DrHouse: Despite this is not 100% retail like, it is here to avoid some exploits during subclass changes, specially 
                                      * on small servers. TODO: On retail, each village master doesn't offer any subclass that is not given by itself so player 
                                     * always has to move to other location to change subclass after changing previously. Thanks Aikimaniac for this info. 
                                    */ 
                                     if (!FloodProtector.getInstance().tryPerformAction(player.getObjectId(), FloodProtector.PROTECTED_SUBCLASS)) 
                                     { 
                                            _log.warn("Player "+player.getName()+" has performed a subclass change too fast"); 
                                             return; 
                                     } 

 

ps: code dont checked from me, i dont know if it work 100% well for help go

 

http://l2jfree.com:8060/browse/l2jfree/trunk/l2jfree-core/src/main/java/com/l2jfree/gameserver/util/FloodProtector.java?r1=4558&r2=4677

 

http://l2jfree.com:8060/browse/l2jfree/trunk/l2jfree-core/src/main/java/com/l2jfree/gameserver/model/actor/instance/L2VillageMasterInstance.java?r1=4672&r2=4677

 

 

  • 0
Posted

Fogotendx20

its working :),

and maybe u know how to write a message from npc, if he

get flooded by player (talking about villagemasters)

that they can change sub only after 10s ?

  • 0
Posted

Fogotendx20

its working :),

and maybe u know how to write a message from npc, if he

get flooded by player (talking about villagemasters)

that they can change sub only after 10s ?

 

ya im know :) :D but i dont know where to put it....in wich part of code anywayi will check it!

 

that they can change sub only after 10s ?

nop now.....delay is for 2 second! w8 a little maby they fx it,smthink like chat flood protection add Properties to can from config to chose a time!

 

smthink like this

# Time limit between using Global Chat in 100ms
GlobalChatTime = 1

 

well a little Update!

 

FloodProtector.java

/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
* 
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
* 
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.util;

import java.util.logging.Logger;

import javolution.util.FastMap;
import javolution.util.FastMap.Entry;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.GameTimeController;

/**
* Flood protector
* 
* @author durgus
*/
public class FloodProtector
{
private static final Logger _log = Logger.getLogger(FloodProtector.class.getName());

private static FloodProtector _instance;

public static final FloodProtector getInstance()
{
	if (_instance == null)
	{
		_instance = new FloodProtector();
	}
	return _instance;
}

// =========================================================
// Data Field
private FastMap<Integer, Integer[]> _floodClient;

// =========================================================

// reuse delays for protected actions (in game ticks 1 tick = 100ms)
private static final int[] REUSEDELAY = new int[]
{
	4, 42, 42, 16, 100, 10, 20
};

// protected actions
public static final int PROTECTED_USEITEM = 0;
public static final int PROTECTED_ROLLDICE = 1;
public static final int PROTECTED_FIREWORK = 2;
public static final int PROTECTED_ITEMPETSUMMON = 3;
public static final int PROTECTED_HEROVOICE = 4;
public static final int PROTECTED_MULTISELL = 5;
public static final int PROTECTED_SUBCLASS = 6;

// =========================================================
// Constructor
private FloodProtector()
{
	_log.info("Initializing FloodProtector");
	_floodClient = new FastMap<Integer, Integer[]>(Config.FLOODPROTECTOR_INITIALSIZE).setShared(true);
}

/**
 * Add a new player to the flood protector (should be done for all players
 * when they enter the world)
 * 
 * @param playerObjId
 */
public void registerNewPlayer(int playerObjId)
{
	// create a new array
	Integer[] array = new Integer[REUSEDELAY.length];
	for (int i = 0; i < array.length; i++)
		array[i] = 0;

	// register the player with an empty array
	_floodClient.put(playerObjId, array);
}

/**
 * Remove a player from the flood protector (should be done if player loggs
 * off)
 * 
 * @param playerObjId
 */
public void removePlayer(int playerObjId)
{
	_floodClient.remove(playerObjId);
}

/**
 * Return the size of the flood protector
 * 
 * @return size
 */
public int getSize()
{
	return _floodClient.size();
}

/**
 * Try to perform the requested action
 * 
 * @param playerObjId
 * @param action
 * @return true if the action may be performed
 */
public boolean tryPerformAction(int playerObjId, int action)
{
	Entry<Integer, Integer[]> entry = _floodClient.getEntry(playerObjId);
	if (entry == null)
		return false; // player just disconnected
	Integer[] value = entry.getValue();

	if (value[action] < GameTimeController.getGameTicks())
	{
		value[action] = GameTimeController.getGameTicks() + REUSEDELAY[action];
		entry.setValue(value);
		return true;
	}
	return false;
}
}

 

well we start from 0

0,1,2,3,4,5,6

 

6=Subclass

 

here is the times!

	// reuse delays for protected actions (in game ticks 1 tick = 100ms)
private static final int[] REUSEDELAY = new int[]
{
	4, 42, 42, 16, 100, 10, 20
};

 

xmmm

0=4

1=42

2=42

3=16

4=100

5=10

6=20

 

 

well 4 is Hero Voice Flood Protection, i think HV Protection is 10 second? right?

well for subclass add 150(15 second) and remove 20 (2sec) so easy :)

 

Again little UPDATE

 

case 7: // Change Subclass - Action
                    /*
                     * Warning: the information about this subclass will be removed from the
                     * subclass list even if false!
                     */
                    if (player.modifySubClass(paramOne, paramTwo))
                    {
                    	player.stopAllEffects(); // all effects from old subclass stopped!
                    	player.setActiveClass(paramOne);

                        content.append("Change Subclass:<br>Your sub class has been changed to <font color=\"LEVEL\">"
                            + CharTemplateTable.getInstance().getClassNameById(paramTwo) + "</font>.");

                        player.sendPacket(new SystemMessage(SystemMessageId.ADD_NEW_SUBCLASS)); // Subclass added.
                    }
                    else
                    {
                        /*
                         * This isn't good! modifySubClass() removed subclass from memory
                         * we must update _classIndex! Else IndexOutOfBoundsException can turn
                         * up some place down the line along with other seemingly unrelated
                         

well in case7(change sub action) go in

 

content.append("Change Subclass:<br>Your sub class has been changed to <font color=\"LEVEL\">"
                            + CharTemplateTable.getInstance().getClassNameById(paramTwo) + "</font>.");

 

this is message when u change sub ^^ Edit it and add your message!

 

EXAMPLE

content.append("Change Subclass:<br>Subclass Manager Edited,we Add 20 Second Penalty...so u can change your cubclass every 20 second. To Above To Stuck Skills!<br>Your sub class has been changed to <font color=\"LEVEL\">"

                            + CharTemplateTable.getInstance().getClassNameById(paramTwo) + "</font>.");

 

just play with Custom Message,play with color :) to be beuty:)

 

my english is DEAD Soz!

  • 0
Posted

is this for l2jfree??and this line you say to add

/*

                                      * DrHouse: Despite this is not 100% retail like, it is here to avoid some exploits during subclass changes, specially

                                      * on small servers. TODO: On retail, each village master doesn't offer any subclass that is not given by itself so player

                                     * always has to move to other location to change subclass after changing previously. Thanks Aikimaniac for this info.

                                    */

                                     if (!FloodProtector.getInstance().tryPerformAction(player.getObjectId(), FloodProtector.PROTECTED_SUBCLASS))

                                     {

                                            _log.warn("Player "+player.getName()+" has performed a subclass change too fast");

                                             return;

                                     }

 

Before this

player.setActiveClass(paramOne);

     

                                     content.append("Change Subclass:<br>Your active sub class is now a <font color=\"LEVEL\">"

 

But there are o lot of lines like this so just tell me in which case we add it....

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.

Guest
Answer this question...

×   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.

×
×
  • Create New...