AdminEffects.java 22 KB

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