QuestSound.java 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server 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 Server 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 com.l2jserver.gameserver.enums;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  23. /**
  24. * This enum contains known sound effects used by quests.<br>
  25. * The idea is to have only a single object of each quest sound instead of constructing a new one every time a script calls the playSound method.<br>
  26. * This is pretty much just a memory and CPU cycle optimization; avoids constructing/deconstructing objects all the time if they're all the same.<br>
  27. * For datapack scripts written in Java and extending the Quest class, this does not need an extra import.
  28. * @author jurchiks
  29. */
  30. public enum QuestSound
  31. {
  32. ITEMSOUND_QUEST_ACCEPT(new PlaySound("ItemSound.quest_accept")),
  33. ITEMSOUND_QUEST_MIDDLE(new PlaySound("ItemSound.quest_middle")),
  34. ITEMSOUND_QUEST_FINISH(new PlaySound("ItemSound.quest_finish")),
  35. ITEMSOUND_QUEST_ITEMGET(new PlaySound("ItemSound.quest_itemget")),
  36. // Newbie Guide tutorial (incl. some quests), Mutated Kaneus quests, Quest 192
  37. ITEMSOUND_QUEST_TUTORIAL(new PlaySound("ItemSound.quest_tutorial")),
  38. // Quests 107, 363, 364
  39. ITEMSOUND_QUEST_GIVEUP(new PlaySound("ItemSound.quest_giveup")),
  40. // Quests 212, 217, 224, 226, 416
  41. ITEMSOUND_QUEST_BEFORE_BATTLE(new PlaySound("ItemSound.quest_before_battle")),
  42. // Quests 211, 258, 266, 330
  43. ITEMSOUND_QUEST_JACKPOT(new PlaySound("ItemSound.quest_jackpot")),
  44. // Quests 508, 509 and 510
  45. ITEMSOUND_QUEST_FANFARE_1(new PlaySound("ItemSound.quest_fanfare_1")),
  46. // Played only after class transfer via Test Server Helpers (ID 31756 and 31757)
  47. ITEMSOUND_QUEST_FANFARE_2(new PlaySound("ItemSound.quest_fanfare_2")),
  48. // Quest 336
  49. ITEMSOUND_QUEST_FANFARE_MIDDLE(new PlaySound("ItemSound.quest_fanfare_middle")),
  50. // Quest 114
  51. ITEMSOUND_ARMOR_WOOD(new PlaySound("ItemSound.armor_wood_3")),
  52. // Quest 21
  53. ITEMSOUND_ARMOR_CLOTH(new PlaySound("ItemSound.item_drop_equip_armor_cloth")),
  54. AMDSOUND_ED_CHIMES(new PlaySound("AmdSound.ed_chimes_05")),
  55. HORROR_01(new PlaySound("horror_01")), // played when spawned monster sees player
  56. // Quest 22
  57. AMBSOUND_HORROR_01(new PlaySound("AmbSound.dd_horror_01")),
  58. AMBSOUND_HORROR_03(new PlaySound("AmbSound.d_horror_03")),
  59. AMBSOUND_HORROR_15(new PlaySound("AmbSound.d_horror_15")),
  60. // Quest 23
  61. ITEMSOUND_ARMOR_LEATHER(new PlaySound("ItemSound.itemdrop_armor_leather")),
  62. ITEMSOUND_WEAPON_SPEAR(new PlaySound("ItemSound.itemdrop_weapon_spear")),
  63. AMBSOUND_MT_CREAK(new PlaySound("AmbSound.mt_creak01")),
  64. AMBSOUND_EG_DRON(new PlaySound("AmbSound.eg_dron_02")),
  65. SKILLSOUND_HORROR_02(new PlaySound("SkillSound5.horror_02")),
  66. CHRSOUND_MHFIGHTER_CRY(new PlaySound("ChrSound.MHFighter_cry")),
  67. // Quest 24
  68. AMDSOUND_WIND_LOOT(new PlaySound("AmdSound.d_wind_loot_02")),
  69. INTERFACESOUND_CHARSTAT_OPEN(new PlaySound("InterfaceSound.charstat_open_01")),
  70. // Quest 25
  71. AMDSOUND_HORROR_02(new PlaySound("AmdSound.dd_horror_02")),
  72. CHRSOUND_FDELF_CRY(new PlaySound("ChrSound.FDElf_Cry")),
  73. // Quest 115
  74. AMBSOUND_WINGFLAP(new PlaySound("AmbSound.t_wingflap_04")),
  75. AMBSOUND_THUNDER(new PlaySound("AmbSound.thunder_02")),
  76. // Quest 120
  77. AMBSOUND_DRONE(new PlaySound("AmbSound.ed_drone_02")),
  78. AMBSOUND_CRYSTAL_LOOP(new PlaySound("AmbSound.cd_crystal_loop")),
  79. AMBSOUND_PERCUSSION_01(new PlaySound("AmbSound.dt_percussion_01")),
  80. AMBSOUND_PERCUSSION_02(new PlaySound("AmbSound.ac_percussion_02")),
  81. // Quest 648 and treasure chests
  82. ITEMSOUND_BROKEN_KEY(new PlaySound("ItemSound2.broken_key")),
  83. // Quest 184
  84. ITEMSOUND_SIREN(new PlaySound("ItemSound3.sys_siren")),
  85. // Quest 648
  86. ITEMSOUND_ENCHANT_SUCCESS(new PlaySound("ItemSound3.sys_enchant_success")),
  87. ITEMSOUND_ENCHANT_FAILED(new PlaySound("ItemSound3.sys_enchant_failed")),
  88. // Best farm mobs
  89. ITEMSOUND_SOW_SUCCESS(new PlaySound("ItemSound3.sys_sow_success")),
  90. // Quest 25
  91. SKILLSOUND_HORROR_1(new PlaySound("SkillSound5.horror_01")),
  92. // Quests 21 and 23
  93. SKILLSOUND_HORROR_2(new PlaySound("SkillSound5.horror_02")),
  94. // Quest 22
  95. SKILLSOUND_ANTARAS_FEAR(new PlaySound("SkillSound3.antaras_fear")),
  96. // Quest 505
  97. SKILLSOUND_JEWEL_CELEBRATE(new PlaySound("SkillSound2.jewel.celebrate")),
  98. // Quest 373
  99. SKILLSOUND_LIQUID_MIX(new PlaySound("SkillSound5.liquid_mix_01")),
  100. SKILLSOUND_LIQUID_SUCCESS(new PlaySound("SkillSound5.liquid_success_01")),
  101. SKILLSOUND_LIQUID_FAIL(new PlaySound("SkillSound5.liquid_fail_01")),
  102. // Quest 111
  103. ETCSOUND_ELROKI_SONG_FULL(new PlaySound("EtcSound.elcroki_song_full")),
  104. ETCSOUND_ELROKI_SONG_1ST(new PlaySound("EtcSound.elcroki_song_1st")),
  105. ETCSOUND_ELROKI_SONG_2ND(new PlaySound("EtcSound.elcroki_song_2nd")),
  106. ETCSOUND_ELROKI_SONG_3RD(new PlaySound("EtcSound.elcroki_song_3rd")),
  107. // Long duration AI sounds
  108. BS01_A(new PlaySound("BS01_A")),
  109. BS02_A(new PlaySound("BS02_A")),
  110. BS03_A(new PlaySound("BS03_A")),
  111. BS04_A(new PlaySound("BS04_A")),
  112. BS06_A(new PlaySound("BS06_A")),
  113. BS07_A(new PlaySound("BS07_A")),
  114. BS08_A(new PlaySound("BS08_A")),
  115. BS01_D(new PlaySound("BS01_D")),
  116. BS02_D(new PlaySound("BS02_D")),
  117. BS05_D(new PlaySound("BS05_D")),
  118. BS07_D(new PlaySound("BS07_D"));
  119. private final PlaySound _playSound;
  120. private static Map<String, PlaySound> soundPackets = new HashMap<>();
  121. private QuestSound(PlaySound playSound)
  122. {
  123. _playSound = playSound;
  124. }
  125. /**
  126. * Get a {@link PlaySound} packet by its name.
  127. * @param soundName the name of the sound to look for
  128. * @return the {@link PlaySound} packet with the specified sound or {@code null} if one was not found
  129. */
  130. public static PlaySound getSound(String soundName)
  131. {
  132. if (soundPackets.containsKey(soundName))
  133. {
  134. return soundPackets.get(soundName);
  135. }
  136. for (QuestSound qs : QuestSound.values())
  137. {
  138. if (qs._playSound.getSoundName().equals(soundName))
  139. {
  140. soundPackets.put(soundName, qs._playSound); // cache in map to avoid looping repeatedly
  141. return qs._playSound;
  142. }
  143. }
  144. soundPackets.put(soundName, new PlaySound(soundName));
  145. return soundPackets.get(soundName);
  146. }
  147. /**
  148. * @return the name of the sound of this QuestSound object
  149. */
  150. public String getSoundName()
  151. {
  152. return _playSound.getSoundName();
  153. }
  154. /**
  155. * @return the {@link PlaySound} packet of this QuestSound object
  156. */
  157. public PlaySound getPacket()
  158. {
  159. return _playSound;
  160. }
  161. }