AdminEffects.java 24 KB

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