AdminEffects.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. /*
  2. * Copyright (C) 2004-2014 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.SkillData;
  25. import com.l2jserver.gameserver.enums.Team;
  26. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  27. import com.l2jserver.gameserver.model.L2Object;
  28. import com.l2jserver.gameserver.model.L2World;
  29. import com.l2jserver.gameserver.model.actor.L2Character;
  30. import com.l2jserver.gameserver.model.actor.L2Npc;
  31. import com.l2jserver.gameserver.model.actor.instance.L2ChestInstance;
  32. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  33. import com.l2jserver.gameserver.model.skills.AbnormalVisualEffect;
  34. import com.l2jserver.gameserver.model.skills.Skill;
  35. import com.l2jserver.gameserver.network.SystemMessageId;
  36. import com.l2jserver.gameserver.network.serverpackets.CharInfo;
  37. import com.l2jserver.gameserver.network.serverpackets.Earthquake;
  38. import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
  39. import com.l2jserver.gameserver.network.serverpackets.ExRedSky;
  40. import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
  41. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  42. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  43. import com.l2jserver.gameserver.network.serverpackets.SSQInfo;
  44. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  45. import com.l2jserver.gameserver.network.serverpackets.SunRise;
  46. import com.l2jserver.gameserver.network.serverpackets.SunSet;
  47. import com.l2jserver.gameserver.network.serverpackets.UserInfo;
  48. import com.l2jserver.gameserver.util.Broadcast;
  49. import com.l2jserver.gameserver.util.Util;
  50. /**
  51. * 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>
  52. * 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 =
  53. * 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 =
  54. * sky change related commands.
  55. */
  56. public class AdminEffects implements IAdminCommandHandler
  57. {
  58. private static final String[] ADMIN_COMMANDS =
  59. {
  60. "admin_invis",
  61. "admin_invisible",
  62. "admin_vis",
  63. "admin_visible",
  64. "admin_invis_menu",
  65. "admin_earthquake",
  66. "admin_earthquake_menu",
  67. "admin_bighead",
  68. "admin_shrinkhead",
  69. "admin_gmspeed",
  70. "admin_gmspeed_menu",
  71. "admin_unpara_all",
  72. "admin_para_all",
  73. "admin_unpara",
  74. "admin_para",
  75. "admin_unpara_all_menu",
  76. "admin_para_all_menu",
  77. "admin_unpara_menu",
  78. "admin_para_menu",
  79. "admin_polyself",
  80. "admin_unpolyself",
  81. "admin_polyself_menu",
  82. "admin_unpolyself_menu",
  83. "admin_clearteams",
  84. "admin_setteam_close",
  85. "admin_setteam",
  86. "admin_social",
  87. "admin_effect",
  88. "admin_effect_menu",
  89. "admin_ave_abnormal",
  90. "admin_ave_special",
  91. "admin_ave_event",
  92. "admin_social_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. AdminHtml.showAdminHtml(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. AdminHtml.showAdminHtml(activeChar, "songs/songs.htm");
  170. }
  171. else if (command.startsWith("admin_play_sounds"))
  172. {
  173. try
  174. {
  175. AdminHtml.showAdminHtml(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.startAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
  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.stopAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
  220. player.setIsParalyzed(false);
  221. }
  222. }
  223. catch (Exception e)
  224. {
  225. }
  226. }
  227. else if (command.startsWith("admin_para")) // || command.startsWith("admin_para_menu"))
  228. {
  229. String type = "1";
  230. try
  231. {
  232. type = st.nextToken();
  233. }
  234. catch (Exception e)
  235. {
  236. }
  237. try
  238. {
  239. L2Object target = activeChar.getTarget();
  240. L2Character player = null;
  241. if (target instanceof L2Character)
  242. {
  243. player = (L2Character) target;
  244. if (type.equals("1"))
  245. {
  246. player.startAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
  247. }
  248. else
  249. {
  250. player.startAbnormalVisualEffect(true, AbnormalVisualEffect.FLESH_STONE);
  251. }
  252. player.setIsParalyzed(true);
  253. player.startParalyze();
  254. }
  255. }
  256. catch (Exception e)
  257. {
  258. }
  259. }
  260. else if (command.startsWith("admin_unpara")) // || command.startsWith("admin_unpara_menu"))
  261. {
  262. String type = "1";
  263. try
  264. {
  265. type = st.nextToken();
  266. }
  267. catch (Exception e)
  268. {
  269. }
  270. try
  271. {
  272. L2Object target = activeChar.getTarget();
  273. L2Character player = null;
  274. if (target instanceof L2Character)
  275. {
  276. player = (L2Character) target;
  277. if (type.equals("1"))
  278. {
  279. player.stopAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
  280. }
  281. else
  282. {
  283. player.stopAbnormalVisualEffect(true, AbnormalVisualEffect.FLESH_STONE);
  284. }
  285. player.setIsParalyzed(false);
  286. }
  287. }
  288. catch (Exception e)
  289. {
  290. }
  291. }
  292. else if (command.startsWith("admin_bighead"))
  293. {
  294. try
  295. {
  296. L2Object target = activeChar.getTarget();
  297. L2Character player = null;
  298. if (target instanceof L2Character)
  299. {
  300. player = (L2Character) target;
  301. player.startAbnormalVisualEffect(true, AbnormalVisualEffect.BIG_HEAD);
  302. }
  303. }
  304. catch (Exception e)
  305. {
  306. }
  307. }
  308. else if (command.startsWith("admin_shrinkhead"))
  309. {
  310. try
  311. {
  312. L2Object target = activeChar.getTarget();
  313. L2Character player = null;
  314. if (target instanceof L2Character)
  315. {
  316. player = (L2Character) target;
  317. player.stopAbnormalVisualEffect(true, AbnormalVisualEffect.BIG_HEAD);
  318. }
  319. }
  320. catch (Exception e)
  321. {
  322. }
  323. }
  324. else if (command.startsWith("admin_gmspeed"))
  325. {
  326. try
  327. {
  328. int val = Integer.parseInt(st.nextToken());
  329. boolean sendMessage = activeChar.isAffectedBySkill(7029);
  330. activeChar.stopSkillEffects((val == 0) && sendMessage, 7029);
  331. if ((val >= 1) && (val <= 4))
  332. {
  333. Skill gmSpeedSkill = SkillData.getInstance().getSkill(7029, val);
  334. activeChar.doSimultaneousCast(gmSpeedSkill);
  335. }
  336. }
  337. catch (Exception e)
  338. {
  339. activeChar.sendMessage("Usage: //gmspeed <value> (0=off...4=max)");
  340. }
  341. if (command.contains("_menu"))
  342. {
  343. command = "";
  344. AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
  345. }
  346. }
  347. else if (command.startsWith("admin_polyself"))
  348. {
  349. try
  350. {
  351. String id = st.nextToken();
  352. activeChar.getPoly().setPolyInfo("npc", id);
  353. activeChar.teleToLocation(activeChar.getLocation());
  354. CharInfo info1 = new CharInfo(activeChar);
  355. activeChar.broadcastPacket(info1);
  356. UserInfo info2 = new UserInfo(activeChar);
  357. activeChar.sendPacket(info2);
  358. activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
  359. }
  360. catch (Exception e)
  361. {
  362. activeChar.sendMessage("Usage: //polyself <npcId>");
  363. }
  364. }
  365. else if (command.startsWith("admin_unpolyself"))
  366. {
  367. activeChar.getPoly().setPolyInfo(null, "1");
  368. activeChar.decayMe();
  369. activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  370. CharInfo info1 = new CharInfo(activeChar);
  371. activeChar.broadcastPacket(info1);
  372. UserInfo info2 = new UserInfo(activeChar);
  373. activeChar.sendPacket(info2);
  374. activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
  375. }
  376. else if (command.equals("admin_clearteams"))
  377. {
  378. try
  379. {
  380. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  381. for (L2PcInstance player : plrs)
  382. {
  383. player.setTeam(Team.NONE);
  384. player.broadcastUserInfo();
  385. }
  386. }
  387. catch (Exception e)
  388. {
  389. }
  390. }
  391. else if (command.startsWith("admin_setteam_close"))
  392. {
  393. try
  394. {
  395. String val = st.nextToken();
  396. int radius = 400;
  397. if (st.hasMoreTokens())
  398. {
  399. radius = Integer.parseInt(st.nextToken());
  400. }
  401. Team team = Team.valueOf(val.toUpperCase());
  402. Collection<L2Character> plrs = activeChar.getKnownList().getKnownCharactersInRadius(radius);
  403. for (L2Character player : plrs)
  404. {
  405. player.setTeam(team);
  406. }
  407. }
  408. catch (Exception e)
  409. {
  410. activeChar.sendMessage("Usage: //setteam_close <none|blue|red> [radius]");
  411. }
  412. }
  413. else if (command.startsWith("admin_setteam"))
  414. {
  415. try
  416. {
  417. Team team = Team.valueOf(st.nextToken().toUpperCase());
  418. L2Character target = null;
  419. if (activeChar.getTarget() instanceof L2Character)
  420. {
  421. target = (L2Character) activeChar.getTarget();
  422. }
  423. else
  424. {
  425. return false;
  426. }
  427. target.setTeam(team);
  428. }
  429. catch (Exception e)
  430. {
  431. activeChar.sendMessage("Usage: //setteam <none|blue|red>");
  432. }
  433. }
  434. else if (command.startsWith("admin_social"))
  435. {
  436. try
  437. {
  438. String target = null;
  439. L2Object obj = activeChar.getTarget();
  440. if (st.countTokens() == 2)
  441. {
  442. int social = Integer.parseInt(st.nextToken());
  443. target = st.nextToken();
  444. if (target != null)
  445. {
  446. L2PcInstance player = L2World.getInstance().getPlayer(target);
  447. if (player != null)
  448. {
  449. if (performSocial(social, player, activeChar))
  450. {
  451. activeChar.sendMessage(player.getName() + " was affected by your request.");
  452. }
  453. }
  454. else
  455. {
  456. try
  457. {
  458. int radius = Integer.parseInt(target);
  459. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  460. for (L2Object object : objs)
  461. {
  462. if (activeChar.isInsideRadius(object, radius, false, false))
  463. {
  464. performSocial(social, object, activeChar);
  465. }
  466. }
  467. activeChar.sendMessage(radius + " units radius affected by your request.");
  468. }
  469. catch (NumberFormatException nbe)
  470. {
  471. activeChar.sendMessage("Incorrect parameter");
  472. }
  473. }
  474. }
  475. }
  476. else if (st.countTokens() == 1)
  477. {
  478. int social = Integer.parseInt(st.nextToken());
  479. if (obj == null)
  480. {
  481. obj = activeChar;
  482. }
  483. if (performSocial(social, obj, activeChar))
  484. {
  485. activeChar.sendMessage(obj.getName() + " was affected by your request.");
  486. }
  487. else
  488. {
  489. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  490. }
  491. }
  492. else if (!command.contains("menu"))
  493. {
  494. activeChar.sendMessage("Usage: //social <social_id> [player_name|radius]");
  495. }
  496. }
  497. catch (Exception e)
  498. {
  499. if (Config.DEBUG)
  500. {
  501. e.printStackTrace();
  502. }
  503. }
  504. }
  505. else if (command.startsWith("admin_ave_abnormal") || command.startsWith("admin_ave_special") || command.startsWith("admin_ave_event"))
  506. {
  507. if (st.countTokens() > 0)
  508. {
  509. final String param1 = st.nextToken();
  510. AbnormalVisualEffect ave;
  511. try
  512. {
  513. ave = AbnormalVisualEffect.valueOf(param1);
  514. }
  515. catch (Exception e)
  516. {
  517. return false;
  518. }
  519. int radius = 0;
  520. String param2 = null;
  521. if (st.countTokens() == 1)
  522. {
  523. param2 = st.nextToken();
  524. if (Util.isDigit(param2))
  525. {
  526. radius = Integer.parseInt(param2);
  527. }
  528. }
  529. if (radius > 0)
  530. {
  531. for (L2Object object : activeChar.getKnownList().getKnownObjects().values())
  532. {
  533. if (activeChar.isInsideRadius(object, radius, false, false))
  534. {
  535. performAbnormalVisualEffect(ave, object);
  536. }
  537. }
  538. activeChar.sendMessage("Affected all characters in radius " + param2 + " by " + param1 + " abnormal visual effect.");
  539. }
  540. else
  541. {
  542. final L2Object obj = activeChar.getTarget() != null ? activeChar.getTarget() : activeChar;
  543. if (performAbnormalVisualEffect(ave, obj))
  544. {
  545. activeChar.sendMessage(obj.getName() + " affected by " + param1 + " abnormal visual effect.");
  546. }
  547. else
  548. {
  549. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  550. }
  551. }
  552. }
  553. else
  554. {
  555. activeChar.sendMessage("Usage: //" + command.replace("admin_", "") + " <AbnormalVisualEffect> [radius]");
  556. }
  557. }
  558. else if (command.startsWith("admin_effect"))
  559. {
  560. try
  561. {
  562. L2Object obj = activeChar.getTarget();
  563. int level = 1, hittime = 1;
  564. int skill = Integer.parseInt(st.nextToken());
  565. if (st.hasMoreTokens())
  566. {
  567. level = Integer.parseInt(st.nextToken());
  568. }
  569. if (st.hasMoreTokens())
  570. {
  571. hittime = Integer.parseInt(st.nextToken());
  572. }
  573. if (obj == null)
  574. {
  575. obj = activeChar;
  576. }
  577. if (!(obj instanceof L2Character))
  578. {
  579. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  580. }
  581. else
  582. {
  583. L2Character target = (L2Character) obj;
  584. target.broadcastPacket(new MagicSkillUse(target, activeChar, skill, level, hittime, 0));
  585. activeChar.sendMessage(obj.getName() + " performs MSU " + skill + "/" + level + " by your request.");
  586. }
  587. }
  588. catch (Exception e)
  589. {
  590. activeChar.sendMessage("Usage: //effect skill [level | level hittime]");
  591. }
  592. }
  593. else if (command.startsWith("admin_set_displayeffect"))
  594. {
  595. L2Object target = activeChar.getTarget();
  596. if (!(target instanceof L2Npc))
  597. {
  598. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  599. return false;
  600. }
  601. L2Npc npc = (L2Npc) target;
  602. try
  603. {
  604. String type = st.nextToken();
  605. int diplayeffect = Integer.parseInt(type);
  606. npc.setDisplayEffect(diplayeffect);
  607. }
  608. catch (Exception e)
  609. {
  610. activeChar.sendMessage("Usage: //set_displayeffect <id>");
  611. }
  612. }
  613. if (command.contains("menu") || command.contains("ave_"))
  614. {
  615. showMainPage(activeChar, command);
  616. }
  617. return true;
  618. }
  619. /**
  620. * @param ave the abnormal visual effect
  621. * @param target the target
  622. * @return {@code true} if target's abnormal state was affected, {@code false} otherwise.
  623. */
  624. private boolean performAbnormalVisualEffect(AbnormalVisualEffect ave, L2Object target)
  625. {
  626. if (target instanceof L2Character)
  627. {
  628. final L2Character character = (L2Character) target;
  629. if (character.hasAbnormalVisualEffect(ave))
  630. {
  631. character.stopAbnormalVisualEffect(true, ave);
  632. }
  633. else
  634. {
  635. character.startAbnormalVisualEffect(true, ave);
  636. }
  637. return true;
  638. }
  639. return false;
  640. }
  641. private boolean performSocial(int action, L2Object target, L2PcInstance activeChar)
  642. {
  643. try
  644. {
  645. if (target instanceof L2Character)
  646. {
  647. if (target instanceof L2ChestInstance)
  648. {
  649. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  650. return false;
  651. }
  652. if ((target instanceof L2Npc) && ((action < 1) || (action > 3)))
  653. {
  654. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  655. return false;
  656. }
  657. if ((target instanceof L2PcInstance) && ((action < 2) || ((action > 18) && (action != SocialAction.LEVEL_UP))))
  658. {
  659. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  660. return false;
  661. }
  662. L2Character character = (L2Character) target;
  663. character.broadcastPacket(new SocialAction(character.getObjectId(), action));
  664. }
  665. else
  666. {
  667. return false;
  668. }
  669. }
  670. catch (Exception e)
  671. {
  672. }
  673. return true;
  674. }
  675. /**
  676. * @param type - atmosphere type (signssky,sky)
  677. * @param state - atmosphere state(night,day)
  678. * @param duration
  679. * @param activeChar
  680. */
  681. private void adminAtmosphere(String type, String state, int duration, L2PcInstance activeChar)
  682. {
  683. L2GameServerPacket packet = null;
  684. if (type.equals("signsky"))
  685. {
  686. if (state.equals("dawn"))
  687. {
  688. packet = new SSQInfo(2);
  689. }
  690. else if (state.equals("dusk"))
  691. {
  692. packet = new SSQInfo(1);
  693. }
  694. }
  695. else if (type.equals("sky"))
  696. {
  697. if (state.equals("night"))
  698. {
  699. packet = SunSet.STATIC_PACKET;
  700. }
  701. else if (state.equals("day"))
  702. {
  703. packet = SunRise.STATIC_PACKET;
  704. }
  705. else if (state.equals("red"))
  706. {
  707. if (duration != 0)
  708. {
  709. packet = new ExRedSky(duration);
  710. }
  711. else
  712. {
  713. packet = new ExRedSky(10);
  714. }
  715. }
  716. }
  717. else
  718. {
  719. activeChar.sendMessage("Usage: //atmosphere <signsky dawn|dusk>|<sky day|night|red> <duration>");
  720. }
  721. if (packet != null)
  722. {
  723. Broadcast.toAllOnlinePlayers(packet);
  724. }
  725. }
  726. private void playAdminSound(L2PcInstance activeChar, String sound)
  727. {
  728. PlaySound _snd = new PlaySound(1, sound, 0, 0, 0, 0, 0);
  729. activeChar.sendPacket(_snd);
  730. activeChar.broadcastPacket(_snd);
  731. activeChar.sendMessage("Playing " + sound + ".");
  732. }
  733. @Override
  734. public String[] getAdminCommandList()
  735. {
  736. return ADMIN_COMMANDS;
  737. }
  738. private void showMainPage(L2PcInstance activeChar, String command)
  739. {
  740. String filename = "effects_menu";
  741. if (command.contains("ave_abnormal"))
  742. {
  743. filename = "ave_abnormal";
  744. }
  745. else if (command.contains("ave_special"))
  746. {
  747. filename = "ave_special";
  748. }
  749. else if (command.contains("ave_event"))
  750. {
  751. filename = "ave_event";
  752. }
  753. else if (command.contains("social"))
  754. {
  755. filename = "social";
  756. }
  757. AdminHtml.showAdminHtml(activeChar, filename + ".htm");
  758. }
  759. }