package NET.worlds.console; import NET.worlds.scape.Drone; import NET.worlds.scape.HoloPilot; import NET.worlds.scape.Pilot; import NET.worlds.scape.Point3Temp; import NET.worlds.scape.TeleportAction; import NET.worlds.scape.TeleportStatus; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; public class BBTeleportCommand extends BlackBoxCommand implements TeleportStatus { private String location; public BBTeleportCommand() { this.commandType = 1; } public BBTeleportCommand(String pLocation) { this(); if (pLocation != null) { this.location = new String(pLocation); } } @Override public boolean execute() { if (this.location != null) { TeleportAction.teleport(this.location, this); } return true; } @Override public void save(DataOutputStream dos) throws IOException { super.save(dos); if (this.location == null) { dos.writeUTF(""); } else { dos.writeUTF(this.location); } } @Override public void load(DataInputStream dis) throws IOException { super.load(dis); this.location = dis.readUTF(); if (this.location.equals("")) { this.location = null; } } @Override public void teleportStatus(String err, String targetURL) { Pilot p = Pilot.getActive(); if (p instanceof HoloPilot) { HoloPilot hp = (HoloPilot)p; Drone d = hp.getInternalDrone(); if (d != null) { short dir = (short)(-p.getYaw() + 90.0F); dir = (short)(dir % 360); while (dir < 0) { dir = (short)(dir + 360); } dir = (short)(90 - dir); dir = (short)(360 - dir); Point3Temp pos = p.getPosition(); d.reset((short)pos.x, (short)pos.y, (short)p.getFootHeight(), dir); } } if (err == null) { this.doCallback(true); } else { this.doCallback(false); } } }