Code:
package server.model.players.content;
import server.Config;
import server.model.players.Client;
import server.model.players.*;
import server.util.Misc;
public class Teleports {
private static final int
BLOOD = 565,
SOUL = 566,
LAW = 563,
FIRE = 554,
WATER = 555,
AIR = 556,
EARTH = 557,
BANANA = 1963;
//(button, x, y, h , req, exp, rune 1, rune 1 amount, rune 2, rune 2 amount, rune 3, rune 3 amount, rune 4, rune 5 amount, item 1, item 1 amount, type)
public static enum teleportData {
/* Moderns */
MODERNHOME(4161, Config.RESPAWN_X, Config.RESPAWN_Y, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, "modern"),
VARROCK(4140, Config.VARROCK_X, Config.VARROCK_Y, 0, 25, 35, AIR, 3, FIRE, 1, LAW, 1, -1, 0, -1, 0, "modern"),
LUMBRIDGE(4143, Config.LUMBRIDGE_X, Config.LUMBRIDGE_Y, 0, 31, 41, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "modern"),
FALADOR(4146, Config.FALADOR_X, Config.FALADOR_Y, 0, 37, 48, AIR, 3, WATER, 1, LAW, 1, -1, 0, -1, 0, "modern"),
CAMELOT(4150, Config.CAMELOT_X, Config.CAMELOT_Y, 0, 45, 56, AIR, 5, LAW, 1, -1, 0, -1, 0, -1, 0, "modern"),
ARDOUGNE(6004, Config.ARDOUGNE_X, Config.ARDOUGNE_Y, 0, 51, 61, LAW, 2, WATER, 2, -1, 0, -1, 0, -1, 0, "modern"),
WATCHTOWER(6005, Config.WATCHTOWER_X, Config.WATCHTOWER_Y, 0, 58, 68, LAW, 2, EARTH, 2, -1, 0, -1, 0, -1, 0, "modern"),
TROLLHEIM(29031, Config.TROLLHEIM_X, Config.TROLLHEIM_Y, 0, 61, 68, LAW, 2, FIRE, 2, -1, 0, -1, 0, -1, 0, "modern"),
APEATOLL(72038, Config.APEATOLL_X, Config.APEATOLL_Y, 0, 64, 76, FIRE, 2, WATER, 2, LAW, 2, -1, 0, BANANA, 1, "modern"),
/* Ancients */
ANCIENTHOME(50056 , Config.RESPAWN_X, Config.RESPAWN_Y, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, "ancient"),
PADDEWWA(50235, Config.PADDEWWA_X, Config.PADDEWWA_Y, 0, 31, 64, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
SENNTISTEN(50245, Config.SENNTISTEN_X, Config.SENNTISTEN_Y, 0, 31, 70, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
KHARYLL(50253, Config.KHARYLL_X, Config.KHARYLL_Y, 0, 31, 76, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
LASSAR(51005, Config.LASSAR_X, Config.LASSAR_Y, 0, 31, 82, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
DAREEYAK(51013, Config.DAREEYAK_X, Config.DAREEYAK_Y, 0, 31, 88, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
CARRALLANGAR(51023, Config.CARRALLANGAR_X, Config.CARRALLANGAR_Y, 0, 31, 94, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
ANNAKARL(51031, Config.ANNAKARL_X, Config.ANNAKARL_Y, 0, 31, 100, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient"),
GHORROCK(51039, Config.GHORROCK_X, Config.GHORROCK_Y, 0, 31, 106, AIR, 3, EARTH, 1, LAW, 1, -1, 0, -1, 0, "ancient");
private int button, x, y, h, req, exp, rune1, amount1, rune2, amount2, rune3, amount3, rune4, amount4, item, amount5;
private String type;
private teleportData(final int button, final int x, final int y, final int h, final int req, final int exp, final int rune1, final int amount1, final int rune2, final int amount2, final int rune3, final int amount3, final int rune4, final int amount4, final int item, final int amount5, final String type) {
this.button = button;
this.x = x;
this.y = y;
this.h = h;
this.req = req;
this.exp = exp;
this.rune1 = rune1;
this.amount1 = amount1;
this.rune2 = rune2;
this.amount2 = amount2;
this.rune3 = rune3;
this.amount3 = amount3;
this.rune4 = rune4;
this.amount4 = amount4;
this.item = item;
this.amount5 = amount5;
this.type = type;
}
public int getButton() {
return button;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getH() {
return h;
}
public int getReq() {
return req;
}
public int getExp() {
return exp;
}
public int getR1() {
return rune1;
}
public int getA1() {
return amount1;
}
public int getR2() {
return rune2;
}
public int getA2() {
return amount2;
}
public int getR3() {
return rune3;
}
public int getA3() {
return amount3;
}
public int getR4() {
return rune4;
}
public int getA4() {
return amount4;
}
public int getItem() {
return item;
}
public int getA5() {
return amount5;
}
public String getType() {
return type;
}
}
public static boolean isTeleport() {
for(final teleportData t : teleportData.values()) {
if(t.getType().equals("ancient") || t.getType().equals("modern") || t.getType().equals("lunar")) {
return true;
}
}
return false;
}
public static void handleTeleport(Client c, int actionButtonId, boolean runesReq) {
for(final teleportData t : teleportData.values()) {
if(t.getReq() > 0) {
if(t.getX() > 0 && t.getY() > 0 && t.getH() >= 0) {
if(c.playerLevel[6] > t.getReq()) {
if(playerHasItem(c, t.getR1(), t.getA1())) { //Need it to check for all runes and see if the need a rune
} else {
c.sM("You do not have the required runes and or items to cast this spell.");
return;
}
} else {
c.sM("You do not have the required magic level to cast this spell.");
return;
}
startTeleport(c, t.getX()+Misc.random(2), t.getY()+Misc.random(2), t.getH(), t.getType());
}
}
}
}
private static boolean playerHasItem(Client c, int itemID, final int amt) {
itemID++;
int found = 0;
for (int i = 0; i < c.playerItems.length; i++) {
if (c.playerItems[i] == itemID) {
if(c.playerItemsN[i] >= amt){
return true;
} else{
found++;
}
}
}
if(found >= amt) {
return true;
}
return false;
}
private static int getItemSlot(Client c, final int ItemID) {
for (int i = 0; i < c.playerItems.length; i++) {
if(c.playerItems[i] - 1 == ItemID){
return i;
}
}
return -1;
}
public static void startTeleport(Client c, int x, int y, int height, String teleportType) {
if(c.duelStatus == 5) { c.sM("You can't teleport during a duel!"); return; }
if(c.inWild() && c.wildLevel > Config.NO_TELEPORT_WILD_LEVEL) {
c.sM("You can't teleport above level "+Config.NO_TELEPORT_WILD_LEVEL+" in the wilderness."); return; }
if(System.currentTimeMillis() - c.teleBlockDelay < c.teleBlockLength) { c.sM("You are teleblocked and can't teleport."); return; }
if(!c.isDead && c.teleTimer == 0 && c.respawnTimer == -6) {
if (c.playerIndex > 0 || c.npcIndex > 0)
c.getCombat().resetPlayerAttack();
c.stopMovement();
c.getPA().removeAllWindows();
c.teleX = x;
c.teleY = y;
c.updateWalkEntities();
c.npcIndex = 0;
c.playerIndex = 0;
c.faceUpdate(0);
c.teleHeight = height;
if(teleportType.equalsIgnoreCase("modern")) {
c.startAnimation(8939);
c.teleTimer = 9;
c.gfx0(1576);
c.teleEndAnimation = 8941;
}
if(teleportType.equalsIgnoreCase("ancient")) {
c.startAnimation(9599);
c.teleGfx = 0;
c.teleTimer = 11;
c.teleEndAnimation = 8941;
c.gfx0(1681);
}
if (teleportType.equalsIgnoreCase("lunar")) {
c.startAnimation(9606);
c.teleGfx = 0;
c.teleTimer = 13;
c.teleEndAnimation = 9013;
c.gfx0(1685);
}
if (teleportType.equalsIgnoreCase("ring")) {
c.startAnimation(9603);
c.teleGfx = 0;
c.teleTimer = 11;
c.gfx0(1684);
}
if (teleportType.equalsIgnoreCase("teletab")) {
c.startAnimation(9597);
c.teleGfx = 0;
c.teleTimer = 6;
c.teleEndAnimation = 9598;
c.gfx0(1680);
}
}
}
}
I need to add checking for runes and removing of them. As well as adding of xp. In the enum a value of -1 is supposed to be no rune req. How do I check all of them and delete them as required. Also I tested it without the rune req's or anything and it just kept teleporting me to the same place.(Guessing I missed an if statement for a value. Not sure.) Hopefully we can get this done because It's already a really nice system I just need to get everything working.