root/trunk/AE-go_GameServer/src/com/aionemu/gameserver/services/TeleportService.java
| 980 | 993 | ||
|---|---|---|---|
20 | 20 | ||
21 | import com.aionemu.gameserver.dataholders.DataManager; | 21 | import com.aionemu.gameserver.dataholders.DataManager; |
22 | import com.aionemu.gameserver.model.ChatType; | 22 | import com.aionemu.gameserver.model.ChatType; |
23 | import com.aionemu.gameserver.model.gameobjects.player.Inventory; | 23 | import com.aionemu.gameserver.model.gameobjects.player.Storage; |
24 | import com.aionemu.gameserver.model.gameobjects.player.Player; | 24 | import com.aionemu.gameserver.model.gameobjects.player.Player; |
25 | import com.aionemu.gameserver.model.gameobjects.state.CreatureState; | 25 | import com.aionemu.gameserver.model.gameobjects.state.CreatureState; |
26 | import com.aionemu.gameserver.model.templates.teleport.TelelocationTemplate; | 26 | import com.aionemu.gameserver.model.templates.teleport.TelelocationTemplate; |
... | ... | ||
42 | private static final int TELEPORT_DEFAULT_DELAY = 2200; | 42 | private static final int TELEPORT_DEFAULT_DELAY = 2200; |
43 | 43 | ||
44 | private static TeleportService instance = new TeleportService(); | 44 | private static TeleportService instance = new TeleportService(); |
45 | | 45 | |
46 | /** | 46 | /** |
47 | * Schedules teleport animation | 47 | * Schedules teleport animation |
48 | * | 48 | * |
... | ... | ||
56 | { | 56 | { |
57 | activePlayer.getController().teleportTo(mapid, x, y, z, TELEPORT_DEFAULT_DELAY); | 57 | activePlayer.getController().teleportTo(mapid, x, y, z, TELEPORT_DEFAULT_DELAY); |
58 | } | 58 | } |
59 | | 59 | |
60 | // TODO injectable bean | 60 | // TODO injectable bean |
61 | public static TeleportService getInstance() | 61 | public static TeleportService getInstance() |
62 | { | 62 | { |
63 | return instance; | 63 | return instance; |
64 | } | 64 | } |
65 | | 65 | |
66 | /** | 66 | /** |
67 | * Performs flight teleportation | 67 | * Performs flight teleportation |
68 | * | 68 | * |
... | ... | ||
78 | PacketSendUtility.sendMessage(player, "Missing locId for this teleporter at teleporter_templates.xml with locId: "+locId); | 78 | PacketSendUtility.sendMessage(player, "Missing locId for this teleporter at teleporter_templates.xml with locId: "+locId); |
79 | return; | 79 | return; |
80 | } | 80 | } |
81 | | 81 | |
82 | TeleportLocation location = template.getTeleLocIdData().getTeleportLocation(locId); | 82 | TeleportLocation location = template.getTeleLocIdData().getTeleportLocation(locId); |
83 | if(location == null) | 83 | if(location == null) |
84 | { | 84 | { |
... | ... | ||
86 | PacketSendUtility.sendMessage(player, "Missing locId for this teleporter at teleporter_templates.xml with locId: "+locId); | 86 | PacketSendUtility.sendMessage(player, "Missing locId for this teleporter at teleporter_templates.xml with locId: "+locId); |
87 | return; | 87 | return; |
88 | } | 88 | } |
89 | | 89 | |
90 | TelelocationTemplate locationTemplate = DataManager.TELELOCATION_DATA.getTelelocationTemplate(locId); | 90 | TelelocationTemplate locationTemplate = DataManager.TELELOCATION_DATA.getTelelocationTemplate(locId); |
91 | if(locationTemplate == null) | 91 | if(locationTemplate == null) |
92 | { | 92 | { |
... | ... | ||
94 | PacketSendUtility.sendMessage(player, "Missing info at teleport_location.xml with locId: "+locId); | 94 | PacketSendUtility.sendMessage(player, "Missing info at teleport_location.xml with locId: "+locId); |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | | 97 | |
98 | if(!checkKinahForTransportation(location, player)) | 98 | if(!checkKinahForTransportation(location, player)) |
99 | return; | 99 | return; |
100 | player.setState(CreatureState.FLYING); | 100 | player.setState(CreatureState.FLYING); |
101 | player.unsetState(CreatureState.ACTIVE); | 101 | player.unsetState(CreatureState.ACTIVE); |
102 | PacketSendUtility.sendPacket(player, new SM_EMOTION(player, 6, location.getTeleportId(), 0)); | 102 | PacketSendUtility.sendPacket(player, new SM_EMOTION(player, 6, location.getTeleportId(), 0)); |
103 | } | 103 | } |
104 | | 104 | |
105 | /** | 105 | /** |
106 | * Performs regular teleportation | 106 | * Performs regular teleportation |
107 | * | 107 | * |
... | ... | ||
118 | PacketSendUtility.sendMessage(player, "Missing locId for this teleporter at teleporter_templates.xml with locId: "+locId); | 118 | PacketSendUtility.sendMessage(player, "Missing locId for this teleporter at teleporter_templates.xml with locId: "+locId); |
119 | return; | 119 | return; |
120 | } | 120 | } |
121 | | 121 | |
122 | TeleportLocation location = template.getTeleLocIdData().getTeleportLocation(locId); | 122 | TeleportLocation location = template.getTeleLocIdData().getTeleportLocation(locId); |
123 | if(location == null) | 123 | if(location == null) |
124 | { | 124 | { |
... | ... | ||
126 | PacketSendUtility.sendMessage(player, "Missing locId for this teleporter at teleporter_templates.xml with locId: "+locId); | 126 | PacketSendUtility.sendMessage(player, "Missing locId for this teleporter at teleporter_templates.xml with locId: "+locId); |
127 | return; | 127 | return; |
128 | } | 128 | } |
129 | | 129 | |
130 | TelelocationTemplate locationTemplate = DataManager.TELELOCATION_DATA.getTelelocationTemplate(locId); | 130 | TelelocationTemplate locationTemplate = DataManager.TELELOCATION_DATA.getTelelocationTemplate(locId); |
131 | if(locationTemplate == null) | 131 | if(locationTemplate == null) |
132 | { | 132 | { |
... | ... | ||
134 | PacketSendUtility.sendMessage(player, "Missing info at teleport_location.xml with locId: "+locId); | 134 | PacketSendUtility.sendMessage(player, "Missing info at teleport_location.xml with locId: "+locId); |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | | 137 | |
138 | if(!checkKinahForTransportation(location, player)) | 138 | if(!checkKinahForTransportation(location, player)) |
139 | return; | 139 | return; |
140 | | 140 | |
141 | PacketSendUtility.sendPacket(player, new SM_TELEPORT_LOC(locationTemplate.getMapId(), | 141 | PacketSendUtility.sendPacket(player, new SM_TELEPORT_LOC(locationTemplate.getMapId(), |
142 | locationTemplate.getX(), locationTemplate.getY(), locationTemplate.getZ())); | 142 | locationTemplate.getX(), locationTemplate.getY(), locationTemplate.getZ())); |
143 | scheduleTeleportTask(player, locationTemplate.getMapId(), | 143 | scheduleTeleportTask(player, locationTemplate.getMapId(), |
... | ... | ||
153 | */ | 153 | */ |
154 | private boolean checkKinahForTransportation(TeleportLocation location, Player player) | 154 | private boolean checkKinahForTransportation(TeleportLocation location, Player player) |
155 | { | 155 | { |
156 | Inventory inventory = player.getInventory(); | 156 | Storage inventory = player.getInventory(); |
157 | | 157 | |
158 | if (!inventory.decreaseKinah(location.getPrice())) | 158 | if (!inventory.decreaseKinah(location.getPrice())) |
159 | { | 159 | { |
160 | // TODO using the correct system message | 160 | // TODO using the correct system message |
Download diff