Guest User

Untitled

a guest
Jun 13th, 2010
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.35 KB | None | 0 0
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.edelvez.gameserver.network.clientpackets;
  16.  
  17. import java.util.logging.Level;
  18. import java.util.logging.Logger;
  19.  
  20. import com.edelvez.Config;
  21. import com.edelvez.gameserver.ai.CtrlIntention;
  22. import com.edelvez.gameserver.communitybbs.CommunityBoard;
  23. import com.edelvez.gameserver.handler.AdminCommandHandler;
  24. import com.edelvez.gameserver.handler.IAdminCommandHandler;
  25. import com.edelvez.gameserver.model.L2CharPosition;
  26. import com.edelvez.gameserver.model.L2Object;
  27. import com.edelvez.gameserver.model.L2World;
  28. import com.edelvez.gameserver.model.actor.instance.L2ClassMasterInstance;
  29. import com.edelvez.gameserver.model.actor.instance.L2NpcInstance;
  30. import com.edelvez.gameserver.model.actor.instance.L2PcInstance;
  31. import com.edelvez.gameserver.model.entity.L2Event;
  32. import com.edelvez.gameserver.model.entity.L2JEdelvezEvents.CTF;
  33. import com.edelvez.gameserver.model.entity.L2JEdelvezEvents.DM;
  34. import com.edelvez.gameserver.model.entity.L2JEdelvezEvents.FortressSiege;
  35. import com.edelvez.gameserver.model.entity.L2JEdelvezEvents.TvT;
  36. import com.edelvez.gameserver.network.serverpackets.ActionFailed;
  37. import com.edelvez.gameserver.network.serverpackets.NpcHtmlMessage;
  38.  
  39. /**
  40. * This class ...
  41. *
  42. * @version $Revision: 1.12.4.5 $ $Date: 2005/04/11 10:06:11 $
  43. */
  44. public final class RequestBypassToServer extends L2GameClientPacket
  45. {
  46. private static final String _C__21_REQUESTBYPASSTOSERVER = "[C] 21 RequestBypassToServer";
  47. private static Logger _log = Logger.getLogger(RequestBypassToServer.class.getName());
  48. // S
  49. private String _command;
  50.  
  51. /**
  52. * @param decrypt
  53. */
  54. @Override
  55. protected void readImpl()
  56. {
  57. _command = readS();
  58. }
  59.  
  60. @Override
  61. protected void runImpl()
  62. {
  63. L2PcInstance activeChar = getClient().getActiveChar();
  64. if (!activeChar.getFloodProtectors().getServerBypass().tryPerformAction("_command"))
  65. {
  66. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  67. return;
  68. }
  69. if (activeChar == null)
  70. {
  71. return;
  72. }
  73. try
  74. {
  75. if (_command.startsWith("admin_")) // &&
  76. // activeChar.getAccessLevel()
  77. // >= Config.GM_ACCESSLEVEL)
  78. {
  79. if (Config.ALT_PRIVILEGES_ADMIN && !AdminCommandHandler.getInstance().checkPrivileges(activeChar, _command))
  80. {
  81. _log.info("<GM>" + activeChar + " does not have sufficient privileges for command '" + _command + "'.");
  82. return;
  83. }
  84. IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler(_command);
  85. if (ach != null)
  86. {
  87. ach.useAdminCommand(_command, activeChar);
  88. }
  89. else
  90. {
  91. _log.warning("No handler registered for bypass '" + _command + "'");
  92. }
  93. }
  94. else if (_command.equals("come_here") && activeChar.getAccessLevel() >= Config.GM_ACCESSLEVEL)
  95. {
  96. comeHere(activeChar);
  97. }
  98. else if (_command.startsWith("player_help "))
  99. {
  100. playerHelp(activeChar, _command.substring(12));
  101. }
  102. else if (_command.startsWith("npc_"))
  103. {
  104. if (!activeChar.validateBypass(_command))
  105. {
  106. return;
  107. }
  108. int endOfId = _command.indexOf('_', 5);
  109. String id;
  110. if (endOfId > 0)
  111. {
  112. id = _command.substring(4, endOfId);
  113. }
  114. else
  115. {
  116. id = _command.substring(4);
  117. }
  118. try
  119. {
  120. L2Object object = L2World.getInstance().findObject(Integer.parseInt(id));
  121. if (_command.substring(endOfId + 1).startsWith("event_participate"))
  122. {
  123. L2Event.inscribePlayer(activeChar);
  124. }
  125. else if (_command.substring(endOfId + 1).startsWith("tvt_player_join "))
  126. {
  127. String teamName = _command.substring(endOfId + 1).substring(16);
  128. if (TvT._joining) {
  129. TvT.addPlayer(activeChar, teamName);
  130. } else {
  131. activeChar.sendMessage("The event is already started. You can not join now!");
  132. }
  133. }
  134. else if (_command.substring(endOfId + 1).startsWith("tvt_player_leave"))
  135. {
  136. if (TvT._joining) {
  137. TvT.removePlayer(activeChar);
  138. } else {
  139. activeChar.sendMessage("The event is already started. You can not leave now!");
  140. }
  141. }
  142. else if (_command.substring(endOfId + 1).startsWith("dmevent_player_join"))
  143. {
  144. if (DM._joining) {
  145. DM.addPlayer(activeChar);
  146. } else {
  147. activeChar.sendMessage("The event is already started. You can not join now!");
  148. }
  149. }
  150. else if (_command.substring(endOfId + 1).startsWith("dmevent_player_leave"))
  151. {
  152. if (DM._joining) {
  153. DM.removePlayer(activeChar);
  154. } else {
  155. activeChar.sendMessage("The event is already started. You can not leave now!");
  156. }
  157. }
  158. else if (_command.substring(endOfId + 1).startsWith("ctf_player_join "))
  159. {
  160. String teamName = _command.substring(endOfId + 1).substring(16);
  161. if (CTF._joining) {
  162. CTF.addPlayer(activeChar, teamName);
  163. } else {
  164. activeChar.sendMessage("The event is already started. You can not join now!");
  165. }
  166. }
  167. else if (_command.substring(endOfId + 1).startsWith("ctf_player_leave"))
  168. {
  169. if (CTF._joining) {
  170. CTF.removePlayer(activeChar);
  171. } else {
  172. activeChar.sendMessage("The event is already started. You can not leave now!");
  173. }
  174. }
  175. else if (_command.substring(endOfId+1).startsWith("fos_player_join "))
  176. {
  177. String teamName = _command.substring(endOfId+1).substring(16);
  178.  
  179. if (FortressSiege._joining) {
  180. FortressSiege.addPlayer(activeChar, teamName);
  181. } else {
  182. activeChar.sendMessage("The event has already begun. You can not join now!");
  183. }
  184. }
  185.  
  186. else if (_command.substring(endOfId+1).startsWith("fos_player_leave")){
  187. if (FortressSiege._joining) {
  188. FortressSiege.removePlayer(activeChar);
  189. } else {
  190. activeChar.sendMessage("The event has already begun. You can not withdraw your participation now!");
  191. }
  192. }
  193. if (Config.ALLOW_REMOTE_CLASS_MASTERS && object instanceof L2ClassMasterInstance || object != null && object instanceof L2NpcInstance && endOfId > 0 && activeChar.isInsideRadius(object, L2NpcInstance.INTERACTION_DISTANCE, false, false))
  194. {
  195. ((L2NpcInstance) object).onBypassFeedback(activeChar, _command.substring(endOfId + 1));
  196. }
  197. }
  198. catch (NumberFormatException nfe)
  199. {
  200. }
  201. }
  202. // Draw a Symbol
  203. else if (_command.equals("menu_select?ask=-16&reply=1"))
  204. {
  205. L2Object object = activeChar.getTarget();
  206. if (object instanceof L2NpcInstance)
  207. {
  208. ((L2NpcInstance) object).onBypassFeedback(activeChar, _command);
  209. }
  210. }
  211. else if (_command.equals("menu_select?ask=-16&reply=2"))
  212. {
  213. L2Object object = activeChar.getTarget();
  214. if (object instanceof L2NpcInstance)
  215. {
  216. ((L2NpcInstance) object).onBypassFeedback(activeChar, _command);
  217. }
  218. }
  219. else if (_command.startsWith("manor_menu_select?"))
  220. {
  221. L2Object object = activeChar.getTarget();
  222. if (object instanceof L2NpcInstance)
  223. {
  224. ((L2NpcInstance) object).onBypassFeedback(activeChar, _command);
  225. }
  226. }
  227. else if (_command.startsWith("bbs_"))
  228. {
  229. CommunityBoard.getInstance().handleCommands(getClient(), _command);
  230. }
  231. else if (_command.startsWith("_bbs"))
  232. {
  233. CommunityBoard.getInstance().handleCommands(getClient(), _command);
  234. }
  235. else if (_command.startsWith("Quest "))
  236. {
  237. if (!activeChar.validateBypass(_command))
  238. {
  239. return;
  240. }
  241. L2PcInstance player = getClient().getActiveChar();
  242. if (player == null)
  243. {
  244. return;
  245. }
  246. String p = _command.substring(6).trim();
  247. int idx = p.indexOf(' ');
  248. if (idx < 0)
  249. {
  250. player.processQuestEvent(p, "");
  251. }
  252. else
  253. {
  254. player.processQuestEvent(p.substring(0, idx), p.substring(idx).trim());
  255. }
  256.  
  257. }
  258. else if (_command.equals("rbAnswear"))
  259. {
  260. L2PcInstance player = getClient().getActiveChar();
  261. if (player.getParty().getLeader().isInOlympiadMode())
  262. return;
  263. else if (player.isInOlympiadMode())
  264. return;
  265.  
  266. player.teleToLocation(player.getParty().getLeader().getX(), player.getParty().getLeader().getY(), player.getParty().getLeader().getZ());
  267. }
  268. else if (_command.equals("rbAnswearDenied"))
  269. {
  270. L2PcInstance player = getClient().getActiveChar();
  271. L2PcInstance target = player.getParty().getLeader();
  272. target.sendMessage("The invitation was denied by "+player.getName()+".");
  273. return;
  274. }
  275. else if (_command.startsWith("raidbosslevel_"))
  276. {
  277. L2PcInstance player = getClient().getActiveChar();
  278. if(!player.validateBypass(_command))
  279. return;
  280.  
  281. int endOfId = _command.indexOf('_', 5);
  282. String id;
  283. if (endOfId > 0)
  284. id = _command.substring(4, endOfId);
  285. else
  286. id = _command.substring(4);
  287. try
  288. {
  289. if (_command.substring(endOfId+1).startsWith("40"))
  290. player.showRaidbossInfoLevel40();
  291. else if (_command.substring(endOfId+1).startsWith("45"))
  292. player.showRaidbossInfoLevel45();
  293. else if (_command.substring(endOfId+1).startsWith("50"))
  294. player.showRaidbossInfoLevel50();
  295. else if (_command.substring(endOfId+1).startsWith("55"))
  296. player.showRaidbossInfoLevel55();
  297. else if (_command.substring(endOfId+1).startsWith("60"))
  298. player.showRaidbossInfoLevel60();
  299. else if (_command.substring(endOfId+1).startsWith("65"))
  300. player.showRaidbossInfoLevel65();
  301. else if (_command.substring(endOfId+1).startsWith("70"))
  302. player.showRaidbossInfoLevel70();
  303. }
  304. catch (NumberFormatException nfe) {}
  305. }
  306.  
  307. }
  308. }
  309. catch (Exception e)
  310. {
  311. _log.log(Level.WARNING, "Bad RequestBypassToServer: ", e);
  312. }
  313. // finally
  314. // {
  315. // activeChar.clearBypass();
  316. // }
  317. }
  318.  
  319. /**
  320. * @param client
  321. */
  322. private void comeHere(L2PcInstance activeChar)
  323. {
  324. L2Object obj = activeChar.getTarget();
  325. if (obj == null)
  326. {
  327. return;
  328. }
  329. if (obj instanceof L2NpcInstance)
  330. {
  331. L2NpcInstance temp = (L2NpcInstance) obj;
  332. temp.setTarget(activeChar);
  333. temp.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 0));
  334. // temp.moveTo(player.getX(),player.getY(), player.getZ(), 0 );
  335. }
  336. }
  337.  
  338. private void playerHelp(L2PcInstance activeChar, String path)
  339. {
  340. if (path.indexOf("..") != -1)
  341. {
  342. return;
  343. }
  344. String filename = "data/html/help/" + path;
  345. NpcHtmlMessage html = new NpcHtmlMessage(1);
  346. html.setFile(filename);
  347. activeChar.sendPacket(html);
  348. }
  349.  
  350. /*
  351. * (non-Javadoc)
  352. * @see com.edelvez.gameserver.network.clientpackets.ClientBasePacket#getType()
  353. */
  354. @Override
  355. public String getType()
  356. {
  357. return _C__21_REQUESTBYPASSTOSERVER;
  358. }
  359. }
Advertisement
Add Comment
Please, Sign In to add comment