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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • Today I would like to introduce a new set of tools developed entirely from scratch in Java, designed to simplify and modernize one of the most important tasks for any online server: distributing, updating, and maintaining the game client quickly, securely, and efficiently. The system has been designed to work with Lineage II, Aion, World of Warcraft, or any other project that requires a file distribution and update system, providing a simple solution for both players and administrators.   The entire project features a modern dark-mode interface, is completely separated into individual tools, and is distributed as standalone Windows executables (.exe) using Launch4j.   1. GameLauncher: The Player Client     GameLauncher is the launcher used by players on their computers. Its goal is to make keeping the game client up to date a completely automatic and transparent process.   Smart Updates: Automatically compares local files with the remote server using a manifest file (manifest.json) Hash-Based Integrity: Calculates file hashes to download only new or modified files, saving time and bandwidth. Real-Time Downloads: Detailed progress bar with transfer speed and automatic ZIP package extraction. Standalone: Packaged into a single .exe with Java 17 requirement validation and automatic redirection if the required environment is not installed.   Source code: https://gitlab.com/u3games/GameLauncher   2. L2Compiler: The Administrator Tool     L2Compiler is the tool designed for server administrators and developers. It allows updates to be prepared and published quickly, automating much of the process that would otherwise have to be performed manually.   Mass Packaging: Select the root folder of your development client and automatically generate optimized compressed packages ready for distribution. Automatic Manifest Generation: Instantly generates the manifest.json file with all the required metadata, including file sizes, paths, and hashes, using Gson. Preference Management: Automatically saves the last used paths through java.util.prefs to speed up everyday development tasks. Asynchronous Interface: Background processing through SwingWorker to prevent the interface from freezing during heavy operations.   Source code: https://gitlab.com/u3games/GameCompiler   A System Designed for Online Servers   The idea behind this project is simple: the administrator prepares an update using L2Compiler, and the player receives it automatically through GameLauncher. This allows both tools to work together and provide a simple update workflow:   Development Client → L2Compiler → Server → GameLauncher → Updated Client   There is no need for players to manually search for files, download patches one by one, or go through complicated installation processes. Although the system was initially designed with projects such as Lineage II, Aion, and World of Warcraft in mind, it is not tied to any specific game. If your project needs to distribute files and keep its clients up to date, it can be easily adapted to fit your needs.   Open Source for the Community   This project was created by me for the U3Games community, with the goal of providing a modern, simple, and reusable alternative for managing updates across our servers. The source code is publicly available so that other developers can study it, adapt it, improve it, and contribute to the project.     Have a Suggestion, Found a Bug, or Want to Contribute?   Any suggestions, bug reports, improvements, or contributions are more than welcome. The goal is to continue evolving the project together with the community and turn it into an increasingly complete tool for all kinds of online servers and projects.
    • Let's do 1 for share for people? Which one? 
    • A 100-YEAR-OLD ORDERED A FLAGSHIP AND PASSED THE VIDEO CALL 🚓 Spanish police took down a gang that found a hole in a major telecom operator's online store. A script told the warehouse to ship before payment went through. The haul: over 150 smartphones worth more than €50,000. The cover was a farm of borrowed identities: documents of around fifty people, including 100-year-old pensioners. They used them to open bank accounts, register phone numbers and send parcels across the country. The cherry on top: gang members passed video KYC themselves, posing as the elderly document holders. The "customer's" age didn't bother the antifraud. Operation Sakosita: seven arrested in Madrid, the alleged ringleader caught in Italy on a European arrest warrant. Meanwhile, the frozen accounts and someone else's debts land on the people whose names were used. 🔒 Account locked because someone opened something in your name? Message us – we'll gather the evidence and see the unlock through. › TG: @mustang_service_ms ( https:// t.me/ mustang_service_ms ) › Channel: Mustang Service ( https:// t.me/ +JPpJCETg-xM1NjNl ) #drawing #kyc #photoshop #unban #news
    • he did it for me    thanks you 😄  some of that bones is broken is some pets or is not exist so is better to buy some from the clientDev: @NevesOma
    • Your ranking service for Telegram bots is interesting. For companies wanting broader organic growth, I rely on the best b2b seo company for technical SEO and pipeline-focused content strategies that actually convert.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..