Jelajahi Sumber

You can now turn off sound effects used by mcMMO

nossr50 6 tahun lalu
induk
melakukan
b42b4cadbe

+ 6 - 0
src/main/java/com/gmail/nossr50/config/SoundConfig.java

@@ -61,4 +61,10 @@ public class SoundConfig extends AutoUpdateConfigLoader {
         String key = "Sounds."+soundType.toString()+".Pitch";
         return (float) config.getDouble(key);
     }
+
+    public boolean getIsEnabled(SoundType soundType)
+    {
+        String key = "Sounds."+soundType.toString()+".Enabled";
+        return config.getBoolean(key, true);
+    }
 }

+ 9 - 4
src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java

@@ -15,23 +15,28 @@ public class SoundManager {
      */
     public static void sendSound(Player player, Location location, SoundType soundType)
     {
-        player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType));
+        if(SoundConfig.getInstance().getIsEnabled(soundType))
+            player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType));
     }
 
     public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory)
     {
-        player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType));
+        if(SoundConfig.getInstance().getIsEnabled(soundType))
+            player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType));
     }
 
     public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory, float pitchModifier)
     {
         float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier));
-        player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch);
+
+        if(SoundConfig.getInstance().getIsEnabled(soundType))
+            player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch);
     }
 
     public static void worldSendSound(World world, Location location, SoundType soundType)
     {
-        world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
+        if(SoundConfig.getInstance().getIsEnabled(soundType))
+            world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
     }
 
     /**

+ 14 - 0
src/main/resources/sounds.yml

@@ -5,44 +5,58 @@ Sounds:
     # 0.0 = No Volume
     MasterVolume: 1.0
     ANVIL:
+        Enable: true
         Volume: 1.0
         Pitch: 0.3
     #Fizz, Pop, and Kraken make use of a adding and multiplying random numbers together to make a unique pitch everytime they are heard
     FIZZ:
+        Enable: true
         Volume: 0.5
     LEVEL_UP:
+        Enable: true
         Volume: 0.75
         Pitch: 0.5
     ITEM_BREAK:
+        Enable: true
         Volume: 1.0
         Pitch: 1.0
     #Fizz, Pop, and Kraken make use of a adding and multiplying random numbers together to make a unique pitch everytime they are heard
     POP:
+        Enable: true
         Volume: 0.2
     #Fizz, Pop, and Kraken make use of a adding and multiplying random numbers together to make a unique pitch everytime they are heard
     KRAKEN:
+        Enable: true
         Volume: 1.0
     CHIMAERA_WING:
+        Enable: true
         Volume: 1.0
         Pitch: 0.6
     ROLL_ACTIVATED:
+        Enable: true
         Volume: 1.0
         Pitch: 0.7
     SKILL_UNLOCKED:
+        Enable: true
         Volume: 1.0
         Pitch: 1.4
     DEFLECT_ARROWS:
+        Enable: true
         Volume: 1.0
         Pitch: 2.0
     TOOL_READY:
+        Enable: true
         Volume: 1.0
         Pitch: 0.4
     ABILITY_ACTIVATED_GENERIC:
+        Enable: true
         Volume: 1.0
         Pitch: 0.1
     ABILITY_ACTIVATED_BERSERK:
+        Enable: true
         Volume: 0.5
         Pitch: 1.7
     TIRED:
+        Enable: true
         Volume: 1.0
         Pitch: 1.7