Nothing special could be cleaned up and minimized without a doubt, may come in handy for someone.
Code:
package server.model.minigames;
import server.Server;
import server.model.players.Client;
import server.util.Misc;
import server.model.players.*;
public class ForresterEvent {
public static void startEvent(Client c) {
c.stopMovement();
c.lastX = c.absX;
c.lastY = c.absY;
if (System.currentTimeMillis() - c.lastButton < 1000) {
c.lastButton = System.currentTimeMillis();
return;
} else
c.lastButton = System.currentTimeMillis();
c.getPA().removeAllWindows();
ForresterEvent.teleportPlayer(c);
return;
}
public static void teleportPlayer(Client c) {
c.stopMovement();
c.getPA().startTeleport(2597, 4779, 0, "modern");
c.inForrestEvent = true;
ForresterEvent.sendDialogue(c, 1);
return;
}
public static void hasMeat(Client c) {
c.getItems().deleteItem(6178, 1);
ForresterEvent.sendDialogue(c, 3);
c.givenMeat = true;
return;
}
public static void givenMeat(Client c) {
ForresterEvent.sendDialogue(c, 3);
return;
}
public static void noMeat(Client c) {
ForresterEvent.sendDialogue(c, 2);
return;
}
public static void leaveEvent(Client c) {
if(c.givenMeat == true) {
ForresterEvent.giveReward(c);
c.getPA().startTeleport(c.lastX, c.lastY, 0, "modern");
}else if(c.givenMeat == false) {
ForresterEvent.sendDialogue(c, 4);
return;
}
}
public static void giveReward(Client c) {
c.givenMeat = false;
c.inForrestEvent = false;
ForresterEvent.sendDialogue(c, 4);
if (c.getItems().freeSlots() < 1) {
c.sendMessage("You don't have enough inventory space to collect the reward.");
return;
}
c.getItems().addItem(6183, 1);
return;
}
public static void logOut(Client c) {
c.getPA().movePlayer(2864, 5354, 2);
return;
}
public static void sendDialogue(Client c, int dialogueId) {
switch (dialogueId) {
case 1:
c.getDH().sendNpcChat4("Welcome to 8thgen's anti Macro event.",
"To exit the event, you must complete my task.",
"I need one raw Pheasant meat. Kill one and come and talk to",
"Me to leave this event.",
2458,
"Freaky Forester");
break;
case 2:
c.getDH().sendNpcChat1("Please get me one raw Pheasant meat.",
2458,
"Freaky Forester");
break;
case 3:
c.getDH().sendNpcChat2("Thanks for that, " + c.playerName +".",
"You may now leave the event in the portal over there.",
2458,
"Freaky Forester");
break;
case 4:
c.getDH().sendNpcChat1("Hey, talk to me before leaving.",
2458,
"Freaky Forester");
break;
case 5:
c.getDH().sendNpcChat1("Take this reward for finishing the event.",
2458,
"Freaky Forester");
break;
}
}
}