Make a class called DiggingHandler, put this in it (NOTE: Uses Graham's event manager):
In server.java addCode:/**
* Digging Handler
* Made by Filth
* WHERE ARE YOUR CONVENTIONS NOW!?
**/
public class DiggingHandler {
public int absX = -1;
public int absY = -1;
public int playerId = -1;
public int weapon = -1;
public int catche = 0;
public int emoteTime = 490;
public int actionTimer = 0;
public void dig(int player) {
final client c = (client) server.playerHandler.players[player];
playerId = c.playerId;
absX = c.absX;
absY = c.absY;
if (actionTimer == 0) {
actionTimer = 3;
if (c.playerEquipment[c.playerWeapon] != 952) {
weapon = c.playerEquipment[c.playerWeapon];
}
c.updateRequired = true;
c.appearanceUpdateRequired = true;
c.playerEquipment[c.playerWeapon] = 952;
animation(831);
c.updateRequired = true;
c.appearanceUpdateRequired = true;
/* Reset Weapon */
EventManager.getSingleton().addEvent(new Event() {
public void execute(EventContainer x) {
c.playerEquipment[c.playerWeapon] = weapon;
if (actionTimer > 0) {
actionTimer--;
} else {
x.stop();
}
}
}, emoteTime);
c.updateRequired = true;
c.appearanceUpdateRequired = true;
/* Add digging things here */
if (absX == 5000 && absY == 5000) {
c.sendMessage("ROW ROW FITE DA POWA");
}
if (area(2607, 3098, 2605, 3096)) {
c.sendMessage("LOL NICE! DIS ARE TEST");
} else if (area(5000, 5000, 2000, 2000)) {
c.sendMessage("U DID IT AGAIN WTF");
} else {
c.sendMessage("Nothing interesting happens.");
}
}
}
public boolean area(int X, int Y, int X2, int Y2) {
client c = (client) server.playerHandler.players[playerId];
if (c.absX <= X && c.absY <= Y && c.absX >= X2 && c.absY >= Y2) {
return true;
} else {
return false;
}
}
public void animation(int emote) {
client c = (client) server.playerHandler.players[playerId];
c.pEmote = emote;
c.updateRequired = true;
c.appearanceUpdateRequired = true;
c.animationReset = System.currentTimeMillis() + emoteTime;
}
}
and in main methodCode:public static DiggingHandler DiggingHandler = null;
In client.java inside of case 122 put:Code:DiggingHandler = new DiggingHandler();
Nao ur gun dig. BTW u mite want to make weapon save incase teh person r disconnect, so when tey log in and tey r has dig, giv tem tere weponCode:if (ItemID == 952) { // Spade
server.DiggingHandler.dig(playerId);
} else {
if (System.currentTimeMillis() - lastAction >= 850) {
buryItem(ItemID, ItemSlot);
lastAction = System.currentTimeMillis();
actionTimer = 10;
}
}
Why make a handler? Because I hate adding stuff to client.java :| That's all.