Tutorial was developed from this post:
http://www.rune-server.org/runescape...tion-mods.html
Preview:
Screenshot by Lightshot
Credits:
jo0 3a7 lo7z for posting the original tutorial above.
First, if you dont have it already, add this into WorldPacketsDecoder.java with the other ones like it:
Code:
private final static int PLAYER_OPTION_5_PACKET = 77;
Next, find this:
Code:
|| packetId == PLAYER_OPTION_1_PACKET
Under that, add this:
Code:
|| packetId == PLAYER_OPTION_5_PACKET
Next, find this:
Code:
public static void decodeLogicPacket(final Player player, LogicPacket packet) {
int packetId = packet.getId();
InputStream stream = new InputStream(packet.getData());
Under it, add this:
Code:
if (packetId == PLAYER_OPTION_5_PACKET) {
boolean unknown = stream.readByte() == 1;
int playerIndex = stream.readUnsignedShortLE128();
Player other = World.getPlayers().get(playerIndex);
if (other == null || other.isDead() || other.hasFinished() || !player.getMapRegionsIds().contains(other.getRegionId()))
return;
if (player.getLockDelay() > Utils.currentTimeMillis())
return;
if (!other.withinDistance(player, 14)) {
player.getPackets().sendGameMessage("Unable to find target "+other.getDisplayName());
return;
}
player.getDialogueManager().startDialogue("ModPanel", playerIndex);
}
next, add this dialogue:
Code:
package com.rs.game.player.dialogues;
import com.rs.Settings;
import com.rs.game.World;
import com.rs.game.player.Player;
import com.rs.game.player.dialogues.Dialogue;
import com.rs.utils.SerializableFilesManager;
import com.rs.utils.Utils;
public class ModPanel extends Dialogue {
private int playerIndex;
@Override
public void start() {
playerIndex = (Integer) parameters[0];
Player target = World.getPlayers().get(playerIndex);
stage = 1;
if (stage == 1) {
sendOptionsDialogue("Player Options: "+target.getDisplayName()+"",
"<col=ff0000>Ban Permanently</col>",
"<col=ff0000>Mute 24 Hours</col>",
"<col=ff0000>Force Logout</col>",
"<col=ff0000>Jail 24 Hours</col>",
"<col=ff0000>Cancel</col>");
stage = 2;
}
}
@Override
public void run(int interfaceId, int componentId) {
if (stage == 2) {
if (componentId == OPTION_1) {
ban();
end();
}
if (componentId == OPTION_2) {
mute();
end();
}
if (componentId == OPTION_3) {
kick();
end();
}
if (componentId == OPTION_4) {
jail();
end();
}
if (componentId == OPTION_5) {
end();
}
}
}
public void ban() {
Player target = World.getPlayers().get(playerIndex);
if (target == null || target.isDead() || target.hasFinished() || !player.getMapRegionsIds().contains(target.getRegionId()))
return;
if (player.getLockDelay() > Utils.currentTimeMillis())
return;
if (!target.withinDistance(player, 14)) {
player.getPackets().sendGameMessage(""+target.getDisplayName()+" is not in range.");
return;
}
if (target.getRights() == 2) {
player.sendMessage("You can't ban an administrator.");
target.sendMessage(""+player.getDisplayName()+" has attempted to ban you.");
return;
}
SerializableFilesManager.savePlayer(target);
target.setPermBanned(true);
target.forceLogout();
player.getPackets().sendGameMessage("You have banned " + target.getDisplayName()+".");
World.sendWorldMessage("<col=ff0000><img=5>News: " + target.getDisplayName() + " has been banned by "+player.getDisplayName()+"", true);
}
public void mute() {
Player target = World.getPlayers().get(playerIndex);
if (target == null || target.isDead() || target.hasFinished() || !player.getMapRegionsIds().contains(target.getRegionId()))
return;
if (player.getLockDelay() > Utils.currentTimeMillis())
return;
if (!target.withinDistance(player, 14)) {
player.getPackets().sendGameMessage(""+target.getDisplayName()+" is not in range.");
return;
}
if (target.getRights() == 2) {
player.sendMessage("You can't mute an administrator.");
target.sendMessage(""+player.getDisplayName()+" has attempted to mute you.");
return;
}
player.getPackets().sendGameMessage("You have muted " + target.getDisplayName()+" for 24 hours.");
target.setMuted(Utils.currentTimeMillis() + 1440000);
target.getPackets().sendGameMessage("You have been muted for 24 hours by "+player.getDisplayName()+".");
World.sendWorldMessage("<col=ff0000><img=5>News: " + target.getDisplayName() + " has been muted for 24 hours by "+player.getDisplayName()+"", true);
}
public void kick() {
Player target = World.getPlayers().get(playerIndex);
if (target == null || target.isDead() || target.hasFinished() || !player.getMapRegionsIds().contains(target.getRegionId()))
return;
if (player.getLockDelay() > Utils.currentTimeMillis())
return;
if (!target.withinDistance(player, 14)) {
player.getPackets().sendGameMessage(""+target.getDisplayName()+" is not in range.");
return;
}
target.forceLogout();
player.getPackets().sendGameMessage("You have kicked: " + target.getDisplayName() + ".");
}
public void jail() {
Player target = World.getPlayers().get(playerIndex);
if (target == null || target.isDead() || target.hasFinished() || !player.getMapRegionsIds().contains(target.getRegionId()))
return;
if (player.getLockDelay() > Utils.currentTimeMillis())
return;
if (!target.withinDistance(player, 14)) {
player.getPackets().sendGameMessage(""+target.getDisplayName()+" is not in range.");
return;
}
if (target.getRights() == 2) {
player.sendMessage("You can't jail an administrator.");
target.sendMessage(""+player.getDisplayName()+" has attempted to jail you.");
return;
}
target.setJailed(Utils.currentTimeMillis() + 1440000);
target.getControlerManager().startControler("JailControler");
target.getPackets().sendGameMessage("You've been Jailed for 24 hours by " + Utils.formatPlayerNameForDisplay(player.getUsername()) + ".");
player.getPackets().sendGameMessage("You have Jailed 24 hours: " + target.getDisplayName() + ".");
SerializableFilesManager.savePlayer(target);
}
@Override
public void finish() {
// TODO Auto-generated method stub
}
}
Open DialogueHandler, add this into init():
Code:
handledDialogues.put("ModPanel", (Class<Dialogue>) Class.forName(ModPanel.class.getCanonicalName()));
Next, open Player.java, and find
Code:
public void sendDefaultPlayersOptions() {
inside that method, add this:
Code:
if (getRights() ==1 || getRights() == 2) {
getPackets().sendPlayerOption("<col=FF0000>Mod Panel</col>", 5, false);
}
Should be everything ^_^ Simple as that