AdminEffects.java 24 KB

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