AdminEffects.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  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_setinvis",
  63. "admin_vis",
  64. "admin_visible",
  65. "admin_invis_menu",
  66. "admin_earthquake",
  67. "admin_earthquake_menu",
  68. "admin_bighead",
  69. "admin_shrinkhead",
  70. "admin_gmspeed",
  71. "admin_gmspeed_menu",
  72. "admin_unpara_all",
  73. "admin_para_all",
  74. "admin_unpara",
  75. "admin_para",
  76. "admin_unpara_all_menu",
  77. "admin_para_all_menu",
  78. "admin_unpara_menu",
  79. "admin_para_menu",
  80. "admin_polyself",
  81. "admin_unpolyself",
  82. "admin_polyself_menu",
  83. "admin_unpolyself_menu",
  84. "admin_clearteams",
  85. "admin_setteam_close",
  86. "admin_setteam",
  87. "admin_social",
  88. "admin_effect",
  89. "admin_effect_menu",
  90. "admin_ave_abnormal",
  91. "admin_ave_special",
  92. "admin_ave_event",
  93. "admin_social_menu",
  94. "admin_play_sounds",
  95. "admin_play_sound",
  96. "admin_atmosphere",
  97. "admin_atmosphere_menu",
  98. "admin_set_displayeffect",
  99. "admin_set_displayeffect_menu"
  100. };
  101. @Override
  102. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  103. {
  104. StringTokenizer st = new StringTokenizer(command);
  105. st.nextToken();
  106. if (command.equals("admin_invis_menu"))
  107. {
  108. if (!activeChar.isInvisible())
  109. {
  110. activeChar.setInvisible(true);
  111. activeChar.broadcastUserInfo();
  112. activeChar.decayMe();
  113. activeChar.spawnMe();
  114. }
  115. else
  116. {
  117. activeChar.setInvisible(false);
  118. activeChar.broadcastUserInfo();
  119. }
  120. RegionBBSManager.getInstance().changeCommunityBoard();
  121. command = "";
  122. AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
  123. }
  124. else if (command.startsWith("admin_invis"))
  125. {
  126. activeChar.setInvisible(false);
  127. activeChar.broadcastUserInfo();
  128. activeChar.decayMe();
  129. activeChar.spawnMe();
  130. RegionBBSManager.getInstance().changeCommunityBoard();
  131. }
  132. else if (command.startsWith("admin_setinvis"))
  133. {
  134. if ((activeChar.getTarget() == null) || !activeChar.getTarget().isCharacter())
  135. {
  136. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  137. return false;
  138. }
  139. final L2Character target = (L2Character) activeChar.getTarget();
  140. target.setInvisible(!target.isInvisible());
  141. activeChar.sendMessage("You've made " + target.getName() + " " + (target.isInvisible() ? "invisible" : "visible") + ".");
  142. }
  143. else if (command.startsWith("admin_vis"))
  144. {
  145. activeChar.setInvisible(false);
  146. activeChar.broadcastUserInfo();
  147. RegionBBSManager.getInstance().changeCommunityBoard();
  148. }
  149. else if (command.startsWith("admin_earthquake"))
  150. {
  151. try
  152. {
  153. String val1 = st.nextToken();
  154. int intensity = Integer.parseInt(val1);
  155. String val2 = st.nextToken();
  156. int duration = Integer.parseInt(val2);
  157. Earthquake eq = new Earthquake(activeChar.getX(), activeChar.getY(), activeChar.getZ(), intensity, duration);
  158. activeChar.broadcastPacket(eq);
  159. }
  160. catch (Exception e)
  161. {
  162. activeChar.sendMessage("Usage: //earthquake <intensity> <duration>");
  163. }
  164. }
  165. else if (command.startsWith("admin_atmosphere"))
  166. {
  167. try
  168. {
  169. String type = st.nextToken();
  170. String state = st.nextToken();
  171. int duration = Integer.parseInt(st.nextToken());
  172. adminAtmosphere(type, state, duration, activeChar);
  173. }
  174. catch (Exception ex)
  175. {
  176. activeChar.sendMessage("Usage: //atmosphere <signsky dawn|dusk>|<sky day|night|red> <duration>");
  177. }
  178. }
  179. else if (command.equals("admin_play_sounds"))
  180. {
  181. AdminHtml.showAdminHtml(activeChar, "songs/songs.htm");
  182. }
  183. else if (command.startsWith("admin_play_sounds"))
  184. {
  185. try
  186. {
  187. AdminHtml.showAdminHtml(activeChar, "songs/songs" + command.substring(18) + ".htm");
  188. }
  189. catch (StringIndexOutOfBoundsException e)
  190. {
  191. activeChar.sendMessage("Usage: //play_sounds <pagenumber>");
  192. }
  193. }
  194. else if (command.startsWith("admin_play_sound"))
  195. {
  196. try
  197. {
  198. playAdminSound(activeChar, command.substring(17));
  199. }
  200. catch (StringIndexOutOfBoundsException e)
  201. {
  202. activeChar.sendMessage("Usage: //play_sound <soundname>");
  203. }
  204. }
  205. else if (command.equals("admin_para_all"))
  206. {
  207. try
  208. {
  209. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  210. for (L2PcInstance player : plrs)
  211. {
  212. if (!player.isGM())
  213. {
  214. player.startAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
  215. player.setIsParalyzed(true);
  216. player.startParalyze();
  217. }
  218. }
  219. }
  220. catch (Exception e)
  221. {
  222. }
  223. }
  224. else if (command.equals("admin_unpara_all"))
  225. {
  226. try
  227. {
  228. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  229. for (L2PcInstance player : plrs)
  230. {
  231. player.stopAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
  232. player.setIsParalyzed(false);
  233. }
  234. }
  235. catch (Exception e)
  236. {
  237. }
  238. }
  239. else if (command.startsWith("admin_para")) // || command.startsWith("admin_para_menu"))
  240. {
  241. String type = "1";
  242. try
  243. {
  244. type = st.nextToken();
  245. }
  246. catch (Exception e)
  247. {
  248. }
  249. try
  250. {
  251. L2Object target = activeChar.getTarget();
  252. L2Character player = null;
  253. if (target instanceof L2Character)
  254. {
  255. player = (L2Character) target;
  256. if (type.equals("1"))
  257. {
  258. player.startAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
  259. }
  260. else
  261. {
  262. player.startAbnormalVisualEffect(true, AbnormalVisualEffect.FLESH_STONE);
  263. }
  264. player.setIsParalyzed(true);
  265. player.startParalyze();
  266. }
  267. }
  268. catch (Exception e)
  269. {
  270. }
  271. }
  272. else if (command.startsWith("admin_unpara")) // || command.startsWith("admin_unpara_menu"))
  273. {
  274. String type = "1";
  275. try
  276. {
  277. type = st.nextToken();
  278. }
  279. catch (Exception e)
  280. {
  281. }
  282. try
  283. {
  284. L2Object target = activeChar.getTarget();
  285. L2Character player = null;
  286. if (target instanceof L2Character)
  287. {
  288. player = (L2Character) target;
  289. if (type.equals("1"))
  290. {
  291. player.stopAbnormalVisualEffect(true, AbnormalVisualEffect.PARALYZE);
  292. }
  293. else
  294. {
  295. player.stopAbnormalVisualEffect(true, AbnormalVisualEffect.FLESH_STONE);
  296. }
  297. player.setIsParalyzed(false);
  298. }
  299. }
  300. catch (Exception e)
  301. {
  302. }
  303. }
  304. else if (command.startsWith("admin_bighead"))
  305. {
  306. try
  307. {
  308. L2Object target = activeChar.getTarget();
  309. L2Character player = null;
  310. if (target instanceof L2Character)
  311. {
  312. player = (L2Character) target;
  313. player.startAbnormalVisualEffect(true, AbnormalVisualEffect.BIG_HEAD);
  314. }
  315. }
  316. catch (Exception e)
  317. {
  318. }
  319. }
  320. else if (command.startsWith("admin_shrinkhead"))
  321. {
  322. try
  323. {
  324. L2Object target = activeChar.getTarget();
  325. L2Character player = null;
  326. if (target instanceof L2Character)
  327. {
  328. player = (L2Character) target;
  329. player.stopAbnormalVisualEffect(true, AbnormalVisualEffect.BIG_HEAD);
  330. }
  331. }
  332. catch (Exception e)
  333. {
  334. }
  335. }
  336. else if (command.startsWith("admin_gmspeed"))
  337. {
  338. try
  339. {
  340. int val = Integer.parseInt(st.nextToken());
  341. boolean sendMessage = activeChar.isAffectedBySkill(7029);
  342. activeChar.stopSkillEffects((val == 0) && sendMessage, 7029);
  343. if ((val >= 1) && (val <= 4))
  344. {
  345. Skill gmSpeedSkill = SkillData.getInstance().getSkill(7029, val);
  346. activeChar.doSimultaneousCast(gmSpeedSkill);
  347. }
  348. }
  349. catch (Exception e)
  350. {
  351. activeChar.sendMessage("Usage: //gmspeed <value> (0=off...4=max)");
  352. }
  353. if (command.contains("_menu"))
  354. {
  355. command = "";
  356. AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
  357. }
  358. }
  359. else if (command.startsWith("admin_polyself"))
  360. {
  361. try
  362. {
  363. String id = st.nextToken();
  364. activeChar.getPoly().setPolyInfo("npc", id);
  365. activeChar.teleToLocation(activeChar.getLocation());
  366. CharInfo info1 = new CharInfo(activeChar);
  367. activeChar.broadcastPacket(info1);
  368. UserInfo info2 = new UserInfo(activeChar);
  369. activeChar.sendPacket(info2);
  370. activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
  371. }
  372. catch (Exception e)
  373. {
  374. activeChar.sendMessage("Usage: //polyself <npcId>");
  375. }
  376. }
  377. else if (command.startsWith("admin_unpolyself"))
  378. {
  379. activeChar.getPoly().setPolyInfo(null, "1");
  380. activeChar.decayMe();
  381. activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  382. CharInfo info1 = new CharInfo(activeChar);
  383. activeChar.broadcastPacket(info1);
  384. UserInfo info2 = new UserInfo(activeChar);
  385. activeChar.sendPacket(info2);
  386. activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
  387. }
  388. else if (command.equals("admin_clearteams"))
  389. {
  390. try
  391. {
  392. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  393. for (L2PcInstance player : plrs)
  394. {
  395. player.setTeam(Team.NONE);
  396. player.broadcastUserInfo();
  397. }
  398. }
  399. catch (Exception e)
  400. {
  401. }
  402. }
  403. else if (command.startsWith("admin_setteam_close"))
  404. {
  405. try
  406. {
  407. String val = st.nextToken();
  408. int radius = 400;
  409. if (st.hasMoreTokens())
  410. {
  411. radius = Integer.parseInt(st.nextToken());
  412. }
  413. Team team = Team.valueOf(val.toUpperCase());
  414. Collection<L2Character> plrs = activeChar.getKnownList().getKnownCharactersInRadius(radius);
  415. for (L2Character player : plrs)
  416. {
  417. player.setTeam(team);
  418. }
  419. }
  420. catch (Exception e)
  421. {
  422. activeChar.sendMessage("Usage: //setteam_close <none|blue|red> [radius]");
  423. }
  424. }
  425. else if (command.startsWith("admin_setteam"))
  426. {
  427. try
  428. {
  429. Team team = Team.valueOf(st.nextToken().toUpperCase());
  430. L2Character target = null;
  431. if (activeChar.getTarget() instanceof L2Character)
  432. {
  433. target = (L2Character) activeChar.getTarget();
  434. }
  435. else
  436. {
  437. return false;
  438. }
  439. target.setTeam(team);
  440. }
  441. catch (Exception e)
  442. {
  443. activeChar.sendMessage("Usage: //setteam <none|blue|red>");
  444. }
  445. }
  446. else if (command.startsWith("admin_social"))
  447. {
  448. try
  449. {
  450. String target = null;
  451. L2Object obj = activeChar.getTarget();
  452. if (st.countTokens() == 2)
  453. {
  454. int social = Integer.parseInt(st.nextToken());
  455. target = st.nextToken();
  456. if (target != null)
  457. {
  458. L2PcInstance player = L2World.getInstance().getPlayer(target);
  459. if (player != null)
  460. {
  461. if (performSocial(social, player, activeChar))
  462. {
  463. activeChar.sendMessage(player.getName() + " was affected by your request.");
  464. }
  465. }
  466. else
  467. {
  468. try
  469. {
  470. int radius = Integer.parseInt(target);
  471. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  472. for (L2Object object : objs)
  473. {
  474. if (activeChar.isInsideRadius(object, radius, false, false))
  475. {
  476. performSocial(social, object, activeChar);
  477. }
  478. }
  479. activeChar.sendMessage(radius + " units radius affected by your request.");
  480. }
  481. catch (NumberFormatException nbe)
  482. {
  483. activeChar.sendMessage("Incorrect parameter");
  484. }
  485. }
  486. }
  487. }
  488. else if (st.countTokens() == 1)
  489. {
  490. int social = Integer.parseInt(st.nextToken());
  491. if (obj == null)
  492. {
  493. obj = activeChar;
  494. }
  495. if (performSocial(social, obj, activeChar))
  496. {
  497. activeChar.sendMessage(obj.getName() + " was affected by your request.");
  498. }
  499. else
  500. {
  501. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  502. }
  503. }
  504. else if (!command.contains("menu"))
  505. {
  506. activeChar.sendMessage("Usage: //social <social_id> [player_name|radius]");
  507. }
  508. }
  509. catch (Exception e)
  510. {
  511. if (Config.DEBUG)
  512. {
  513. e.printStackTrace();
  514. }
  515. }
  516. }
  517. else if (command.startsWith("admin_ave_abnormal") || command.startsWith("admin_ave_special") || command.startsWith("admin_ave_event"))
  518. {
  519. if (st.countTokens() > 0)
  520. {
  521. final String param1 = st.nextToken();
  522. AbnormalVisualEffect ave;
  523. try
  524. {
  525. ave = AbnormalVisualEffect.valueOf(param1);
  526. }
  527. catch (Exception e)
  528. {
  529. return false;
  530. }
  531. int radius = 0;
  532. String param2 = null;
  533. if (st.countTokens() == 1)
  534. {
  535. param2 = st.nextToken();
  536. if (Util.isDigit(param2))
  537. {
  538. radius = Integer.parseInt(param2);
  539. }
  540. }
  541. if (radius > 0)
  542. {
  543. for (L2Object object : activeChar.getKnownList().getKnownObjects().values())
  544. {
  545. if (activeChar.isInsideRadius(object, radius, false, false))
  546. {
  547. performAbnormalVisualEffect(ave, object);
  548. }
  549. }
  550. activeChar.sendMessage("Affected all characters in radius " + param2 + " by " + param1 + " abnormal visual effect.");
  551. }
  552. else
  553. {
  554. final L2Object obj = activeChar.getTarget() != null ? activeChar.getTarget() : activeChar;
  555. if (performAbnormalVisualEffect(ave, obj))
  556. {
  557. activeChar.sendMessage(obj.getName() + " affected by " + param1 + " abnormal visual effect.");
  558. }
  559. else
  560. {
  561. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  562. }
  563. }
  564. }
  565. else
  566. {
  567. activeChar.sendMessage("Usage: //" + command.replace("admin_", "") + " <AbnormalVisualEffect> [radius]");
  568. }
  569. }
  570. else if (command.startsWith("admin_effect"))
  571. {
  572. try
  573. {
  574. L2Object obj = activeChar.getTarget();
  575. int level = 1, hittime = 1;
  576. int skill = Integer.parseInt(st.nextToken());
  577. if (st.hasMoreTokens())
  578. {
  579. level = Integer.parseInt(st.nextToken());
  580. }
  581. if (st.hasMoreTokens())
  582. {
  583. hittime = Integer.parseInt(st.nextToken());
  584. }
  585. if (obj == null)
  586. {
  587. obj = activeChar;
  588. }
  589. if (!(obj instanceof L2Character))
  590. {
  591. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  592. }
  593. else
  594. {
  595. L2Character target = (L2Character) obj;
  596. target.broadcastPacket(new MagicSkillUse(target, activeChar, skill, level, hittime, 0));
  597. activeChar.sendMessage(obj.getName() + " performs MSU " + skill + "/" + level + " by your request.");
  598. }
  599. }
  600. catch (Exception e)
  601. {
  602. activeChar.sendMessage("Usage: //effect skill [level | level hittime]");
  603. }
  604. }
  605. else if (command.startsWith("admin_set_displayeffect"))
  606. {
  607. L2Object target = activeChar.getTarget();
  608. if (!(target instanceof L2Npc))
  609. {
  610. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  611. return false;
  612. }
  613. L2Npc npc = (L2Npc) target;
  614. try
  615. {
  616. String type = st.nextToken();
  617. int diplayeffect = Integer.parseInt(type);
  618. npc.setDisplayEffect(diplayeffect);
  619. }
  620. catch (Exception e)
  621. {
  622. activeChar.sendMessage("Usage: //set_displayeffect <id>");
  623. }
  624. }
  625. if (command.contains("menu") || command.contains("ave_"))
  626. {
  627. showMainPage(activeChar, command);
  628. }
  629. return true;
  630. }
  631. /**
  632. * @param ave the abnormal visual effect
  633. * @param target the target
  634. * @return {@code true} if target's abnormal state was affected, {@code false} otherwise.
  635. */
  636. private boolean performAbnormalVisualEffect(AbnormalVisualEffect ave, L2Object target)
  637. {
  638. if (target instanceof L2Character)
  639. {
  640. final L2Character character = (L2Character) target;
  641. if (character.hasAbnormalVisualEffect(ave))
  642. {
  643. character.stopAbnormalVisualEffect(true, ave);
  644. }
  645. else
  646. {
  647. character.startAbnormalVisualEffect(true, ave);
  648. }
  649. return true;
  650. }
  651. return false;
  652. }
  653. private boolean performSocial(int action, L2Object target, L2PcInstance activeChar)
  654. {
  655. try
  656. {
  657. if (target instanceof L2Character)
  658. {
  659. if (target instanceof L2ChestInstance)
  660. {
  661. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  662. return false;
  663. }
  664. if ((target instanceof L2Npc) && ((action < 1) || (action > 3)))
  665. {
  666. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  667. return false;
  668. }
  669. if ((target instanceof L2PcInstance) && ((action < 2) || ((action > 18) && (action != SocialAction.LEVEL_UP))))
  670. {
  671. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  672. return false;
  673. }
  674. L2Character character = (L2Character) target;
  675. character.broadcastPacket(new SocialAction(character.getObjectId(), action));
  676. }
  677. else
  678. {
  679. return false;
  680. }
  681. }
  682. catch (Exception e)
  683. {
  684. }
  685. return true;
  686. }
  687. /**
  688. * @param type - atmosphere type (signssky,sky)
  689. * @param state - atmosphere state(night,day)
  690. * @param duration
  691. * @param activeChar
  692. */
  693. private void adminAtmosphere(String type, String state, int duration, L2PcInstance activeChar)
  694. {
  695. L2GameServerPacket packet = null;
  696. if (type.equals("signsky"))
  697. {
  698. if (state.equals("dawn"))
  699. {
  700. packet = new SSQInfo(2);
  701. }
  702. else if (state.equals("dusk"))
  703. {
  704. packet = new SSQInfo(1);
  705. }
  706. }
  707. else if (type.equals("sky"))
  708. {
  709. if (state.equals("night"))
  710. {
  711. packet = SunSet.STATIC_PACKET;
  712. }
  713. else if (state.equals("day"))
  714. {
  715. packet = SunRise.STATIC_PACKET;
  716. }
  717. else if (state.equals("red"))
  718. {
  719. if (duration != 0)
  720. {
  721. packet = new ExRedSky(duration);
  722. }
  723. else
  724. {
  725. packet = new ExRedSky(10);
  726. }
  727. }
  728. }
  729. else
  730. {
  731. activeChar.sendMessage("Usage: //atmosphere <signsky dawn|dusk>|<sky day|night|red> <duration>");
  732. }
  733. if (packet != null)
  734. {
  735. Broadcast.toAllOnlinePlayers(packet);
  736. }
  737. }
  738. private void playAdminSound(L2PcInstance activeChar, String sound)
  739. {
  740. PlaySound _snd = new PlaySound(1, sound, 0, 0, 0, 0, 0);
  741. activeChar.sendPacket(_snd);
  742. activeChar.broadcastPacket(_snd);
  743. activeChar.sendMessage("Playing " + sound + ".");
  744. }
  745. @Override
  746. public String[] getAdminCommandList()
  747. {
  748. return ADMIN_COMMANDS;
  749. }
  750. private void showMainPage(L2PcInstance activeChar, String command)
  751. {
  752. String filename = "effects_menu";
  753. if (command.contains("ave_abnormal"))
  754. {
  755. filename = "ave_abnormal";
  756. }
  757. else if (command.contains("ave_special"))
  758. {
  759. filename = "ave_special";
  760. }
  761. else if (command.contains("ave_event"))
  762. {
  763. filename = "ave_event";
  764. }
  765. else if (command.contains("social"))
  766. {
  767. filename = "social";
  768. }
  769. AdminHtml.showAdminHtml(activeChar, filename + ".htm");
  770. }
  771. }