nossr50 пре 6 година
родитељ
комит
6f3b90d0dd

+ 7 - 0
src/main/java/com/gmail/nossr50/config/ConfigManager.java

@@ -43,6 +43,7 @@ import com.gmail.nossr50.config.hocon.skills.swords.ConfigSwords;
 import com.gmail.nossr50.config.hocon.skills.taming.ConfigTaming;
 import com.gmail.nossr50.config.hocon.skills.taming.ConfigTaming;
 import com.gmail.nossr50.config.hocon.skills.unarmed.ConfigUnarmed;
 import com.gmail.nossr50.config.hocon.skills.unarmed.ConfigUnarmed;
 import com.gmail.nossr50.config.hocon.skills.woodcutting.ConfigWoodcutting;
 import com.gmail.nossr50.config.hocon.skills.woodcutting.ConfigWoodcutting;
+import com.gmail.nossr50.config.hocon.sound.ConfigSound;
 import com.gmail.nossr50.config.hocon.superabilities.ConfigSuperAbilities;
 import com.gmail.nossr50.config.hocon.superabilities.ConfigSuperAbilities;
 import com.gmail.nossr50.config.hocon.worldblacklist.ConfigWorldBlacklist;
 import com.gmail.nossr50.config.hocon.worldblacklist.ConfigWorldBlacklist;
 import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig;
 import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig;
@@ -106,6 +107,7 @@ public final class ConfigManager {
     private SerializedConfigLoader<ConfigCoreSkills> configCoreSkills;
     private SerializedConfigLoader<ConfigCoreSkills> configCoreSkills;
     private SerializedConfigLoader<ConfigEvent> configEvent;
     private SerializedConfigLoader<ConfigEvent> configEvent;
     private SerializedConfigLoader<ConfigRanks> configRanks;
     private SerializedConfigLoader<ConfigRanks> configRanks;
+    private SerializedConfigLoader<ConfigSound> configSound;
     private SerializedConfigLoader<ConfigNameRegisterDefaults> configDefaultExamples;
     private SerializedConfigLoader<ConfigNameRegisterDefaults> configDefaultExamples;
 
 
     private ConfigAcrobatics configAcrobatics;
     private ConfigAcrobatics configAcrobatics;
@@ -191,6 +193,7 @@ public final class ConfigManager {
         configCoreSkills = new SerializedConfigLoader<>(ConfigCoreSkills.class, "core_skills.conf", "Core-Skills", null);
         configCoreSkills = new SerializedConfigLoader<>(ConfigCoreSkills.class, "core_skills.conf", "Core-Skills", null);
         configEvent = new SerializedConfigLoader<>(ConfigEvent.class, "events.conf", "Events", null);
         configEvent = new SerializedConfigLoader<>(ConfigEvent.class, "events.conf", "Events", null);
         configRanks = new SerializedConfigLoader<>(ConfigRanks.class, "ranks.conf", "Skill-Ranks", null);
         configRanks = new SerializedConfigLoader<>(ConfigRanks.class, "ranks.conf", "Skill-Ranks", null);
+        configSound = new SerializedConfigLoader<>(ConfigSound.class, "sounds.conf", "Sounds", null);
 
 
         configDefaultExamples = new SerializedConfigLoader<>(ConfigNameRegisterDefaults.class, "minecraft_item_block_name_examples.conf", "Minecraft", null);
         configDefaultExamples = new SerializedConfigLoader<>(ConfigNameRegisterDefaults.class, "minecraft_item_block_name_examples.conf", "Minecraft", null);
         initSerializedSkillConfigs();
         initSerializedSkillConfigs();
@@ -497,6 +500,10 @@ public final class ConfigManager {
         return configRanks.getConfig();
         return configRanks.getConfig();
     }
     }
 
 
+    public ConfigSound getConfigSound() {
+        return configSound.getConfig();
+    }
+
     /**
     /**
      * Used to programmatically grab rank data for skills
      * Used to programmatically grab rank data for skills
      * @return root node for the ranks config file
      * @return root node for the ranks config file

+ 50 - 0
src/main/java/com/gmail/nossr50/config/hocon/sound/ConfigSound.java

@@ -0,0 +1,50 @@
+package com.gmail.nossr50.config.hocon.sound;
+
+import com.gmail.nossr50.util.sounds.SoundType;
+import ninja.leaping.configurate.objectmapping.Setting;
+import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
+
+import java.util.HashMap;
+
+@ConfigSerializable
+public class ConfigSound {
+
+    private static final HashMap<SoundType, SoundSetting> SOUND_SETTINGS_MAP_DEFAULT;
+    private static final double MASTER_VOLUME_DEFAULT = 1.0;
+
+    static {
+        SOUND_SETTINGS_MAP_DEFAULT = new HashMap<>();
+
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.ANVIL, new SoundSetting(1.0, 0.3));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.FIZZ, new SoundSetting(0.5));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.LEVEL_UP, new SoundSetting(.75, 0.5));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.ITEM_BREAK, new SoundSetting(1.0, 1.0));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.POP, new SoundSetting(1.0));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.CHIMAERA_WING, new SoundSetting(1.0, 0.6));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.ROLL_ACTIVATED, new SoundSetting(1.0, 0.7));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.SKILL_UNLOCKED, new SoundSetting(1.0, 1.4));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.DEFLECT_ARROWS, new SoundSetting(1.0, 2.0));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.TOOL_READY, new SoundSetting(1.0, 0.4));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.ABILITY_ACTIVATED_GENERIC, new SoundSetting(1.0, 0.1));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.ABILITY_ACTIVATED_BERSERK, new SoundSetting(0.5, 1.7));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.TIRED, new SoundSetting(1.0, 1.7));
+        SOUND_SETTINGS_MAP_DEFAULT.put(SoundType.BLEED, new SoundSetting(2.0, 2.0));
+    }
+
+    @Setting(value = "Sound-Settings", comment = "Adjust sound settings for various mcMMO sounds here." +
+            "\nSome sound settings such as pitch are ignored because mcMMO randomizes the pitch with certain sounds.")
+    private HashMap<SoundType, SoundSetting> soundSettingsHashMap = SOUND_SETTINGS_MAP_DEFAULT;
+
+    @Setting(value = "Master-Volume", comment = "All sound values are multiplied by this value to determine their final volume." +
+            "\nUse a range from 0.0 -> 1.0" +
+            "\nDefault Value: "+MASTER_VOLUME_DEFAULT)
+    private double masterVolume = MASTER_VOLUME_DEFAULT;
+
+    public double getMasterVolume() {
+        return masterVolume;
+    }
+
+    public SoundSetting getSoundSetting(SoundType soundType) {
+        return soundSettingsHashMap.get(soundType);
+    }
+}

+ 59 - 0
src/main/java/com/gmail/nossr50/config/hocon/sound/SoundSetting.java

@@ -0,0 +1,59 @@
+package com.gmail.nossr50.config.hocon.sound;
+
+public class SoundSetting {
+    private boolean enabled;
+    private double volume;
+    private double pitch;
+
+    public SoundSetting(boolean enabled) {
+        this.enabled = enabled;
+        volume = 0f;
+        pitch = 0f;
+    }
+
+    public SoundSetting(boolean enabled, double pitch) {
+        this.enabled = enabled;
+        this.volume = 1.0f;
+        this.pitch = pitch;
+    }
+
+    public SoundSetting(boolean enabled, double volume, double pitch) {
+        this.enabled = enabled;
+        this.volume = volume;
+        this.pitch = pitch;
+    }
+
+    public SoundSetting(double volume, double pitch) {
+        this.volume = volume;
+        this.pitch = pitch;
+    }
+
+    public SoundSetting(double volume) {
+        this.volume = volume;
+        this.pitch = 1.0F;
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+
+    public double getVolume() {
+        return volume;
+    }
+
+    public void setVolume(double volume) {
+        this.volume = volume;
+    }
+
+    public double getPitch() {
+        return pitch;
+    }
+
+    public void setPitch(double pitch) {
+        this.pitch = pitch;
+    }
+}