AdminEffects.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. /*
  2. * Copyright (C) 2004-2013 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package handlers.admincommandhandlers;
  20. import java.util.Collection;
  21. import java.util.StringTokenizer;
  22. import com.l2jserver.Config;
  23. import com.l2jserver.gameserver.communitybbs.Manager.RegionBBSManager;
  24. import com.l2jserver.gameserver.datatables.SkillTable;
  25. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  26. import com.l2jserver.gameserver.model.L2Object;
  27. import com.l2jserver.gameserver.model.L2World;
  28. import com.l2jserver.gameserver.model.actor.L2Character;
  29. import com.l2jserver.gameserver.model.actor.L2Npc;
  30. import com.l2jserver.gameserver.model.actor.instance.L2ChestInstance;
  31. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  32. import com.l2jserver.gameserver.model.effects.AbnormalEffect;
  33. import com.l2jserver.gameserver.model.skills.L2Skill;
  34. import com.l2jserver.gameserver.network.SystemMessageId;
  35. import com.l2jserver.gameserver.network.serverpackets.CharInfo;
  36. import com.l2jserver.gameserver.network.serverpackets.Earthquake;
  37. import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
  38. import com.l2jserver.gameserver.network.serverpackets.ExRedSky;
  39. import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
  40. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  41. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  42. import com.l2jserver.gameserver.network.serverpackets.SSQInfo;
  43. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  44. import com.l2jserver.gameserver.network.serverpackets.SunRise;
  45. import com.l2jserver.gameserver.network.serverpackets.SunSet;
  46. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  47. import com.l2jserver.gameserver.network.serverpackets.UserInfo;
  48. import com.l2jserver.gameserver.util.Broadcast;
  49. /**
  50. * This class handles following admin commands: <li>invis/invisible/vis/visible = makes yourself invisible or visible <li>earthquake = causes an earthquake of a given intensity and duration around you <li>bighead/shrinkhead = changes head size <li>gmspeed = temporary Super Haste effect. <li>
  51. * para/unpara = paralyze/remove paralysis from target <li>para_all/unpara_all = same as para/unpara, affects the whole world. <li>polyself/unpolyself = makes you look as a specified mob. <li>changename = temporary change name <li>clearteams/setteam_close/setteam = team related commands <li>social =
  52. * forces an L2Character instance to broadcast social action packets. <li>effect = forces an L2Character instance to broadcast MSU packets. <li>abnormal = force changes over an L2Character instance's abnormal state. <li>play_sound/play_sounds = Music broadcasting related commands <li>atmosphere =
  53. * sky change related commands.
  54. */
  55. public class AdminEffects implements IAdminCommandHandler
  56. {
  57. private static final String[] ADMIN_COMMANDS =
  58. {
  59. "admin_invis",
  60. "admin_invisible",
  61. "admin_vis",
  62. "admin_visible",
  63. "admin_invis_menu",
  64. "admin_earthquake",
  65. "admin_earthquake_menu",
  66. "admin_bighead",
  67. "admin_shrinkhead",
  68. "admin_gmspeed",
  69. "admin_gmspeed_menu",
  70. "admin_unpara_all",
  71. "admin_para_all",
  72. "admin_unpara",
  73. "admin_para",
  74. "admin_unpara_all_menu",
  75. "admin_para_all_menu",
  76. "admin_unpara_menu",
  77. "admin_para_menu",
  78. "admin_polyself",
  79. "admin_unpolyself",
  80. "admin_polyself_menu",
  81. "admin_unpolyself_menu",
  82. "admin_clearteams",
  83. "admin_setteam_close",
  84. "admin_setteam",
  85. "admin_social",
  86. "admin_effect",
  87. "admin_social_menu",
  88. "admin_special",
  89. "admin_special_menu",
  90. "admin_effect_menu",
  91. "admin_abnormal",
  92. "admin_abnormal_menu",
  93. "admin_play_sounds",
  94. "admin_play_sound",
  95. "admin_atmosphere",
  96. "admin_atmosphere_menu",
  97. "admin_set_displayeffect",
  98. "admin_set_displayeffect_menu"
  99. };
  100. @Override
  101. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  102. {
  103. StringTokenizer st = new StringTokenizer(command);
  104. st.nextToken();
  105. if (command.equals("admin_invis_menu"))
  106. {
  107. if (!activeChar.getAppearance().getInvisible())
  108. {
  109. activeChar.getAppearance().setInvisible();
  110. activeChar.broadcastUserInfo();
  111. activeChar.decayMe();
  112. activeChar.spawnMe();
  113. }
  114. else
  115. {
  116. activeChar.getAppearance().setVisible();
  117. activeChar.broadcastUserInfo();
  118. }
  119. RegionBBSManager.getInstance().changeCommunityBoard();
  120. command = "";
  121. AdminHelpPage.showHelpPage(activeChar, "gm_menu.htm");
  122. }
  123. else if (command.startsWith("admin_invis"))
  124. {
  125. activeChar.getAppearance().setInvisible();
  126. activeChar.broadcastUserInfo();
  127. activeChar.decayMe();
  128. activeChar.spawnMe();
  129. RegionBBSManager.getInstance().changeCommunityBoard();
  130. }
  131. else if (command.startsWith("admin_vis"))
  132. {
  133. activeChar.getAppearance().setVisible();
  134. activeChar.broadcastUserInfo();
  135. RegionBBSManager.getInstance().changeCommunityBoard();
  136. }
  137. else if (command.startsWith("admin_earthquake"))
  138. {
  139. try
  140. {
  141. String val1 = st.nextToken();
  142. int intensity = Integer.parseInt(val1);
  143. String val2 = st.nextToken();
  144. int duration = Integer.parseInt(val2);
  145. Earthquake eq = new Earthquake(activeChar.getX(), activeChar.getY(), activeChar.getZ(), intensity, duration);
  146. activeChar.broadcastPacket(eq);
  147. }
  148. catch (Exception e)
  149. {
  150. activeChar.sendMessage("Usage: //earthquake <intensity> <duration>");
  151. }
  152. }
  153. else if (command.startsWith("admin_atmosphere"))
  154. {
  155. try
  156. {
  157. String type = st.nextToken();
  158. String state = st.nextToken();
  159. int duration = Integer.parseInt(st.nextToken());
  160. adminAtmosphere(type, state, duration, activeChar);
  161. }
  162. catch (Exception ex)
  163. {
  164. activeChar.sendMessage("Usage: //atmosphere <signsky dawn|dusk>|<sky day|night|red> <duration>");
  165. }
  166. }
  167. else if (command.equals("admin_play_sounds"))
  168. {
  169. AdminHelpPage.showHelpPage(activeChar, "songs/songs.htm");
  170. }
  171. else if (command.startsWith("admin_play_sounds"))
  172. {
  173. try
  174. {
  175. AdminHelpPage.showHelpPage(activeChar, "songs/songs" + command.substring(18) + ".htm");
  176. }
  177. catch (StringIndexOutOfBoundsException e)
  178. {
  179. activeChar.sendMessage("Usage: //play_sounds <pagenumber>");
  180. }
  181. }
  182. else if (command.startsWith("admin_play_sound"))
  183. {
  184. try
  185. {
  186. playAdminSound(activeChar, command.substring(17));
  187. }
  188. catch (StringIndexOutOfBoundsException e)
  189. {
  190. activeChar.sendMessage("Usage: //play_sound <soundname>");
  191. }
  192. }
  193. else if (command.equals("admin_para_all"))
  194. {
  195. try
  196. {
  197. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  198. for (L2PcInstance player : plrs)
  199. {
  200. if (!player.isGM())
  201. {
  202. player.startAbnormalEffect(AbnormalEffect.HOLD_1);
  203. player.setIsParalyzed(true);
  204. player.startParalyze();
  205. }
  206. }
  207. }
  208. catch (Exception e)
  209. {
  210. }
  211. }
  212. else if (command.equals("admin_unpara_all"))
  213. {
  214. try
  215. {
  216. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  217. for (L2PcInstance player : plrs)
  218. {
  219. player.stopAbnormalEffect(AbnormalEffect.HOLD_1);
  220. player.setIsParalyzed(false);
  221. }
  222. }
  223. catch (Exception e)
  224. {
  225. }
  226. }
  227. else if (command.startsWith("admin_para")) // || command.startsWith("admin_para_menu"))
  228. {
  229. String type = "1";
  230. try
  231. {
  232. type = st.nextToken();
  233. }
  234. catch (Exception e)
  235. {
  236. }
  237. try
  238. {
  239. L2Object target = activeChar.getTarget();
  240. L2Character player = null;
  241. if (target instanceof L2Character)
  242. {
  243. player = (L2Character) target;
  244. if (type.equals("1"))
  245. {
  246. player.startAbnormalEffect(AbnormalEffect.HOLD_1);
  247. }
  248. else
  249. {
  250. player.startAbnormalEffect(AbnormalEffect.HOLD_2);
  251. }
  252. player.setIsParalyzed(true);
  253. player.startParalyze();
  254. }
  255. }
  256. catch (Exception e)
  257. {
  258. }
  259. }
  260. else if (command.startsWith("admin_unpara")) // || command.startsWith("admin_unpara_menu"))
  261. {
  262. String type = "1";
  263. try
  264. {
  265. type = st.nextToken();
  266. }
  267. catch (Exception e)
  268. {
  269. }
  270. try
  271. {
  272. L2Object target = activeChar.getTarget();
  273. L2Character player = null;
  274. if (target instanceof L2Character)
  275. {
  276. player = (L2Character) target;
  277. if (type.equals("1"))
  278. {
  279. player.stopAbnormalEffect(AbnormalEffect.HOLD_1);
  280. }
  281. else
  282. {
  283. player.stopAbnormalEffect(AbnormalEffect.HOLD_2);
  284. }
  285. player.setIsParalyzed(false);
  286. }
  287. }
  288. catch (Exception e)
  289. {
  290. }
  291. }
  292. else if (command.startsWith("admin_bighead"))
  293. {
  294. try
  295. {
  296. L2Object target = activeChar.getTarget();
  297. L2Character player = null;
  298. if (target instanceof L2Character)
  299. {
  300. player = (L2Character) target;
  301. player.startAbnormalEffect(AbnormalEffect.BIG_HEAD);
  302. }
  303. }
  304. catch (Exception e)
  305. {
  306. }
  307. }
  308. else if (command.startsWith("admin_shrinkhead"))
  309. {
  310. try
  311. {
  312. L2Object target = activeChar.getTarget();
  313. L2Character player = null;
  314. if (target instanceof L2Character)
  315. {
  316. player = (L2Character) target;
  317. player.stopAbnormalEffect(AbnormalEffect.BIG_HEAD);
  318. }
  319. }
  320. catch (Exception e)
  321. {
  322. }
  323. }
  324. else if (command.startsWith("admin_gmspeed"))
  325. {
  326. try
  327. {
  328. int val = Integer.parseInt(st.nextToken());
  329. boolean sendMessage = activeChar.getFirstEffect(7029) != null;
  330. activeChar.stopSkillEffects(7029);
  331. if ((val == 0) && sendMessage)
  332. {
  333. final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EFFECT_S1_DISAPPEARED);
  334. sm.addSkillName(7029);
  335. activeChar.sendPacket(sm);
  336. }
  337. else if ((val >= 1) && (val <= 4))
  338. {
  339. L2Skill gmSpeedSkill = SkillTable.getInstance().getInfo(7029, val);
  340. activeChar.doSimultaneousCast(gmSpeedSkill);
  341. }
  342. }
  343. catch (Exception e)
  344. {
  345. activeChar.sendMessage("Usage: //gmspeed <value> (0=off...4=max)");
  346. }
  347. if (command.contains("_menu"))
  348. {
  349. command = "";
  350. AdminHelpPage.showHelpPage(activeChar, "gm_menu.htm");
  351. }
  352. }
  353. else if (command.startsWith("admin_polyself"))
  354. {
  355. try
  356. {
  357. String id = st.nextToken();
  358. activeChar.getPoly().setPolyInfo("npc", id);
  359. activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false);
  360. CharInfo info1 = new CharInfo(activeChar);
  361. activeChar.broadcastPacket(info1);
  362. UserInfo info2 = new UserInfo(activeChar);
  363. activeChar.sendPacket(info2);
  364. activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
  365. }
  366. catch (Exception e)
  367. {
  368. activeChar.sendMessage("Usage: //polyself <npcId>");
  369. }
  370. }
  371. else if (command.startsWith("admin_unpolyself"))
  372. {
  373. activeChar.getPoly().setPolyInfo(null, "1");
  374. activeChar.decayMe();
  375. activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  376. CharInfo info1 = new CharInfo(activeChar);
  377. activeChar.broadcastPacket(info1);
  378. UserInfo info2 = new UserInfo(activeChar);
  379. activeChar.sendPacket(info2);
  380. activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
  381. }
  382. else if (command.equals("admin_clearteams"))
  383. {
  384. try
  385. {
  386. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  387. for (L2PcInstance player : plrs)
  388. {
  389. player.setTeam(0);
  390. player.broadcastUserInfo();
  391. }
  392. }
  393. catch (Exception e)
  394. {
  395. }
  396. }
  397. else if (command.startsWith("admin_setteam_close"))
  398. {
  399. try
  400. {
  401. String val = st.nextToken();
  402. int radius = 400;
  403. if (st.hasMoreTokens())
  404. {
  405. radius = Integer.parseInt(st.nextToken());
  406. }
  407. int teamVal = Integer.parseInt(val);
  408. Collection<L2Character> plrs = activeChar.getKnownList().getKnownCharactersInRadius(radius);
  409. for (L2Character player : plrs)
  410. {
  411. player.setTeam(teamVal);
  412. }
  413. }
  414. catch (Exception e)
  415. {
  416. activeChar.sendMessage("Usage: //setteam_close <teamId>");
  417. }
  418. }
  419. else if (command.startsWith("admin_setteam"))
  420. {
  421. try
  422. {
  423. String val = st.nextToken();
  424. int teamVal = Integer.parseInt(val);
  425. L2Character target = null;
  426. if (activeChar.getTarget() instanceof L2Character)
  427. {
  428. target = (L2Character) activeChar.getTarget();
  429. }
  430. else
  431. {
  432. return false;
  433. }
  434. target.setTeam(teamVal);
  435. }
  436. catch (Exception e)
  437. {
  438. activeChar.sendMessage("Usage: //setteam <teamId>");
  439. }
  440. }
  441. else if (command.startsWith("admin_social"))
  442. {
  443. try
  444. {
  445. String target = null;
  446. L2Object obj = activeChar.getTarget();
  447. if (st.countTokens() == 2)
  448. {
  449. int social = Integer.parseInt(st.nextToken());
  450. target = st.nextToken();
  451. if (target != null)
  452. {
  453. L2PcInstance player = L2World.getInstance().getPlayer(target);
  454. if (player != null)
  455. {
  456. if (performSocial(social, player, activeChar))
  457. {
  458. activeChar.sendMessage(player.getName() + " was affected by your request.");
  459. }
  460. }
  461. else
  462. {
  463. try
  464. {
  465. int radius = Integer.parseInt(target);
  466. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  467. for (L2Object object : objs)
  468. {
  469. if (activeChar.isInsideRadius(object, radius, false, false))
  470. {
  471. performSocial(social, object, activeChar);
  472. }
  473. }
  474. activeChar.sendMessage(radius + " units radius affected by your request.");
  475. }
  476. catch (NumberFormatException nbe)
  477. {
  478. activeChar.sendMessage("Incorrect parameter");
  479. }
  480. }
  481. }
  482. }
  483. else if (st.countTokens() == 1)
  484. {
  485. int social = Integer.parseInt(st.nextToken());
  486. if (obj == null)
  487. {
  488. obj = activeChar;
  489. }
  490. if (performSocial(social, obj, activeChar))
  491. {
  492. activeChar.sendMessage(obj.getName() + " was affected by your request.");
  493. }
  494. else
  495. {
  496. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  497. }
  498. }
  499. else if (!command.contains("menu"))
  500. {
  501. activeChar.sendMessage("Usage: //social <social_id> [player_name|radius]");
  502. }
  503. }
  504. catch (Exception e)
  505. {
  506. if (Config.DEBUG)
  507. {
  508. e.printStackTrace();
  509. }
  510. }
  511. }
  512. else if (command.startsWith("admin_abnormal"))
  513. {
  514. try
  515. {
  516. String target = null;
  517. L2Object obj = activeChar.getTarget();
  518. if (st.countTokens() == 2)
  519. {
  520. String parm = st.nextToken();
  521. int abnormal = Integer.decode("0x" + parm);
  522. target = st.nextToken();
  523. if (target != null)
  524. {
  525. L2PcInstance player = L2World.getInstance().getPlayer(target);
  526. if (player != null)
  527. {
  528. if (performAbnormal(abnormal, player))
  529. {
  530. activeChar.sendMessage(player.getName() + "'s abnormal status was affected by your request.");
  531. }
  532. else
  533. {
  534. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  535. }
  536. }
  537. else
  538. {
  539. try
  540. {
  541. int radius = Integer.parseInt(target);
  542. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  543. for (L2Object object : objs)
  544. {
  545. if (activeChar.isInsideRadius(object, radius, false, false))
  546. {
  547. performAbnormal(abnormal, object);
  548. }
  549. }
  550. activeChar.sendMessage(radius + " units radius affected by your request.");
  551. }
  552. catch (NumberFormatException nbe)
  553. {
  554. activeChar.sendMessage("Usage: //abnormal <hex_abnormal_mask> [player|radius]");
  555. }
  556. }
  557. }
  558. }
  559. else if (st.countTokens() == 1)
  560. {
  561. int abnormal = Integer.decode("0x" + st.nextToken());
  562. if (obj == null)
  563. {
  564. obj = activeChar;
  565. }
  566. if (performAbnormal(abnormal, obj))
  567. {
  568. activeChar.sendMessage(obj.getName() + "'s abnormal status was affected by your request.");
  569. }
  570. else
  571. {
  572. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  573. }
  574. }
  575. else if (!command.contains("menu"))
  576. {
  577. activeChar.sendMessage("Usage: //abnormal <abnormal_mask> [player_name|radius]");
  578. }
  579. }
  580. catch (Exception e)
  581. {
  582. if (Config.DEBUG)
  583. {
  584. e.printStackTrace();
  585. }
  586. }
  587. }
  588. else if (command.startsWith("admin_special"))
  589. {
  590. try
  591. {
  592. String target = null;
  593. L2Object obj = activeChar.getTarget();
  594. if (st.countTokens() == 2)
  595. {
  596. String parm = st.nextToken();
  597. int special = Integer.decode("0x" + parm);
  598. target = st.nextToken();
  599. if (target != null)
  600. {
  601. L2PcInstance player = L2World.getInstance().getPlayer(target);
  602. if (player != null)
  603. {
  604. if (performSpecial(special, player))
  605. {
  606. activeChar.sendMessage(player.getName() + "'s special status was affected by your request.");
  607. }
  608. else
  609. {
  610. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  611. }
  612. }
  613. else
  614. {
  615. try
  616. {
  617. int radius = Integer.parseInt(target);
  618. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  619. for (L2Object object : objs)
  620. {
  621. if (activeChar.isInsideRadius(object, radius, false, false))
  622. {
  623. performSpecial(special, object);
  624. }
  625. }
  626. activeChar.sendMessage(radius + " units radius affected by your request.");
  627. }
  628. catch (NumberFormatException nbe)
  629. {
  630. activeChar.sendMessage("Usage: //special <hex_special_mask> [player|radius]");
  631. }
  632. }
  633. }
  634. }
  635. else if (st.countTokens() == 1)
  636. {
  637. int special = Integer.decode("0x" + st.nextToken());
  638. if (obj == null)
  639. {
  640. obj = activeChar;
  641. }
  642. if (performSpecial(special, obj))
  643. {
  644. activeChar.sendMessage(obj.getName() + "'s special status was affected by your request.");
  645. }
  646. else
  647. {
  648. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  649. }
  650. }
  651. else if (!command.contains("menu"))
  652. {
  653. activeChar.sendMessage("Usage: //special <special_mask> [player_name|radius]");
  654. }
  655. }
  656. catch (Exception e)
  657. {
  658. if (Config.DEBUG)
  659. {
  660. e.printStackTrace();
  661. }
  662. }
  663. }
  664. else if (command.startsWith("admin_effect"))
  665. {
  666. try
  667. {
  668. L2Object obj = activeChar.getTarget();
  669. int level = 1, hittime = 1;
  670. int skill = Integer.parseInt(st.nextToken());
  671. if (st.hasMoreTokens())
  672. {
  673. level = Integer.parseInt(st.nextToken());
  674. }
  675. if (st.hasMoreTokens())
  676. {
  677. hittime = Integer.parseInt(st.nextToken());
  678. }
  679. if (obj == null)
  680. {
  681. obj = activeChar;
  682. }
  683. if (!(obj instanceof L2Character))
  684. {
  685. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  686. }
  687. else
  688. {
  689. L2Character target = (L2Character) obj;
  690. target.broadcastPacket(new MagicSkillUse(target, activeChar, skill, level, hittime, 0));
  691. activeChar.sendMessage(obj.getName() + " performs MSU " + skill + "/" + level + " by your request.");
  692. }
  693. }
  694. catch (Exception e)
  695. {
  696. activeChar.sendMessage("Usage: //effect skill [level | level hittime]");
  697. }
  698. }
  699. else if (command.startsWith("admin_set_displayeffect"))
  700. {
  701. L2Object target = activeChar.getTarget();
  702. if (!(target instanceof L2Npc))
  703. {
  704. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  705. return false;
  706. }
  707. L2Npc npc = (L2Npc) target;
  708. try
  709. {
  710. String type = st.nextToken();
  711. int diplayeffect = Integer.parseInt(type);
  712. npc.setDisplayEffect(diplayeffect);
  713. }
  714. catch (Exception e)
  715. {
  716. activeChar.sendMessage("Usage: //set_displayeffect <id>");
  717. }
  718. }
  719. if (command.contains("menu"))
  720. {
  721. showMainPage(activeChar, command);
  722. }
  723. return true;
  724. }
  725. /**
  726. * @param action bitmask that should be applied over target's abnormal
  727. * @param target
  728. * @return <i>true</i> if target's abnormal state was affected , <i>false</i> otherwise.
  729. */
  730. private boolean performAbnormal(int action, L2Object target)
  731. {
  732. if (target instanceof L2Character)
  733. {
  734. L2Character character = (L2Character) target;
  735. if ((character.getAbnormalEffect() & action) == action)
  736. {
  737. character.stopAbnormalEffect(action);
  738. }
  739. else
  740. {
  741. character.startAbnormalEffect(action);
  742. }
  743. return true;
  744. }
  745. return false;
  746. }
  747. private boolean performSpecial(int action, L2Object target)
  748. {
  749. if (target instanceof L2PcInstance)
  750. {
  751. L2Character character = (L2Character) target;
  752. if ((character.getSpecialEffect() & action) == action)
  753. {
  754. character.stopSpecialEffect(action);
  755. }
  756. else
  757. {
  758. character.startSpecialEffect(action);
  759. }
  760. return true;
  761. }
  762. return false;
  763. }
  764. private boolean performSocial(int action, L2Object target, L2PcInstance activeChar)
  765. {
  766. try
  767. {
  768. if (target instanceof L2Character)
  769. {
  770. if (target instanceof L2ChestInstance)
  771. {
  772. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  773. return false;
  774. }
  775. if ((target instanceof L2Npc) && ((action < 1) || (action > 3)))
  776. {
  777. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  778. return false;
  779. }
  780. if ((target instanceof L2PcInstance) && ((action < 2) || ((action > 18) && (action != SocialAction.LEVEL_UP))))
  781. {
  782. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  783. return false;
  784. }
  785. L2Character character = (L2Character) target;
  786. character.broadcastPacket(new SocialAction(character.getObjectId(), action));
  787. }
  788. else
  789. {
  790. return false;
  791. }
  792. }
  793. catch (Exception e)
  794. {
  795. }
  796. return true;
  797. }
  798. /**
  799. * @param type - atmosphere type (signssky,sky)
  800. * @param state - atmosphere state(night,day)
  801. * @param duration
  802. * @param activeChar
  803. */
  804. private void adminAtmosphere(String type, String state, int duration, L2PcInstance activeChar)
  805. {
  806. L2GameServerPacket packet = null;
  807. if (type.equals("signsky"))
  808. {
  809. if (state.equals("dawn"))
  810. {
  811. packet = new SSQInfo(2);
  812. }
  813. else if (state.equals("dusk"))
  814. {
  815. packet = new SSQInfo(1);
  816. }
  817. }
  818. else if (type.equals("sky"))
  819. {
  820. if (state.equals("night"))
  821. {
  822. packet = SunSet.STATIC_PACKET;
  823. }
  824. else if (state.equals("day"))
  825. {
  826. packet = SunRise.STATIC_PACKET;
  827. }
  828. else if (state.equals("red"))
  829. {
  830. if (duration != 0)
  831. {
  832. packet = new ExRedSky(duration);
  833. }
  834. else
  835. {
  836. packet = new ExRedSky(10);
  837. }
  838. }
  839. }
  840. else
  841. {
  842. activeChar.sendMessage("Usage: //atmosphere <signsky dawn|dusk>|<sky day|night|red> <duration>");
  843. }
  844. if (packet != null)
  845. {
  846. Broadcast.toAllOnlinePlayers(packet);
  847. }
  848. }
  849. private void playAdminSound(L2PcInstance activeChar, String sound)
  850. {
  851. PlaySound _snd = new PlaySound(1, sound, 0, 0, 0, 0, 0);
  852. activeChar.sendPacket(_snd);
  853. activeChar.broadcastPacket(_snd);
  854. activeChar.sendMessage("Playing " + sound + ".");
  855. }
  856. @Override
  857. public String[] getAdminCommandList()
  858. {
  859. return ADMIN_COMMANDS;
  860. }
  861. private void showMainPage(L2PcInstance activeChar, String command)
  862. {
  863. String filename = "effects_menu";
  864. if (command.contains("abnormal"))
  865. {
  866. filename = "abnormal";
  867. }
  868. else if (command.contains("special"))
  869. {
  870. filename = "special";
  871. }
  872. else if (command.contains("social"))
  873. {
  874. filename = "social";
  875. }
  876. AdminHelpPage.showHelpPage(activeChar, filename + ".htm");
  877. }
  878. }