Vhince
October 9th, 2010, 21:59
Thought i'd convert Shamon's teleporting system for Hyperion for wL
import com.rs2.model.player.Client;
import java.util.HashMap;
import java.util.Map;
public class ActionTeleports {
public enum Teleports {
TEST(29031, 3200, 3200);
//
private int x;
private int y;
private int z;
private int button;
private Teleports(int button, int x, int y) {
this.button = button;
this.x = x;
this.y = y;
}
public int getButton() {
return button;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZ() {
return z;
}
}
private static Map<Integer, Teleports> actionButton = new HashMap<Integer, Teleports>();
public static Teleports forId(int object) {
return actionButton.get(object);
}
static {
for (Teleports teles : Teleports.values()) {
actionButton.put(teles.getButton(), teles);
}
}
public static void teleport(final Client player, final int button) {
if (forId(button) == null) {
return;
}
player.teleportToX = forId(button).getX();
player.teleportToY = forId(button).getY();
}
}
ClickingButtons/ActionButton packet
ActionTeleports.teleport(client, actionButtonId);
Now you don't need to be adding all these JUNK case switches like
case 1:
VarrockTele
some stuff like that.
Simply just do this to add more TelePorts.
Example
LUMBRIDGE(29031, 3200, 3200);
29031 - ActionButton ID
3200, 3200 - X and Y Coordinates
import com.rs2.model.player.Client;
import java.util.HashMap;
import java.util.Map;
public class ActionTeleports {
public enum Teleports {
TEST(29031, 3200, 3200);
//
private int x;
private int y;
private int z;
private int button;
private Teleports(int button, int x, int y) {
this.button = button;
this.x = x;
this.y = y;
}
public int getButton() {
return button;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZ() {
return z;
}
}
private static Map<Integer, Teleports> actionButton = new HashMap<Integer, Teleports>();
public static Teleports forId(int object) {
return actionButton.get(object);
}
static {
for (Teleports teles : Teleports.values()) {
actionButton.put(teles.getButton(), teles);
}
}
public static void teleport(final Client player, final int button) {
if (forId(button) == null) {
return;
}
player.teleportToX = forId(button).getX();
player.teleportToY = forId(button).getY();
}
}
ClickingButtons/ActionButton packet
ActionTeleports.teleport(client, actionButtonId);
Now you don't need to be adding all these JUNK case switches like
case 1:
VarrockTele
some stuff like that.
Simply just do this to add more TelePorts.
Example
LUMBRIDGE(29031, 3200, 3200);
29031 - ActionButton ID
3200, 3200 - X and Y Coordinates