AdminEffects.java 22 KB

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