11package simplexity .simplepms .config ;
22
3- import net .kyori .adventure .key .Key ;
43import org .bukkit .NamespacedKey ;
54import org .bukkit .Registry ;
65import org .bukkit .Sound ;
76import org .bukkit .configuration .file .FileConfiguration ;
7+ import org .jetbrains .annotations .NotNull ;
88import simplexity .simplepms .SimplePMs ;
99
1010import java .util .ArrayList ;
@@ -23,7 +23,9 @@ public static ConfigHandler getInstance() {
2323 private final Logger logger = SimplePMs .getInstance ().getLogger ();
2424 private boolean mysqlEnabled , playersSendToConsole , playersSendToHiddenPlayers , consoleHasSocialSpy ,
2525 commandSpyEnabled , consoleHasCommandSpy , receiveSoundEnabled , sendSoundEnabled , spySoundEnabled ;
26- private NamespacedKey receiveSound , sendSound , spySound ;
26+ private NamespacedKey receiveSound = Registry .SOUNDS .getKey (Sound .BLOCK_NOTE_BLOCK_XYLOPHONE );
27+ private NamespacedKey sendSound = Registry .SOUNDS .getKey (Sound .ENTITY_ALLAY_ITEM_THROWN );
28+ private NamespacedKey spySound = Registry .SOUNDS .getKey (Sound .ENTITY_ITEM_FRAME_ROTATE_ITEM );
2729 private float receivePitch , receiveVolume , sendPitch , sendVolume , spyPitch , spyVolume ;
2830 private String mysqlIp , mysqlName , mysqlUsername , mysqlPassword , normalFormat , socialSpyFormat ;
2931 private final List <String > validNamesForConsole = new ArrayList <>();
@@ -64,26 +66,26 @@ private void updateHashSet(HashSet<String> set, List<String> list) {
6466
6567 private void loadReceiveSoundInfo (FileConfiguration config ) {
6668 String soundString = config .getString ("sounds.received.sound" , "minecraft:block.note_block.xylophone" );
67- receiveSound = getValidSound (soundString , Registry .SOUNDS .getKey (Sound .BLOCK_NOTE_BLOCK_XYLOPHONE ));
69+ receiveSound = getValidSound (soundString , Registry .SOUNDS .getKey (Sound .BLOCK_NOTE_BLOCK_XYLOPHONE ));
6870 receivePitch = getValidFloat (config .getDouble ("sounds.received.pitch" , 1.8 ));
6971 receiveVolume = getValidFloat (config .getDouble ("sounds.received.volume" , 0.5 ));
7072 }
7173
72- private void loadSendSoundInfo (FileConfiguration config ){
74+ private void loadSendSoundInfo (FileConfiguration config ) {
7375 String soundString = config .getString ("sounds.sent.sound" , "minecraft:entity.allay.item_thrown" );
74- sendSound = getValidSound (soundString , Registry .SOUNDS .getKey (Sound .ENTITY_ALLAY_ITEM_THROWN ));
76+ sendSound = getValidSound (soundString , Registry .SOUNDS .getKey (Sound .ENTITY_ALLAY_ITEM_THROWN ));
7577 sendPitch = getValidFloat (config .getDouble ("sounds.sent.pitch" , 1.8 ));
7678 sendVolume = getValidFloat (config .getDouble ("sounds.sent.volume" , 0.5 ));
7779 }
7880
79- private void loadSpySoundInfo (FileConfiguration config ){
81+ private void loadSpySoundInfo (FileConfiguration config ) {
8082 String soundString = config .getString ("sounds.spy.sound" , "minecraft:entity.item_frame.rotate_item" );
8183 spySound = getValidSound (soundString , Registry .SOUNDS .getKey (Sound .ENTITY_ITEM_FRAME_ROTATE_ITEM ));
8284 spyPitch = getValidFloat (config .getDouble ("sounds.spy.pitch" , 1.8 ));
8385 spyVolume = getValidFloat (config .getDouble ("sounds.spy.volume" , 0.5 ));
8486 }
8587
86- private NamespacedKey getValidSound (String soundString , NamespacedKey defaultSound ){
88+ private NamespacedKey getValidSound (String soundString , NamespacedKey defaultSound ) {
8789 NamespacedKey key = NamespacedKey .fromString (soundString );
8890 if (key == null || Registry .SOUNDS .get (key ) == null ) {
8991 String warning = LocaleMessage .LOG_ERROR_SOUND_NOT_VALID .getMessage ().replace ("%sound-string%" , soundString );
@@ -95,7 +97,7 @@ private NamespacedKey getValidSound(String soundString, NamespacedKey defaultSou
9597 return key ;
9698 }
9799
98- private float getValidFloat (double numberToCheck ){
100+ private float getValidFloat (double numberToCheck ) {
99101 if (numberToCheck <= 2 && numberToCheck >= 0 ) return (float ) numberToCheck ;
100102 String warning = LocaleMessage .LOG_ERROR_FLOAT_OUT_OF_RANGE .getMessage ().replace ("%number%" , String .valueOf (numberToCheck ));
101103 logger .warning (warning );
@@ -159,15 +161,15 @@ public boolean isCommandSpyEnabled() {
159161 return commandSpyEnabled ;
160162 }
161163
162- public boolean receivingMessagePlaysSound (){
164+ public boolean receivingMessagePlaysSound () {
163165 return receiveSoundEnabled ;
164166 }
165167
166- public boolean sendingMessagePlaysSound (){
168+ public boolean sendingMessagePlaysSound () {
167169 return sendSoundEnabled ;
168170 }
169171
170- public boolean messagePlaysSoundForSpy (){
172+ public boolean messagePlaysSoundForSpy () {
171173 return spySoundEnabled ;
172174 }
173175
@@ -179,14 +181,17 @@ public String getSocialSpyFormat() {
179181 return socialSpyFormat ;
180182 }
181183
184+ @ NotNull
182185 public NamespacedKey getReceiveSound () {
183186 return receiveSound ;
184187 }
185188
189+ @ NotNull
186190 public NamespacedKey getSendSound () {
187191 return sendSound ;
188192 }
189193
194+ @ NotNull
190195 public NamespacedKey getSpySound () {
191196 return spySound ;
192197 }
0 commit comments