PDA

View Full Version : [Rs377d] Commands.



Fire cape
June 30th, 2010, 21:52
Description: Adding commands to rs377d.
Assumed Knowledge: How to read, adding new class files.
Tested Server: Rs377d.
Files/Classes modified: Configuration.
Files/Classes added: CommandEventListener.

Firstly,

Navigate your way through your packaging.

org.rs377d.net.event.impl

Make a new class file.
Name the class file CommandEventListener.
Add this inside it:


package org.rs377d.net.event.impl;

import org.apache.mina.core.session.IoSession;
import org.rs377d.model.player.Player;
import org.rs377d.net.Rs2Packet;
import org.rs377d.net.event.EventListener;
import org.rs377d.net.event.EventListenerChain;

/**
* Commands class.
* @author Fire cape
*/
public class CommandEventListener implements EventListener {

@Override
public void handle(IoSession session, Rs2Packet packet, EventListenerChain chain) throws Exception {
String commandString = packet.getRs2String();
String[] args = commandString.split(" ");
String command = args[0].toLowerCase();
try {
if(command.equals("test")) {
Player.getActionSender().sendMessage("Test complete");
}
} catch(Exception ex) {
Player.getActionSender().sendMessage("Error while processing command.");
}
}
}

Now go to config.xml (which can be found in the main folder where src and bin is).
add this at the bottem with all the other opcodes!

<!-- Commands event chain -->
<CHAIN OPCODES="56">
<EVENT_LISTENER CLASS="org.rs377d.net.event.impl.CommandEventListener"/>
</CHAIN>

Jesse
July 1st, 2010, 15:58
nice ganna use