AdminEffects.java 22 KB

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