AdminEffects.java 24 KB

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