Advertisement
Guest User

BBSTeleportService

a guest
May 28th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1. package onemp.gameserver.service;
  2.  
  3. import java.util.HashMap;
  4. import onemp.gameserver.model.actor.instance.L2PcInstance;
  5.  
  6. /**
  7.  * @author KID
  8.  *
  9.  */
  10. public class BBSTeleportService {
  11.     private static final BBSTeleportService instance = new BBSTeleportService();
  12.     public static BBSTeleportService getInstance() {
  13.         return instance;
  14.     }
  15.  
  16.     private HashMap<Integer, TeleportEntry> teleportmap;
  17.  
  18.     public BBSTeleportService() {
  19.         this.teleportmap = new HashMap<Integer, TeleportEntry>();
  20.  
  21.         this.add(1, 1, 1, 1, 500);
  22.         this.add(2, 2, 2, 2, 600);
  23.         this.add(3, 3, 3, 3, 0);
  24.     }
  25.  
  26.     private void add(int id, int x, int y, int z, int cost) {
  27.         this.teleportmap.put(id, new TeleportEntry(x, y, z, cost));
  28.     }
  29.  
  30.     /**
  31.      * _bbteleport 1
  32.      *
  33.      * @param talker
  34.      * @param cmd
  35.      */
  36.     public void bypass(L2PcInstance talker, String cmd) {
  37.         int id;
  38.         try {
  39.             id = Integer.parseInt(cmd);
  40.         } catch (NumberFormatException e) {
  41.             talker.sendMessage("teleportmap: command parse failed");
  42.             return;
  43.         }
  44.  
  45.         TeleportEntry entry = this.teleportmap.get(id);
  46.         if (entry == null) {
  47.             talker.sendMessage("teleportmap: wrong id");
  48.             return;
  49.         }
  50.  
  51.         if (entry.cost > 0 && !talker.reduceAdena("teleportmap", entry.cost, talker, true)) {
  52.             return;
  53.         }
  54.        
  55.         talker.teleToLocation(entry.x, entry.y, entry.z);
  56.     }
  57.  
  58.     public class TeleportEntry {
  59.         public TeleportEntry(int x, int y, int z, int cost) {
  60.             this.x = x;
  61.             this.y = y;
  62.             this.z = z;
  63.             this.cost = cost;
  64.         }
  65.  
  66.         public int x, y, z, cost;
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement