How to add custom commands
Custom commands, as in teleport commands, and more.
Step 1): Open up 'client.java' in your server files.
Step 2): Search for
Code:
if(command.startsWith
Step 3): Now, under the }, is where you add the new code.
Example:
Code:
if(command.startsWith("coordinates") && playerRights > 0){
sM("AbsX: "+absX+" AbsY: "+absY+"");
}
if(command.startsWith("hail") && playerRights > 3){
hail();
Here are some commands some people might not have:
If you want to tele some where, here is the code:
Code:
if (command.startsWith("tele") && playerRights >= 20) {
String[] args = command.split(" ");
if(args.length == 3) {
int newPosX = Integer.parseInt(args[1]);
int newPosY = Integer.parseInt(args[2]);
toX = newPosX;
toY = newPosY;
}
Result: Type in ::tele xcord ycord
Where it says xcord and ycord, that is where the coordinates go.
If you want to get the coordinates:
Code:
if(command.startsWith("coordinates") && playerRights > 0){
sM("AbsX: "+absX+" AbsY: "+absY+"");
}
Result: Type in ::coordinates
And you will get both coordinates on your exact position.