Guest User

Untitled

a guest
Mar 30th, 2020
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.40 KB | None | 0 0
  1. /*
  2. * This file is part of the L2J Mobius project.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. package org.l2jmobius.gameserver.network.clientpackets;
  18.  
  19. import java.util.logging.Logger;
  20.  
  21. import org.l2jmobius.Config;
  22. import org.l2jmobius.gameserver.ai.CtrlIntention;
  23. import org.l2jmobius.gameserver.communitybbs.CommunityBoard;
  24. import org.l2jmobius.gameserver.datatables.SkillTable;
  25. import org.l2jmobius.gameserver.datatables.xml.AdminData;
  26. import org.l2jmobius.gameserver.handler.AdminCommandHandler;
  27. import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
  28. import org.l2jmobius.gameserver.handler.custom.CustomBypassHandler;
  29. import org.l2jmobius.gameserver.model.Location;
  30. import org.l2jmobius.gameserver.model.World;
  31. import org.l2jmobius.gameserver.model.WorldObject;
  32. import org.l2jmobius.gameserver.model.actor.instance.ClassMasterInstance;
  33. import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
  34. import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
  35. import org.l2jmobius.gameserver.model.actor.instance.SymbolMakerInstance;
  36. import org.l2jmobius.gameserver.model.entity.event.CTF;
  37. import org.l2jmobius.gameserver.model.entity.event.DM;
  38. import org.l2jmobius.gameserver.model.entity.event.GameEvent;
  39. import org.l2jmobius.gameserver.model.entity.event.TvT;
  40. import org.l2jmobius.gameserver.model.entity.event.VIP;
  41. import org.l2jmobius.gameserver.model.entity.olympiad.Olympiad;
  42. import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
  43. import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
  44. import org.l2jmobius.gameserver.util.GMAudit;
  45.  
  46. public class RequestBypassToServer extends GameClientPacket
  47. {
  48. private static Logger LOGGER = Logger.getLogger(RequestBypassToServer.class.getName());
  49.  
  50. // S
  51. private String _command;
  52.  
  53. @Override
  54. protected void readImpl()
  55. {
  56. _command = readS();
  57. }
  58.  
  59. @Override
  60. protected void runImpl()
  61. {
  62. final PlayerInstance player = getClient().getPlayer();
  63.  
  64. if (player == null)
  65. {
  66. return;
  67. }
  68.  
  69. if (!getClient().getFloodProtectors().getServerBypass().tryPerformAction(_command))
  70. {
  71. return;
  72. }
  73.  
  74. try
  75. {
  76. if (_command.startsWith("admin_"))
  77. {
  78. if (!player.isGM())
  79. {
  80. return;
  81. }
  82.  
  83. String command;
  84. if (_command.contains(" "))
  85. {
  86. command = _command.substring(0, _command.indexOf(" "));
  87. }
  88. else
  89. {
  90. command = _command;
  91. }
  92.  
  93. final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler(command);
  94. if (ach == null)
  95. {
  96. player.sendMessage("The command " + command + " does not exists!");
  97. LOGGER.warning("No handler registered for admin command '" + command + "'");
  98. return;
  99. }
  100.  
  101. if (!AdminData.getInstance().hasAccess(command, player.getAccessLevel()))
  102. {
  103. player.sendMessage("You don't have the access right to use this command!");
  104. return;
  105. }
  106.  
  107. if (Config.GMAUDIT)
  108. {
  109. GMAudit.auditGMAction(player.getName() + " [" + player.getObjectId() + "]", command, (player.getTarget() != null ? player.getTarget().getName() : "no-target"), _command.replace(command, ""));
  110. }
  111.  
  112. ach.useAdminCommand(_command, player);
  113. }
  114. else if (_command.equals("come_here") && player.isGM())
  115. {
  116. comeHere(player);
  117. }
  118. else if (_command.startsWith("player_help "))
  119. {
  120. playerHelp(player, _command.substring(12));
  121. }
  122. else if (_command.startsWith("npc_"))
  123. {
  124. if (!player.validateBypass(_command))
  125. {
  126. return;
  127. }
  128.  
  129. final int endOfId = _command.indexOf('_', 5);
  130. String id;
  131.  
  132. if (endOfId > 0)
  133. {
  134. id = _command.substring(4, endOfId);
  135. }
  136. else
  137. {
  138. id = _command.substring(4);
  139. }
  140.  
  141. try
  142. {
  143. final WorldObject object = World.getInstance().findObject(Integer.parseInt(id));
  144.  
  145. if (_command.substring(endOfId + 1).startsWith("event_participate"))
  146. {
  147. GameEvent.inscribePlayer(player);
  148. }
  149. else if (_command.substring(endOfId + 1).startsWith("tvt_player_join "))
  150. {
  151. final String teamName = _command.substring(endOfId + 1).substring(16);
  152.  
  153. if (TvT.is_joining())
  154. {
  155. TvT.addPlayer(player, teamName);
  156. }
  157. else
  158. {
  159. player.sendMessage("The event is already started. You can not join now!");
  160. }
  161. }
  162.  
  163. else if (_command.substring(endOfId + 1).startsWith("tvt_player_leave"))
  164. {
  165. if (TvT.is_joining())
  166. {
  167. TvT.removePlayer(player);
  168. }
  169. else
  170. {
  171. player.sendMessage("The event is already started. You can not leave now!");
  172. }
  173. }
  174.  
  175. else if (_command.substring(endOfId + 1).startsWith("dmevent_player_join"))
  176. {
  177. if (DM.is_joining())
  178. {
  179. DM.addPlayer(player);
  180. }
  181. else
  182. {
  183. player.sendMessage("The event is already started. You can't join now!");
  184. }
  185. }
  186.  
  187. else if (_command.substring(endOfId + 1).startsWith("dmevent_player_leave"))
  188. {
  189. if (DM.is_joining())
  190. {
  191. DM.removePlayer(player);
  192. }
  193. else
  194. {
  195. player.sendMessage("The event is already started. You can't leave now!");
  196. }
  197. }
  198.  
  199. else if (_command.substring(endOfId + 1).startsWith("ctf_player_join "))
  200. {
  201. final String teamName = _command.substring(endOfId + 1).substring(16);
  202. if (CTF.is_joining())
  203. {
  204. CTF.addPlayer(player, teamName);
  205. }
  206. else
  207. {
  208. player.sendMessage("The event is already started. You can't join now!");
  209. }
  210. }
  211.  
  212. else if (_command.substring(endOfId + 1).startsWith("ctf_player_leave"))
  213. {
  214. if (CTF.is_joining())
  215. {
  216. CTF.removePlayer(player);
  217. }
  218. else
  219. {
  220. player.sendMessage("The event is already started. You can't leave now!");
  221. }
  222. }
  223.  
  224. if (_command.substring(endOfId + 1).startsWith("vip_joinVIPTeam"))
  225. {
  226. VIP.addPlayerVIP(player);
  227. }
  228.  
  229. if (_command.substring(endOfId + 1).startsWith("vip_joinNotVIPTeam"))
  230. {
  231. VIP.addPlayerNotVIP(player);
  232. }
  233.  
  234. if (_command.substring(endOfId + 1).startsWith("vip_finishVIP"))
  235. {
  236. VIP.vipWin(player);
  237. }
  238.  
  239. if (_command.substring(endOfId + 1).startsWith("event_participate"))
  240. {
  241. GameEvent.inscribePlayer(player);
  242. }
  243.  
  244. if ((Config.ALLOW_CLASS_MASTERS && Config.ALLOW_REMOTE_CLASS_MASTERS && (object instanceof ClassMasterInstance)) || ((object instanceof NpcInstance) && (endOfId > 0) && player.isInsideRadius(object, NpcInstance.INTERACTION_DISTANCE, false, false)))
  245. {
  246. ((NpcInstance) object).onBypassFeedback(player, _command.replace("npc_" + object.getObjectId() + "_", ""));
  247. }
  248.  
  249. player.sendPacket(ActionFailed.STATIC_PACKET);
  250. }
  251. catch (NumberFormatException nfe)
  252. {
  253. }
  254. }
  255. // Draw a Symbol
  256. else if (_command.equals("Draw"))
  257. {
  258. final WorldObject object = player.getTarget();
  259. if (object instanceof NpcInstance)
  260. {
  261. ((SymbolMakerInstance) object).onBypassFeedback(player, _command);
  262. }
  263. }
  264. else if (_command.equals("RemoveList"))
  265. {
  266. final WorldObject object = player.getTarget();
  267. if (object instanceof NpcInstance)
  268. {
  269. ((SymbolMakerInstance) object).onBypassFeedback(player, _command);
  270. }
  271. }
  272. else if (_command.equals("Remove "))
  273. {
  274. final WorldObject object = player.getTarget();
  275.  
  276. if (object instanceof NpcInstance)
  277. {
  278. ((SymbolMakerInstance) object).onBypassFeedback(player, _command);
  279. }
  280. }
  281. // Navigate throught Manor windows
  282. else if (_command.startsWith("manor_menu_select?"))
  283. {
  284. final WorldObject object = player.getTarget();
  285. if (object instanceof NpcInstance)
  286. {
  287. ((NpcInstance) object).onBypassFeedback(player, _command);
  288. }
  289. }
  290. else if (_command.startsWith("bbs_") || _command.startsWith("_bbs") || _command.startsWith("_friend") || _command.startsWith("_mail") || _command.startsWith("_block"))
  291. {
  292. CommunityBoard.getInstance().handleCommands(getClient(), _command);
  293. }
  294. else if (_command.equalsIgnoreCase("giveAcumen"))
  295. {
  296. SkillTable.getInstance().getInfo(1085, 3).getEffectsSelf(player);
  297.  
  298. }
  299.  
  300. else if (_command.startsWith("Quest "))
  301. {
  302. if (!player.validateBypass(_command))
  303. {
  304. return;
  305. }
  306.  
  307. final String p = _command.substring(6).trim();
  308. final int idx = p.indexOf(' ');
  309.  
  310. if (idx < 0)
  311. {
  312. player.processQuestEvent(p, "");
  313. }
  314. else
  315. {
  316. player.processQuestEvent(p.substring(0, idx), p.substring(idx).trim());
  317. }
  318. }
  319.  
  320. // Jstar's Custom Bypass Caller!
  321. else if (_command.startsWith("custom_"))
  322. {
  323. CustomBypassHandler.getInstance().handleBypass(player, _command);
  324. }
  325. else if (_command.startsWith("OlympiadArenaChange"))
  326. {
  327. Olympiad.bypassChangeArena(_command, player);
  328. }
  329. }
  330. catch (Exception e)
  331. {
  332. LOGGER.warning("Bad RequestBypassToServer: " + e);
  333. }
  334. }
  335.  
  336. /**
  337. * @param player
  338. */
  339. private void comeHere(PlayerInstance player)
  340. {
  341. final WorldObject obj = player.getTarget();
  342. if (obj == null)
  343. {
  344. return;
  345. }
  346.  
  347. if (obj instanceof NpcInstance)
  348. {
  349. final NpcInstance temp = (NpcInstance) obj;
  350. temp.setTarget(player);
  351. temp.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(player.getX(), player.getY(), player.getZ(), 0));
  352. // temp.moveTo(player.getX(),player.getY(), player.getZ(), 0 );
  353. }
  354. }
  355.  
  356. private void playerHelp(PlayerInstance player, String path)
  357. {
  358. if (path.contains(".."))
  359. {
  360. return;
  361. }
  362.  
  363. final String filename = "data/html/help/" + path;
  364. final NpcHtmlMessage html = new NpcHtmlMessage(1);
  365. html.setFile(filename);
  366. player.sendPacket(html);
  367. }
  368. }
Advertisement
Add Comment
Please, Sign In to add comment