Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package onemp.gameserver.service;
- import java.util.HashMap;
- import onemp.gameserver.model.actor.instance.L2PcInstance;
- /**
- * @author KID
- *
- */
- public class BBSTeleportService {
- private static final BBSTeleportService instance = new BBSTeleportService();
- public static BBSTeleportService getInstance() {
- return instance;
- }
- private HashMap<Integer, TeleportEntry> teleportmap;
- public BBSTeleportService() {
- this.teleportmap = new HashMap<Integer, TeleportEntry>();
- this.add(1, 1, 1, 1, 500);
- this.add(2, 2, 2, 2, 600);
- this.add(3, 3, 3, 3, 0);
- }
- private void add(int id, int x, int y, int z, int cost) {
- this.teleportmap.put(id, new TeleportEntry(x, y, z, cost));
- }
- /**
- * _bbteleport 1
- *
- * @param talker
- * @param cmd
- */
- public void bypass(L2PcInstance talker, String cmd) {
- int id;
- try {
- id = Integer.parseInt(cmd);
- } catch (NumberFormatException e) {
- talker.sendMessage("teleportmap: command parse failed");
- return;
- }
- TeleportEntry entry = this.teleportmap.get(id);
- if (entry == null) {
- talker.sendMessage("teleportmap: wrong id");
- return;
- }
- if (entry.cost > 0 && !talker.reduceAdena("teleportmap", entry.cost, talker, true)) {
- return;
- }
- talker.teleToLocation(entry.x, entry.y, entry.z);
- }
- public class TeleportEntry {
- public TeleportEntry(int x, int y, int z, int cost) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.cost = cost;
- }
- public int x, y, z, cost;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement