AdminEffects.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900
  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. player.stopParalyze(false);
  222. }
  223. }
  224. catch (Exception e)
  225. {
  226. }
  227. }
  228. else if (command.startsWith("admin_para")) // || command.startsWith("admin_para_menu"))
  229. {
  230. String type = "1";
  231. try
  232. {
  233. type = st.nextToken();
  234. }
  235. catch (Exception e)
  236. {
  237. }
  238. try
  239. {
  240. L2Object target = activeChar.getTarget();
  241. L2Character player = null;
  242. if (target instanceof L2Character)
  243. {
  244. player = (L2Character) target;
  245. if (type.equals("1"))
  246. {
  247. player.startAbnormalEffect(AbnormalEffect.HOLD_1);
  248. }
  249. else
  250. {
  251. player.startAbnormalEffect(AbnormalEffect.HOLD_2);
  252. }
  253. player.setIsParalyzed(true);
  254. player.startParalyze();
  255. }
  256. }
  257. catch (Exception e)
  258. {
  259. }
  260. }
  261. else if (command.startsWith("admin_unpara")) // || command.startsWith("admin_unpara_menu"))
  262. {
  263. String type = "1";
  264. try
  265. {
  266. type = st.nextToken();
  267. }
  268. catch (Exception e)
  269. {
  270. }
  271. try
  272. {
  273. L2Object target = activeChar.getTarget();
  274. L2Character player = null;
  275. if (target instanceof L2Character)
  276. {
  277. player = (L2Character) target;
  278. if (type.equals("1"))
  279. {
  280. player.stopAbnormalEffect(AbnormalEffect.HOLD_1);
  281. }
  282. else
  283. {
  284. player.stopAbnormalEffect(AbnormalEffect.HOLD_2);
  285. }
  286. player.setIsParalyzed(false);
  287. player.stopParalyze(false);
  288. }
  289. }
  290. catch (Exception e)
  291. {
  292. }
  293. }
  294. else if (command.startsWith("admin_bighead"))
  295. {
  296. try
  297. {
  298. L2Object target = activeChar.getTarget();
  299. L2Character player = null;
  300. if (target instanceof L2Character)
  301. {
  302. player = (L2Character) target;
  303. player.startAbnormalEffect(AbnormalEffect.BIG_HEAD);
  304. }
  305. }
  306. catch (Exception e)
  307. {
  308. }
  309. }
  310. else if (command.startsWith("admin_shrinkhead"))
  311. {
  312. try
  313. {
  314. L2Object target = activeChar.getTarget();
  315. L2Character player = null;
  316. if (target instanceof L2Character)
  317. {
  318. player = (L2Character) target;
  319. player.stopAbnormalEffect(AbnormalEffect.BIG_HEAD);
  320. }
  321. }
  322. catch (Exception e)
  323. {
  324. }
  325. }
  326. else if (command.startsWith("admin_gmspeed"))
  327. {
  328. try
  329. {
  330. int val = Integer.parseInt(st.nextToken());
  331. boolean sendMessage = activeChar.getFirstEffect(7029) != null;
  332. activeChar.stopSkillEffects(7029);
  333. if ((val == 0) && sendMessage)
  334. {
  335. final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EFFECT_S1_DISAPPEARED);
  336. sm.addSkillName(7029);
  337. activeChar.sendPacket(sm);
  338. }
  339. else if ((val >= 1) && (val <= 4))
  340. {
  341. L2Skill gmSpeedSkill = SkillTable.getInstance().getInfo(7029, val);
  342. activeChar.doSimultaneousCast(gmSpeedSkill);
  343. }
  344. }
  345. catch (Exception e)
  346. {
  347. activeChar.sendMessage("Usage: //gmspeed <value> (0=off...4=max)");
  348. }
  349. if (command.contains("_menu"))
  350. {
  351. command = "";
  352. AdminHelpPage.showHelpPage(activeChar, "gm_menu.htm");
  353. }
  354. }
  355. else if (command.startsWith("admin_polyself"))
  356. {
  357. try
  358. {
  359. String id = st.nextToken();
  360. activeChar.getPoly().setPolyInfo("npc", id);
  361. activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false);
  362. CharInfo info1 = new CharInfo(activeChar);
  363. activeChar.broadcastPacket(info1);
  364. UserInfo info2 = new UserInfo(activeChar);
  365. activeChar.sendPacket(info2);
  366. activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
  367. }
  368. catch (Exception e)
  369. {
  370. activeChar.sendMessage("Usage: //polyself <npcId>");
  371. }
  372. }
  373. else if (command.startsWith("admin_unpolyself"))
  374. {
  375. activeChar.getPoly().setPolyInfo(null, "1");
  376. activeChar.decayMe();
  377. activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  378. CharInfo info1 = new CharInfo(activeChar);
  379. activeChar.broadcastPacket(info1);
  380. UserInfo info2 = new UserInfo(activeChar);
  381. activeChar.sendPacket(info2);
  382. activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
  383. }
  384. else if (command.equals("admin_clearteams"))
  385. {
  386. try
  387. {
  388. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  389. for (L2PcInstance player : plrs)
  390. {
  391. player.setTeam(0);
  392. player.broadcastUserInfo();
  393. }
  394. }
  395. catch (Exception e)
  396. {
  397. }
  398. }
  399. else if (command.startsWith("admin_setteam_close"))
  400. {
  401. try
  402. {
  403. String val = st.nextToken();
  404. int radius = 400;
  405. if (st.hasMoreTokens())
  406. {
  407. radius = Integer.parseInt(st.nextToken());
  408. }
  409. int teamVal = Integer.parseInt(val);
  410. Collection<L2Character> plrs = activeChar.getKnownList().getKnownCharactersInRadius(radius);
  411. for (L2Character player : plrs)
  412. {
  413. player.setTeam(teamVal);
  414. }
  415. }
  416. catch (Exception e)
  417. {
  418. activeChar.sendMessage("Usage: //setteam_close <teamId>");
  419. }
  420. }
  421. else if (command.startsWith("admin_setteam"))
  422. {
  423. try
  424. {
  425. String val = st.nextToken();
  426. int teamVal = Integer.parseInt(val);
  427. L2Character target = null;
  428. if (activeChar.getTarget() instanceof L2Character)
  429. {
  430. target = (L2Character) activeChar.getTarget();
  431. }
  432. else
  433. {
  434. return false;
  435. }
  436. target.setTeam(teamVal);
  437. }
  438. catch (Exception e)
  439. {
  440. activeChar.sendMessage("Usage: //setteam <teamId>");
  441. }
  442. }
  443. else if (command.startsWith("admin_social"))
  444. {
  445. try
  446. {
  447. String target = null;
  448. L2Object obj = activeChar.getTarget();
  449. if (st.countTokens() == 2)
  450. {
  451. int social = Integer.parseInt(st.nextToken());
  452. target = st.nextToken();
  453. if (target != null)
  454. {
  455. L2PcInstance player = L2World.getInstance().getPlayer(target);
  456. if (player != null)
  457. {
  458. if (performSocial(social, player, activeChar))
  459. {
  460. activeChar.sendMessage(player.getName() + " was affected by your request.");
  461. }
  462. }
  463. else
  464. {
  465. try
  466. {
  467. int radius = Integer.parseInt(target);
  468. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  469. for (L2Object object : objs)
  470. {
  471. if (activeChar.isInsideRadius(object, radius, false, false))
  472. {
  473. performSocial(social, object, activeChar);
  474. }
  475. }
  476. activeChar.sendMessage(radius + " units radius affected by your request.");
  477. }
  478. catch (NumberFormatException nbe)
  479. {
  480. activeChar.sendMessage("Incorrect parameter");
  481. }
  482. }
  483. }
  484. }
  485. else if (st.countTokens() == 1)
  486. {
  487. int social = Integer.parseInt(st.nextToken());
  488. if (obj == null)
  489. {
  490. obj = activeChar;
  491. }
  492. if (performSocial(social, obj, activeChar))
  493. {
  494. activeChar.sendMessage(obj.getName() + " was affected by your request.");
  495. }
  496. else
  497. {
  498. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  499. }
  500. }
  501. else if (!command.contains("menu"))
  502. {
  503. activeChar.sendMessage("Usage: //social <social_id> [player_name|radius]");
  504. }
  505. }
  506. catch (Exception e)
  507. {
  508. if (Config.DEBUG)
  509. {
  510. e.printStackTrace();
  511. }
  512. }
  513. }
  514. else if (command.startsWith("admin_abnormal"))
  515. {
  516. try
  517. {
  518. String target = null;
  519. L2Object obj = activeChar.getTarget();
  520. if (st.countTokens() == 2)
  521. {
  522. String parm = st.nextToken();
  523. int abnormal = Integer.decode("0x" + parm);
  524. target = st.nextToken();
  525. if (target != null)
  526. {
  527. L2PcInstance player = L2World.getInstance().getPlayer(target);
  528. if (player != null)
  529. {
  530. if (performAbnormal(abnormal, player))
  531. {
  532. activeChar.sendMessage(player.getName() + "'s abnormal status was affected by your request.");
  533. }
  534. else
  535. {
  536. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  537. }
  538. }
  539. else
  540. {
  541. try
  542. {
  543. int radius = Integer.parseInt(target);
  544. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  545. for (L2Object object : objs)
  546. {
  547. if (activeChar.isInsideRadius(object, radius, false, false))
  548. {
  549. performAbnormal(abnormal, object);
  550. }
  551. }
  552. activeChar.sendMessage(radius + " units radius affected by your request.");
  553. }
  554. catch (NumberFormatException nbe)
  555. {
  556. activeChar.sendMessage("Usage: //abnormal <hex_abnormal_mask> [player|radius]");
  557. }
  558. }
  559. }
  560. }
  561. else if (st.countTokens() == 1)
  562. {
  563. int abnormal = Integer.decode("0x" + st.nextToken());
  564. if (obj == null)
  565. {
  566. obj = activeChar;
  567. }
  568. if (performAbnormal(abnormal, obj))
  569. {
  570. activeChar.sendMessage(obj.getName() + "'s abnormal status was affected by your request.");
  571. }
  572. else
  573. {
  574. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  575. }
  576. }
  577. else if (!command.contains("menu"))
  578. {
  579. activeChar.sendMessage("Usage: //abnormal <abnormal_mask> [player_name|radius]");
  580. }
  581. }
  582. catch (Exception e)
  583. {
  584. if (Config.DEBUG)
  585. {
  586. e.printStackTrace();
  587. }
  588. }
  589. }
  590. else if (command.startsWith("admin_special"))
  591. {
  592. try
  593. {
  594. String target = null;
  595. L2Object obj = activeChar.getTarget();
  596. if (st.countTokens() == 2)
  597. {
  598. String parm = st.nextToken();
  599. int special = Integer.decode("0x" + parm);
  600. target = st.nextToken();
  601. if (target != null)
  602. {
  603. L2PcInstance player = L2World.getInstance().getPlayer(target);
  604. if (player != null)
  605. {
  606. if (performSpecial(special, player))
  607. {
  608. activeChar.sendMessage(player.getName() + "'s special status was affected by your request.");
  609. }
  610. else
  611. {
  612. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  613. }
  614. }
  615. else
  616. {
  617. try
  618. {
  619. int radius = Integer.parseInt(target);
  620. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  621. for (L2Object object : objs)
  622. {
  623. if (activeChar.isInsideRadius(object, radius, false, false))
  624. {
  625. performSpecial(special, object);
  626. }
  627. }
  628. activeChar.sendMessage(radius + " units radius affected by your request.");
  629. }
  630. catch (NumberFormatException nbe)
  631. {
  632. activeChar.sendMessage("Usage: //special <hex_special_mask> [player|radius]");
  633. }
  634. }
  635. }
  636. }
  637. else if (st.countTokens() == 1)
  638. {
  639. int special = Integer.decode("0x" + st.nextToken());
  640. if (obj == null)
  641. {
  642. obj = activeChar;
  643. }
  644. if (performSpecial(special, obj))
  645. {
  646. activeChar.sendMessage(obj.getName() + "'s special status was affected by your request.");
  647. }
  648. else
  649. {
  650. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  651. }
  652. }
  653. else if (!command.contains("menu"))
  654. {
  655. activeChar.sendMessage("Usage: //special <special_mask> [player_name|radius]");
  656. }
  657. }
  658. catch (Exception e)
  659. {
  660. if (Config.DEBUG)
  661. {
  662. e.printStackTrace();
  663. }
  664. }
  665. }
  666. else if (command.startsWith("admin_effect"))
  667. {
  668. try
  669. {
  670. L2Object obj = activeChar.getTarget();
  671. int level = 1, hittime = 1;
  672. int skill = Integer.parseInt(st.nextToken());
  673. if (st.hasMoreTokens())
  674. {
  675. level = Integer.parseInt(st.nextToken());
  676. }
  677. if (st.hasMoreTokens())
  678. {
  679. hittime = Integer.parseInt(st.nextToken());
  680. }
  681. if (obj == null)
  682. {
  683. obj = activeChar;
  684. }
  685. if (!(obj instanceof L2Character))
  686. {
  687. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  688. }
  689. else
  690. {
  691. L2Character target = (L2Character) obj;
  692. target.broadcastPacket(new MagicSkillUse(target, activeChar, skill, level, hittime, 0));
  693. activeChar.sendMessage(obj.getName() + " performs MSU " + skill + "/" + level + " by your request.");
  694. }
  695. }
  696. catch (Exception e)
  697. {
  698. activeChar.sendMessage("Usage: //effect skill [level | level hittime]");
  699. }
  700. }
  701. else if (command.startsWith("admin_set_displayeffect"))
  702. {
  703. L2Object target = activeChar.getTarget();
  704. if (!(target instanceof L2Npc))
  705. {
  706. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  707. return false;
  708. }
  709. L2Npc npc = (L2Npc) target;
  710. try
  711. {
  712. String type = st.nextToken();
  713. int diplayeffect = Integer.parseInt(type);
  714. npc.setDisplayEffect(diplayeffect);
  715. }
  716. catch (Exception e)
  717. {
  718. activeChar.sendMessage("Usage: //set_displayeffect <id>");
  719. }
  720. }
  721. if (command.contains("menu"))
  722. {
  723. showMainPage(activeChar, command);
  724. }
  725. return true;
  726. }
  727. /**
  728. * @param action bitmask that should be applied over target's abnormal
  729. * @param target
  730. * @return <i>true</i> if target's abnormal state was affected , <i>false</i> otherwise.
  731. */
  732. private boolean performAbnormal(int action, L2Object target)
  733. {
  734. if (target instanceof L2Character)
  735. {
  736. L2Character character = (L2Character) target;
  737. if ((character.getAbnormalEffect() & action) == action)
  738. {
  739. character.stopAbnormalEffect(action);
  740. }
  741. else
  742. {
  743. character.startAbnormalEffect(action);
  744. }
  745. return true;
  746. }
  747. return false;
  748. }
  749. private boolean performSpecial(int action, L2Object target)
  750. {
  751. if (target instanceof L2PcInstance)
  752. {
  753. L2Character character = (L2Character) target;
  754. if ((character.getSpecialEffect() & action) == action)
  755. {
  756. character.stopSpecialEffect(action);
  757. }
  758. else
  759. {
  760. character.startSpecialEffect(action);
  761. }
  762. return true;
  763. }
  764. return false;
  765. }
  766. private boolean performSocial(int action, L2Object target, L2PcInstance activeChar)
  767. {
  768. try
  769. {
  770. if (target instanceof L2Character)
  771. {
  772. if (target instanceof L2ChestInstance)
  773. {
  774. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  775. return false;
  776. }
  777. if ((target instanceof L2Npc) && ((action < 1) || (action > 3)))
  778. {
  779. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  780. return false;
  781. }
  782. if ((target instanceof L2PcInstance) && ((action < 2) || ((action > 18) && (action != SocialAction.LEVEL_UP))))
  783. {
  784. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  785. return false;
  786. }
  787. L2Character character = (L2Character) target;
  788. character.broadcastPacket(new SocialAction(character.getObjectId(), action));
  789. }
  790. else
  791. {
  792. return false;
  793. }
  794. }
  795. catch (Exception e)
  796. {
  797. }
  798. return true;
  799. }
  800. /**
  801. * @param type - atmosphere type (signssky,sky)
  802. * @param state - atmosphere state(night,day)
  803. * @param duration
  804. * @param activeChar
  805. */
  806. private void adminAtmosphere(String type, String state, int duration, L2PcInstance activeChar)
  807. {
  808. L2GameServerPacket packet = null;
  809. if (type.equals("signsky"))
  810. {
  811. if (state.equals("dawn"))
  812. {
  813. packet = new SSQInfo(2);
  814. }
  815. else if (state.equals("dusk"))
  816. {
  817. packet = new SSQInfo(1);
  818. }
  819. }
  820. else if (type.equals("sky"))
  821. {
  822. if (state.equals("night"))
  823. {
  824. packet = SunSet.STATIC_PACKET;
  825. }
  826. else if (state.equals("day"))
  827. {
  828. packet = SunRise.STATIC_PACKET;
  829. }
  830. else if (state.equals("red"))
  831. {
  832. if (duration != 0)
  833. {
  834. packet = new ExRedSky(duration);
  835. }
  836. else
  837. {
  838. packet = new ExRedSky(10);
  839. }
  840. }
  841. }
  842. else
  843. {
  844. activeChar.sendMessage("Usage: //atmosphere <signsky dawn|dusk>|<sky day|night|red> <duration>");
  845. }
  846. if (packet != null)
  847. {
  848. Broadcast.toAllOnlinePlayers(packet);
  849. }
  850. }
  851. private void playAdminSound(L2PcInstance activeChar, String sound)
  852. {
  853. PlaySound _snd = new PlaySound(1, sound, 0, 0, 0, 0, 0);
  854. activeChar.sendPacket(_snd);
  855. activeChar.broadcastPacket(_snd);
  856. activeChar.sendMessage("Playing " + sound + ".");
  857. }
  858. @Override
  859. public String[] getAdminCommandList()
  860. {
  861. return ADMIN_COMMANDS;
  862. }
  863. private void showMainPage(L2PcInstance activeChar, String command)
  864. {
  865. String filename = "effects_menu";
  866. if (command.contains("abnormal"))
  867. {
  868. filename = "abnormal";
  869. }
  870. else if (command.contains("special"))
  871. {
  872. filename = "special";
  873. }
  874. else if (command.contains("social"))
  875. {
  876. filename = "social";
  877. }
  878. AdminHelpPage.showHelpPage(activeChar, filename + ".htm");
  879. }
  880. }