From 6f3b90d0dd68e13793e8d91a673fad096128512f Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 13 Jun 2019 13:43:10 -0700 Subject: [PATCH] Sound Config --- .../gmail/nossr50/config/ConfigManager.java | 7 +++ .../config/hocon/sound/ConfigSound.java | 50 ++++++++++++++++ .../config/hocon/sound/SoundSetting.java | 59 +++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/sound/ConfigSound.java create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/sound/SoundSetting.java diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index ca030776e..ee62c2370 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/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.unarmed.ConfigUnarmed; 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.worldblacklist.ConfigWorldBlacklist; import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig; @@ -106,6 +107,7 @@ public final class ConfigManager { private SerializedConfigLoader configCoreSkills; private SerializedConfigLoader configEvent; private SerializedConfigLoader configRanks; + private SerializedConfigLoader configSound; private SerializedConfigLoader configDefaultExamples; private ConfigAcrobatics configAcrobatics; @@ -191,6 +193,7 @@ public final class ConfigManager { configCoreSkills = new SerializedConfigLoader<>(ConfigCoreSkills.class, "core_skills.conf", "Core-Skills", null); configEvent = new SerializedConfigLoader<>(ConfigEvent.class, "events.conf", "Events", 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); initSerializedSkillConfigs(); @@ -497,6 +500,10 @@ public final class ConfigManager { return configRanks.getConfig(); } + public ConfigSound getConfigSound() { + return configSound.getConfig(); + } + /** * Used to programmatically grab rank data for skills * @return root node for the ranks config file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/sound/ConfigSound.java b/src/main/java/com/gmail/nossr50/config/hocon/sound/ConfigSound.java new file mode 100644 index 000000000..106c00528 --- /dev/null +++ b/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 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 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); + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/sound/SoundSetting.java b/src/main/java/com/gmail/nossr50/config/hocon/sound/SoundSetting.java new file mode 100644 index 000000000..27e80c293 --- /dev/null +++ b/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; + } +} \ No newline at end of file