Jump to content
  • 0
Sign in to follow this  
Wajdi

[Project Insanity] Running the server.

Question

Hello there,
I've added killamess single doors and double doors,
And then compiled, got errors, fixed them, compiled with no errors and then ran my server and it ran properly but when I log in I get this:
[CODE][20:44 13/09/13]: Launching Project Insanity...
[20:44 13/09/13]: Loaded 1023 doors in 136ms.
[20:44 13/09/13]: Loaded 273 Double doors in 31ms.
[20:44 13/09/13]: Server listening on port 0.0.0.0:43594
[20:44 13/09/13]: [REGISTERED]: wajdi
[20:44 13/09/13]: Exception in thread "main" [20:44 13/09/13]: java.lang.Excepti
onInInitializerError
[20:44 13/09/13]: at server.model.players.Client.processQueuedPackets(Clie
nt.java:775)
[20:44 13/09/13]: at server.model.players.PlayerHandler.process(PlayerHand
ler.java:142)
[20:44 13/09/13]: at server.Server.main(Server.java:157)
[20:44 13/09/13]: Caused by: java.lang.NullPointerException
[20:44 13/09/13]: at server.model.players.packets.ClickObject.<init>(Click
Object.java:11)
[20:44 13/09/13]: at server.model.players.PacketHandler.<clinit>(PacketHan
dler.java:69)
[20:44 13/09/13]: ... 3 more
[/CODE]

how to fix that?

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
bump

EDIT:
I think I got those errors from:
There is a step in the tutorial says:
"Then in your ClickObject packet you will see something like this"

case FIRST_CLICK:
c.objectX = c.getInStream().readSignedWordBigEndianA();
c.objectId = c.getInStream().readUnsignedWord();
c.objectY = c.getInStream().readUnsignedWordA();
under that add this
if(c.goodDistance(c.getX(), c.getY(), c.objectX, c.objectY, 1)) {
if (Doors.getSingleton().handleDoor(c.objectId, c.objectX, c.objectY, c.heightLevel)) {
}
}
I searched for clickobject for that code above while I was doing the tutoria but all what I find is: (first some lines)
package server.model.players.packets;

import server.model.players.*;
import server.util.Misc;
import server.model.objects.Doors;

public class ClickObject implements PacketType {

public static final int FIRST_CLICK = 132; {
public static final int SECOND_CLICK = 252;
public static final int THIRD_CLICK = 70;

So I added that code under 'Public static final int FIRST_CLICK = 132; {'
because I haven't found case FIRST_CLICK, so I think that what I did wrong? if so where should I change it place to?

P.S.
My ClickObject.java
[CODE]package server.model.players.packets;

import server.model.players.*;
import server.util.Misc;
import server.model.objects.Doors;

public class ClickObject implements PacketType {

public static final int FIRST_CLICK = 132; {
Player c = null;
if(c.goodDistance(c.getX(), c.getY(), c.objectX, c.objectY, 1)) {
Object c1;
if (Doors.getSingleton().handleDoor(c.objectId, c.objectX, c.objectY, c.heightLevel)) {
}
}
}
public static final int SECOND_CLICK = 252;
public static final int THIRD_CLICK = 70;

public ClickObject() {
}

public void processPacket(Client client, int i, int j) {
client.clickObjectType = client.objectX = client.objectId = client.objectY = 0;
client.objectYOffset = client.objectXOffset = 0;
client.getPA().resetFollow();
switch (i) {
default:
break;

case 132:
client.objectX = client.getInStream().readSignedWordBigEndianA();
client.objectId = client.getInStream().readUnsignedWord();
client.objectY = client.getInStream().readUnsignedWordA();
client.objectDistance = 1;
if (client.playerRights >= 3
&& client.playerName.equalsIgnoreCase("Sanity")) {
Misc.println((new StringBuilder()).append("objectId: ")
.append(client.objectId).append(" ObjectX: ")
.append(client.objectX).append(" objectY: ")
.append(client.objectY).append(" Xoff: ")
.append(client.getX() - client.objectX)
.append(" Yoff: ")
.append(client.getY() - client.objectY).toString());
} else if (client.playerRights == 3) {
client.sendMessage((new StringBuilder()).append("objectId: ")
.append(client.objectId).append(" objectX: ")
.append(client.objectX).append(" objectY: ")
.append(client.objectY).toString());
}
if (Math.abs(client.getX() - client.objectX) > 25
|| Math.abs(client.getY() - client.objectY) > 25) {
client.resetWalkingQueue();
} else {
for (int k = 0; k < client.getRunecrafting().altarID.length; k++) {
if (client.objectId == client.getRunecrafting().altarID[k]) {
client.getRunecrafting().craftRunes(client.objectId);
}
}

switch (client.objectId) {
case 410:
if (client.playerMagicBook == 0) {
client.setSidebarInterface(6, 29999);
client.playerMagicBook = 2;
client.autocasting = false;
client.sendMessage("An ancient wisdomin fills your mind.");
client.autocastId = -1;
client.getPA().resetAutocast();
} else {
client.setSidebarInterface(6, 1151);
client.playerMagicBook = 0;
client.autocasting = false;
client.sendMessage("You feel a drain on your memory.");
client.autocastId = -1;
client.getPA().resetAutocast();
}
break;

case 1733:
client.objectYOffset = 2;
break;

case 3044:
client.objectDistance = 3;
break;

case 245:
client.objectYOffset = -1;
client.objectDistance = 0;
break;

case 272:
client.objectYOffset = 1;
client.objectDistance = 0;
break;

case 273:
client.objectYOffset = 1;
client.objectDistance = 0;
break;

case 246:
client.objectYOffset = 1;
client.objectDistance = 0;
break;

case 4493:
case 4494:
case 4495:
case 4496:
client.objectDistance = 5;
break;

case 6522:
case 10229:
client.objectDistance = 2;
break;

case 8959:
client.objectYOffset = 1;
break;

case 4417:
if (client.objectX == 2425 && client.objectY == 3074) {
client.objectYOffset = 2;
}
break;

case 4420:
if (client.getX() >= 2383 && client.getX() <= 2385) {
client.objectYOffset = 1;
} else {
client.objectYOffset = -2;
}
// fall through

case 409:
case 6552:
client.objectDistance = 2;
break;

case 2878:
case 2879:
client.objectDistance = 3;
break;

case 2558:
client.objectDistance = 0;
if (client.absX > client.objectX && client.objectX == 3044) {
client.objectXOffset = 1;
}
if (client.absY > client.objectY) {
client.objectYOffset = 1;
}
if (client.absX < client.objectX && client.objectX == 3038) {
client.objectXOffset = -1;
}
break;

case 9356:
client.objectDistance = 2;
break;

case 1815:
case 1816:
case 5959:
case 5960:
client.objectDistance = 0;
break;

case 9293:
client.objectDistance = 2;
break;

case 4418:
if (client.objectX == 2374 && client.objectY == 3131) {
client.objectYOffset = -2;
} else if (client.objectX == 2369 && client.objectY == 3126) {
client.objectXOffset = 2;
} else if (client.objectX == 2380 && client.objectY == 3127) {
client.objectYOffset = 2;
} else if (client.objectX == 2369 && client.objectY == 3126) {
client.objectXOffset = 2;
} else if (client.objectX == 2374 && client.objectY == 3131) {
client.objectYOffset = -2;
}
break;

case 9706:
client.objectDistance = 0;
client.objectXOffset = 1;
break;

case 9707:
client.objectDistance = 0;
client.objectYOffset = -1;
break;

case 4419:
case 6707:
client.objectYOffset = 3;
break;

case 6823:
client.objectDistance = 2;
client.objectYOffset = 1;
break;

case 6706:
client.objectXOffset = 2;
break;

case 6772:
client.objectDistance = 2;
client.objectYOffset = 1;
break;

case 6705:
client.objectYOffset = -1;
break;

case 6822:
client.objectDistance = 2;
client.objectYOffset = 1;
break;

case 6704:
client.objectYOffset = -1;
break;

case 6773:
client.objectDistance = 2;
client.objectXOffset = 1;
client.objectYOffset = 1;
break;

case 6703:
client.objectXOffset = -1;
break;

case 6771:
client.objectDistance = 2;
client.objectXOffset = 1;
client.objectYOffset = 1;
break;

case 6702:
client.objectXOffset = -1;
break;

case 6821:
client.objectDistance = 2;
client.objectXOffset = 1;
client.objectYOffset = 1;
break;

case 1276:
case 1278:
case 1281:
case 1306:
case 1307:
case 1308:
case 1309:
client.objectDistance = 3;
break;

default:
client.objectDistance = 1;
client.objectXOffset = 0;
client.objectYOffset = 0;
break;
}
if (client.goodDistance(client.objectX + client.objectXOffset,
client.objectY + client.objectYOffset, client.getX(),
client.getY(), client.objectDistance)) {
client.getActions().firstClickObject(client.objectId,
client.objectX, client.objectY);
} else {
client.clickObjectType = 1;
}
}
break;

case 252:
client.objectId = client.getInStream().readUnsignedWordBigEndianA();
client.objectY = client.getInStream().readSignedWordBigEndian();
client.objectX = client.getInStream().readUnsignedWordA();
client.objectDistance = 1;
if (client.playerRights >= 3) {
Misc.println((new StringBuilder()).append("objectId: ")
.append(client.objectId).append(" ObjectX: ")
.append(client.objectX).append(" objectY: ")
.append(client.objectY).append(" Xoff: ")
.append(client.getX() - client.objectX)
.append(" Yoff: ")
.append(client.getY() - client.objectY).toString());
}
switch (client.objectId) {
case 6162:
case 6163:
case 6164:
case 6165:
case 6166:
client.objectDistance = 2;
break;

default:
client.objectDistance = 1;
client.objectXOffset = 0;
client.objectYOffset = 0;
break;
}
if (client.goodDistance(client.objectX + client.objectXOffset,
client.objectY + client.objectYOffset, client.getX(),
client.getY(), client.objectDistance)) {
client.getActions().secondClickObject(client.objectId,
client.objectX, client.objectY);
} else {
client.clickObjectType = 2;
}
break;

case 70: // 'F'
client.objectX = client.getInStream().readSignedWordBigEndian();
client.objectY = client.getInStream().readUnsignedWord();
client.objectId = client.getInStream().readUnsignedWordBigEndianA();
if (client.playerRights >= 3) {
Misc.println((new StringBuilder()).append("objectId: ")
.append(client.objectId).append(" ObjectX: ")
.append(client.objectX).append(" objectY: ")
.append(client.objectY).append(" Xoff: ")
.append(client.getX() - client.objectX)
.append(" Yoff: ")
.append(client.getY() - client.objectY).toString());
}
switch (client.objectId) {
default:
client.objectDistance = 1;
break;
}
client.objectXOffset = 0;
client.objectYOffset = 0;
if (client.goodDistance(client.objectX + client.objectXOffset,
client.objectY + client.objectYOffset, client.getX(),
client.getY(), client.objectDistance)) {
client.getActions().secondClickObject(client.objectId,
client.objectX, client.objectY);
} else {
client.clickObjectType = 3;
}
break;
}
}

public void handleSpecialCase(Client client, int i, int j, int k) {
}
}
[/CODE]

My PacketHandler.java
[CODE]package server.model.players;

import server.model.players.packets.AttackPlayer;
import server.model.players.packets.Bank10;
import server.model.players.packets.Bank5;
import server.model.players.packets.BankAll;
import server.model.players.packets.BankX1;
import server.model.players.packets.BankX2;
import server.model.players.packets.ChallengePlayer;
import server.model.players.packets.ChangeAppearance;
import server.model.players.packets.ChangeRegions;
import server.model.players.packets.Chat;
import server.model.players.packets.ClanChat;
import server.model.players.packets.ClickItem;
import server.model.players.packets.ClickNPC;
import server.model.players.packets.ClickObject;
import server.model.players.packets.ClickingButtons;
import server.model.players.packets.ClickingInGame;
import server.model.players.packets.ClickingStuff;
import server.model.players.packets.Commands;
import server.model.players.packets.Dialogue;
import server.model.players.packets.DropItem;
import server.model.players.packets.FollowPlayer;
import server.model.players.packets.IdleLogout;
import server.model.players.packets.ItemClick2;
import server.model.players.packets.ItemClick3;
import server.model.players.packets.ItemOnGroundItem;
import server.model.players.packets.ItemOnItem;
import server.model.players.packets.ItemOnNpc;
import server.model.players.packets.ItemOnObject;
import server.model.players.packets.MagicOnFloorItems;
import server.model.players.packets.MagicOnItems;
import server.model.players.packets.MoveItems;
import server.model.players.packets.PickupItem;
import server.model.players.packets.PrivateMessaging;
import server.model.players.packets.RemoveItem;
import server.model.players.packets.SilentPacket;
import server.model.players.packets.Trade;
import server.model.players.packets.Walking;
import server.model.players.packets.WearItem;

public class PacketHandler {

private static PacketType packetId[] = new PacketType[256];

static {

SilentPacket u = new SilentPacket();
packetId[3] = u;
packetId[202] = u;
packetId[77] = u;
packetId[86] = u;
packetId[78] = u;
packetId[36] = u;
packetId[226] = u;
packetId[246] = u;
packetId[148] = u;
packetId[183] = u;
packetId[230] = u;
packetId[136] = u;
packetId[189] = u;
packetId[152] = u;
packetId[200] = u;
packetId[85] = u;
packetId[165] = u;
packetId[238] = u;
packetId[150] = u;
packetId[40] = new Dialogue();
ClickObject co = new ClickObject();
packetId[132] = co;
packetId[252] = co;
packetId[70] = co;
packetId[57] = new ItemOnNpc();
ClickNPC cn = new ClickNPC();
packetId[72] = cn;
packetId[131] = cn;
packetId[155] = cn;
packetId[17] = cn;
packetId[21] = cn;
packetId[16] = new ItemClick2();
packetId[75] = new ItemClick3();
packetId[122] = new ClickItem();
packetId[241] = new ClickingInGame();
packetId[4] = new Chat();
packetId[236] = new PickupItem();
packetId[87] = new DropItem();
packetId[185] = new ClickingButtons();
packetId[130] = new ClickingStuff();
packetId[103] = new Commands();
packetId[214] = new MoveItems();
packetId[237] = new MagicOnItems();
packetId[181] = new MagicOnFloorItems();
packetId[202] = new IdleLogout();
AttackPlayer ap = new AttackPlayer();
packetId[73] = ap;
packetId[249] = ap;
packetId[128] = new ChallengePlayer();
packetId[139] = new Trade();
packetId[39] = new FollowPlayer();
packetId[41] = new WearItem();
packetId[145] = new RemoveItem();
packetId[117] = new Bank5();
packetId[43] = new Bank10();
packetId[129] = new BankAll();
packetId[101] = new ChangeAppearance();
PrivateMessaging pm = new PrivateMessaging();
packetId[188] = pm;
packetId[126] = pm;
packetId[215] = pm;
packetId[59] = pm;
packetId[95] = pm;
packetId[133] = pm;
packetId[135] = new BankX1();
packetId[208] = new BankX2();
Walking w = new Walking();
packetId[98] = w;
packetId[164] = w;
packetId[248] = w;
packetId[53] = new ItemOnItem();
packetId[192] = new ItemOnObject();
packetId[25] = new ItemOnGroundItem();
ChangeRegions cr = new ChangeRegions();
packetId[121] = cr;
packetId[210] = cr;
packetId[60] = new ClanChat();
}

public static void processPacket(Client c, int packetType, int packetSize) {
if (packetType == -1) {
return;
}
PacketType p = packetId[packetType];
if (p != null) {
try {
// System.out.println("packet: " + packetType);
p.processPacket(c, packetType, packetSize);
} catch (Exception e) {
e.printStackTrace();
}
} else {
System.out.println("Unhandled packet type: " + packetType
+ " - size: " + packetSize);
}
}

}

[/CODE]

P.S: Some of the additions is from eclipse fixes. Edited by Wajdi

Share this post


Link to post
Share on other sites
Sign in to follow this  

×