Jump to content

Recommended Posts

Posted

Hello everybody. Here I am again with another topic.

Here you will learn about a few things in l2j.

It would be a bit annoying if I made a new topic for each guide, so I decided to compile them in this one. Let's begin?

 


 

Chapter 1: Voiced Commands

 

All of us know the Voiced Commands.

Simple commands for players that start with the dot (.)

 

So, let's see how to make a simple one!

Let's begin with the well known license (That part can be skipped, but let's do it for fun xD)

/*
* 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 2, 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/

 

You can also replace it with your own "license".

Let's continue setting the package.

Since the Voicedcommands are made in the voicedcommandhandlers, the package will always be the same. Which means that the package will be:

package net.sf.l2j.gameserver.handler.voicedcommandhandlers;

 

Okay we are done with this.

Now let's continue with the imports.

You have two options: You will either set the imports now, if you know what you'll use or leave it for later (you'll write what you want and import the proper stuff manually).

 

We'll work with the online voiced command in order to show you a few things (you all know what it does, it shows the ammount of Online players). Even if I know what we'll write, I won't add the imports now, to show you about the imports.

 

Okay, let's add your name as authors now, in order to show who wrote the code!

/**
* @author YourNameHere
*/

You just have to insert your name instead of the "YourNameHere".

 

Let's start the main stuff!

You have to set the class as public and show that it implements the "IVoicedCommandHandler".

So, the form will be like this:

public class OnlinePlayers implements IVoicedCommandHandler

For other codes, the form will be the same, although the "OnlinePlayers" must be replaced with your new voicedcommand.

 

Let's start writing. You all know how! {

Now, let's set the voicedcommands that will be made in this file.

how to do this? Simple. First decide what the command will be. Then show it in this form:

private static final String[] VOICED_COMMANDS ={"on"};

 

Instead of "on" you will need to write your command. Don't delete the "" though!

 

Now let's write what will happen when a player presses the command.

In this case, once the player presses the command he will see the ammount of players online.

So:

public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
        {
	        if (command.startsWith("on"))
	        {
	            showPlayers(activeChar, target);		
	        }
	        return true;
               }

Don't forget! Instead of "on" you have to add your own command, and instead of the action I set (showPlayers) you have to set your own.

 

We would have to end our code with this:

public String[] getVoicedCommandList()
{
	return VOICED_COMMANDS;
}

 

Although, in this code we have to explain what the action above is.

Since the "showPlayers" doesn't exist, we have to "Explain" what it is and what it does.

So, in this case we set the void and make it to send some systemmessages to the player, in order to inform him about the ammount of online players.

So it will be:

public void showPlayers (L2PcInstance player, String target)
{

	{
          	        sm = new SystemMessage(SystemMessageId.S1_S2);	
          	        sm.addString("players are online.");
          	        sm.addNumber(L2World.getInstance().getAllPlayers().size());
          	        player.sendPacket(sm);

	}
}

 

In the end we just close it with a "}".

Now it's time to set the imports!

Let's see what we used.

In our imports we always use the IVoicedCommandHandler, so

import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;

Next, we used the L2World in order to see how many players are online.

So,

import net.sf.l2j.gameserver.model.L2World;

Don't forget the L2PcInstance, for the activeChar (the online active player).

import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;

And in the end we used systemmessages to tell him how many players were online.

So we import these two:

import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;

Use the function "Organise Imports" and the code is ready!

Now save and close your file!

 

We are not done yet, though!

There is something left!

We have to register our code!

 

In Gracia it will be done on the MasterHandler file, so it will be registered on the VoicedCommands part like that:

VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new OnlinePlayers());

There's no need to import the location of the file, since it imports automaticaly every file at that folder.

 

In Interlude it will be different. You will have to go at Gameserver.java file, open it and add the import.

This file will be imported like:

import net.sf.l2j.gameserver.handler.voicedcommandhandlers.OnlinePlayers;

And now comes the registeration.

Find the VoicedCommands part, and register the new command like:

_voicedCommandHandler.registerVoicedCommandHandler(new OnlinePlayers());

 

And we're done!

That's how you created a brand new Voiced Command! =]

 

 

Chapter 2: Configurations

 

All of us know the "Config" file. Custom/non modifications are being added there. The reason though is not to add custom features, but to make our lifes easier! Configs are made in order to handle specified settings from simple modifcations. For example, you can simply add a custom TvT Event. You add the teleporting coordinates, you enable it, you set the reward, etc. But if you want to change these settings, in the future many times, you will get pissed off if you don't find the values easily. The solution? You make them configurable. In the configs, you can just change a few numbers or a "True" to "False" (and vice versa) and change the whole server in no time! So we will now see easily, how to make our own configuration. We will make a simple one. My goal is not to teach you what each thing in Config.java does, or how to make every single value configurable. What I want to do, is to show you what Configurations are, and how to start Configuring stuff. Let's begin!

 

First of all, we find what we want to set configurable.

I picked the OnlinePlayers VoicedCommands that we created in a previous guide!

So, let's see.

We will set the use of the class configurable.

What do I mean?

We will create a config that if we set to "True", will enable the use of the VoicedCommand, otherwise (if set to "False) will disable it.

We first create the configuration at the Config.java file, located in net.sf.l2j

Open the file and search for

/**define L2JMODS */

Under this, we have to set the new boolean.. (If you don't know what booleans are, then read the last part of my l2j guide in the L2j Section).

So, let's add this:

public static boolean ENABLE_OUR_CODE;

Instead of ENABLE_OUR_CODE, you can set another name, like ENABLE_ONLINE_VC.

Now, let's search for

Properties L2JModSettings

.

You'll see some configurations about Champion Mobs, etc.

You will have to place the new configuration under those (for example).

So let's add this:

ENABLE_OUR_CODE = Boolean.parseBoolean(L2JModSettings.getProperty("EnableTheCode", "True"));

 

You can replace again the ENABLE_OUR_CODE with something you like, although it must be the same with the one you set above. The "EnableTheCode" is what will be shown at the properties file. About the "True" value we set, you don't have to worry. The feature will be enabled/disabled depending ONLY to the value you will set at the properties file (In this case, l2jmods).

 

So we are done with the java part of the configuration.

Now, let's find the properties file (l2jmods) and add the new configuration.

Open the file and add in the end this:

EnableTheCode = True

You can set it either to true or false. Absolutely your decision.

 

The last part! We have to set this at a place where the code we added before (the custom voiced command, in this case) will be affected. What does this mean? We must find the proper place to add the configuration! In our case, we will go at the place where we registered the command! (MasterHandler for Gracia and Gameserver for Interlude).

Above the code with which we registered the command (this code:

_voicedCommandHandler.registerVoicedCommandHandler(new OnlinePlayers());

Above it, we add the configuration.

if(Config.ENABLE_OUR_CODE)

 

And that's it!

What did we finally do? We created a configuration for the OnlinePlayers voiced command.

If we set the value to "True" the command will be ok. If we set it to "False" the command will be disabled!

 

 

 

What did we learn today? How to create a new VoicedCommand, and how to make Configurations!

I did my best to explain everything in an informal way, so it can be understood by newbies.

If there is something you'd like to learn, or something you didn't understand, feel free to ask here!

Don't spam please.

 

Best Regards,

Coyote™.

 

PS: More guides like these will come soon, if I find free time.

 

To be Continued...

http://www.maxcheaters.com/forum/index.php?topic=123823.0

Posted

Naah, there is just no space left in here.

http://www.maxcheaters.com/forum/index.php?topic=92146.0

 

So I continue them like that xD

from mine topic in greek section i meant :D

 

 

anyway make sure you will continue them , because noobs keep creating - using preconfs

Posted

anyway make sure you will continue them , because noobs keep creating - using preconfs

 

I will keep creating guides..

I just need free time, and the next days I doubt if I have some..

I'll continue them soon though, don't worry..

Posted

hahah the license and author part is funny.. well u have some good guides Coyote.. will help alot of nabs here that have no clue what they doing :P

i plan on making a full detailed guide "coding an event from scratch" and i will be coding a ctf or dm there.. but probably i wont soon since im a lazy ass.. xD

 

edit: btw u maybe wanna add somewhere in the guide that in epilogue instead of "net.sf.l2j" u need to put "com.l2jserver" (or something like that.. i dont have it in front of me right now)

Posted

hahah the license and author part is funny.. well u have some good guides Coyote.. will help alot of nabs here that have no clue what they doing :P

i plan on making a full detailed guide "coding an event from scratch" and i will be coding a ctf or dm there.. but probably i wont soon since im a lazy ass.. xD

 

Well, thanks and good luck with your future guide!

Posted

As a newbie in java, i have a question. What exactly is this part doing?

public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)

 

It is the boolean that, let's say, shows the command and its use.

It shows that if the player presses ".on" then the action below happens.

  • 2 months later...
Posted

i can't add new command becaus my VoicedCommandHandler.java it look like this:

 

package net.sf.l2j.gameserver.handler;

import java.util.Map;
import java.util.logging.Logger;

import javolution.util.FastMap;
import net.sf.l2j.Config;

public class VoicedCommandHandler
{
private static Logger _log = Logger.getLogger(ItemHandler.class.getName());

private static VoicedCommandHandler _instance;

private Map<String, IVoicedCommandHandler> _datatable;

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

private VoicedCommandHandler()
{
	_datatable = new FastMap<String, IVoicedCommandHandler>();
}

public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
{
	String[] ids = handler.getVoicedCommandList();
	for (int i = 0; i < ids.length; i++)
	{
		if (Config.DEBUG) _log.fine("Adding handler for command "+ids[i]);
		_datatable.put(ids[i], handler);
	}
}

public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
{
	String command = voicedCommand;
	if (voicedCommand.indexOf(" ") != -1) {
		command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
	}
	if (Config.DEBUG)
		_log.fine("getting handler for command: "+command+
				" -> "+(_datatable.get(command) != null));
	return _datatable.get(command);
}

    public int size()
    {
        return _datatable.size();
    }
}

what can i do?

Posted

i can't add new command becaus my VoicedCommandHandler.java it look like this:

 

package net.sf.l2j.gameserver.handler;

import java.util.Map;
import java.util.logging.Logger;

import javolution.util.FastMap;
import net.sf.l2j.Config;

public class VoicedCommandHandler
{
private static Logger _log = Logger.getLogger(ItemHandler.class.getName());

private static VoicedCommandHandler _instance;

private Map<String, IVoicedCommandHandler> _datatable;

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

private VoicedCommandHandler()
{
	_datatable = new FastMap<String, IVoicedCommandHandler>();
}

public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
{
	String[] ids = handler.getVoicedCommandList();
	for (int i = 0; i < ids.length; i++)
	{
		if (Config.DEBUG) _log.fine("Adding handler for command "+ids[i]);
		_datatable.put(ids[i], handler);
	}
}

public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
{
	String command = voicedCommand;
	if (voicedCommand.indexOf(" ") != -1) {
		command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
	}
	if (Config.DEBUG)
		_log.fine("getting handler for command: "+command+
				" -> "+(_datatable.get(command) != null));
	return _datatable.get(command);
}

    public int size()
    {
        return _datatable.size();
    }
}

what can i do?

 

Add them in gameserver

serch for:

_log.config("VoicedCommandHandler: Loaded " + _voicedCommandHandler.size() + " handlers.");

and add before:

_voicedCommandHandler.registerVoicedCommandHandler(new Wedding());

Replace Wedding with your VoicedCommand Name Save & Exit and you are done :D

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

    • Since technical talk offends people, I believe I should return back to writting my Lineage 2 lore stories. Here's the next one:   Once upon a time, there was a boy and a small adorable wolf.    The boy really loved the wolf but as the wolf grow older and bigger, it became agressive and would bite the boy. One day the boy and the wolf decided to go to the city to buy potions. The road was long and hilly so the boy moved all his adena to the wolf bags to help his legs and reach the city easier.   When they reached the city, the boy tried to take the adena out of the wolf's bags. But the wolf would not ! He bit the boy and said "You will not get this adena back, this is my adena". The boy got angry. He decided to go to the pet master and ask for help.    "Pet master, pet master ! My wolf is big, bad and angry and it won't obey me. I want my adena back and it bites me. "   The pet master looked at the big angry wolf, then looked at the boy and said. "I have a solution for your problem young one. I have magic. Dark magic. I can turn your big bad elder wolf into a younger puppy for free, all you have to do is spell the magic chants. Nothing more, no wolf modifying wands, just your say".   The boy thought about it for a bit, and decided that he indeed wanted to turn things back. But when he was about to spell the magic words, guards arrived at the pet master.    The city guard captain said "Is this the big bad angry wolf that bites people and doesn't give back his adena ? We will kill this wolf !"    For a moment the boy hesitated but he said "This wolf is big bad and angry, but I love this wolf and I dont want it to die ! Please don't kill the big bad angry wolf." But the boy was not fast enough. The guards jumped the wolf and started slashing on him with their swords. The boy didn't know what to do, so in it its final moments right as the wolf was about to die, it spelled the magic words. "Pet master, make my wolf young and adorable again !"   But he was not fast enough. The wolf got slashed and killed by the guards just one moment before the boy could finish his last word.    But as the words came out of his mouth, with the wolf's dead body on the floor, a younger wolf manifested out of thin air. The magic was real. The guards got scared and run away. Now the boy was left with a dead old bad angry wolf and next to him an alive younger version.    The boys joy was even bigger when it opened the new wolfs bags and his adena was finally there. He took the adena and went back to buy potions in the city.   Twenty four hours later, the boy couldn't believe how his fortune would change ...   (No AI was used to write this story)
    • This is like 2017 MaxCheaters. i love it.
    • NEW SEASON GRAND OPENING FROM - 30 OCTOBER 2026, FRIDAY, 20:00 +2 GMT !
    • My bug report was a proper submission. I shouldn't have shown the exploit, I will accept that. Let's end it here. 
    • To Finish this, because it's need a explanation   1. “I come to your forum” — It's the L2JMobius forum, not mine. I'm a contributor, not the owner or the maintainer responsible for deciding which fixes get committed.   2. “Which is why I left” — That's not an accurate account of what happened. You may have left voluntarily once, but you were also banned from the Discord server three times after repeatedly returning and causing the same disruptions. Those are not the same thing.   3. “You personally reply and reject that it works” — I asked how a negative withdrawal could be performed and later requested a demonstration of the claimed exploit. At no point did I reject the patch or claim the vulnerability was impossible. Asking for evidence is not the same as rejecting someone's work.   4. “You leave it unpatched for days” — I don't make that decision. Whether and when a patch gets committed is entirely up to the project maintainer, not me.   5. “You challenge me to post a video” — Yes, I asked you to demonstrate the exploit. You interpreted that as a rejection of your work, which it wasn't. Requesting proof of a claimed exploit is a perfectly reasonable part of technical discussion.   6. “Asshole-ness is a mutually contracted disease” — You're responsible for your own behavior, just as I'm responsible for mine. Disagreeing with you or questioning your claims doesn't justify personal insults. If you believe I've treated you unfairly, address what I actually said rather than making my behavior an excuse for yours.   And one question remains unanswered: why did you publicly disclose the exploitationmethod before the fix was released, after previously saying you wanted to avoid harming the project?   The vulnerability was real, the fix was accepted, and the commit was published. I have no problem acknowledging any of that.   My disagreement has never been about whether the bug deserved to be fixed. It's about how you've handled the discussion and repeatedly misrepresented my role in it.     I have nothing against you personally. My issue is with the way you conduct yourself in these discussions.   And no, you're not obligated to prove anything to me. However, when you make a technical claim, the burden of proof is on you. You cannot reasonably expect others to accept your claims without sufficient evidence.   Questioning a claim is not the same as rejecting it, nor is it a personal attack.   This isn’t about fanaticism; it’s about pushing back against the completely senseless attacks constantly leveled at the project as a whole.   It’s always the same thing: they badmouth it, claiming the project is worthless—yet the very same people criticizing it are the first in line to download a leaked version.   Enough is enough. This discussion has dragged on far too long over something that ought to be straightforward; if you’re going to submit a bug report, you should at least do it properly.
  • 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..