Purpose: Making a command handler to reduce lagg in your server!
Difficulty: 2
Assumed Knowledge: Copy and Paste
Server Base: All (i based mine off whitescape)
Classes Modified: Client.java, server.java
-------------------------*-PROCEDURE-*-------------------------
Step 1: Open up your Client.java and search for public void customCommand which is you command void
and you should see some like this:
Quote:
public void customCommand(String command) {
actionAmount++;
after the actionAmount++; press enter then add this:
Quote:
server.CommandHandler.CommandHandler(command, playerId);
Step 2: Open up your server.java and search for playerHandler = new PlayerHandler();
press enter after that and add this:
Quote:
CommandHandler = new CommandHandler();
then search for public static PlayerHandler playerHandler = null;
press enter after that and add this:
Quote:
public static CommandHandler CommandHandler = null;
Now its time to add the CommandHandler.java so here is the downloads:
Java File:
Making a Command: To make a command do it like every command but put it in the
public void CommandHandler(String command, int a)
Then you can make another void on the top so you wont have to make one in the client.java so it will not cause lagg!
so if you want to make a command just make it like this:
Quote:
if (command.equalsIgnoreCase("test"))
{
CNAME(a);
}
and make sure it is in CommandHandler VOID so it will
look like this:
Quote:
public void CommandHandler(String command, int a)
{
if (command.equalsIgnoreCase("test"))
{
CNAME(a);
}
}
To make a void in the command handler use this layout:
Quote:
public void CNAME(int a)
{
client p = (client) server.playerHandler.players[a];
}
then do not remove the client p = (client) server.playerHandler.players[a];
ok so if you want it to like add an item make it like this:
Quote:
p.addItem(995, 123)
and the p. in the beginning means that it is a void from the Client if you dont add a p. before the void that comes from the client.java you you come across and error saying the variable is not recognizable
after you finish with the void it will look like this:
Quote:
public void CNAME(int a)
{
client p = (client) server.playerHandler.players[a];
p.addItem(995, 123)
}