2019-01-12 19:08:54 -08:00
|
|
|
package com.gmail.nossr50.config;
|
|
|
|
|
2021-04-09 10:19:34 -07:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2019-01-12 19:08:54 -08:00
|
|
|
import com.gmail.nossr50.util.sounds.SoundType;
|
|
|
|
|
2022-01-10 22:29:22 -08:00
|
|
|
public class SoundConfig extends BukkitConfig {
|
2019-01-12 19:08:54 -08:00
|
|
|
private static SoundConfig instance;
|
|
|
|
|
2022-01-10 22:29:22 -08:00
|
|
|
public SoundConfig() {
|
2019-01-12 19:08:54 -08:00
|
|
|
super("sounds.yml");
|
|
|
|
validate();
|
2020-07-13 11:39:03 -07:00
|
|
|
instance = this;
|
2019-01-12 19:08:54 -08:00
|
|
|
}
|
|
|
|
|
2022-01-10 22:29:22 -08:00
|
|
|
public static SoundConfig getInstance() {
|
|
|
|
if (instance == null)
|
|
|
|
return new SoundConfig();
|
2019-01-12 19:08:54 -08:00
|
|
|
|
2022-01-10 22:29:22 -08:00
|
|
|
return instance;
|
2019-01-12 19:08:54 -08:00
|
|
|
}
|
|
|
|
|
2022-01-10 22:29:22 -08:00
|
|
|
@Override
|
|
|
|
protected void loadKeys() {
|
2019-01-12 19:08:54 -08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean validateKeys() {
|
2022-01-10 22:29:22 -08:00
|
|
|
for (SoundType soundType : SoundType.values()) {
|
|
|
|
if (config.getDouble("Sounds." + soundType.toString() + ".Volume") < 0) {
|
|
|
|
mcMMO.p.getLogger().info("[mcMMO] Sound volume cannot be below 0 for " + soundType);
|
2019-01-12 19:08:54 -08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Sounds with custom pitching don't use pitch values
|
2022-01-10 22:29:22 -08:00
|
|
|
if (!soundType.usesCustomPitch()) {
|
|
|
|
if (config.getDouble("Sounds." + soundType + ".Pitch") < 0) {
|
|
|
|
mcMMO.p.getLogger().info("[mcMMO] Sound pitch cannot be below 0 for " + soundType);
|
2019-01-12 19:08:54 -08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-01-10 22:29:22 -08:00
|
|
|
public float getMasterVolume() {
|
|
|
|
return (float) config.getDouble("Sounds.MasterVolume", 1.0);
|
|
|
|
}
|
2019-01-12 19:08:54 -08:00
|
|
|
|
2022-01-10 22:29:22 -08:00
|
|
|
public float getVolume(SoundType soundType) {
|
|
|
|
String key = "Sounds." + soundType.toString() + ".Volume";
|
2019-01-12 19:08:54 -08:00
|
|
|
return (float) config.getDouble(key);
|
|
|
|
}
|
|
|
|
|
2022-01-10 22:29:22 -08:00
|
|
|
public float getPitch(SoundType soundType) {
|
|
|
|
String key = "Sounds." + soundType.toString() + ".Pitch";
|
2019-01-12 19:08:54 -08:00
|
|
|
return (float) config.getDouble(key);
|
|
|
|
}
|
2019-01-21 05:23:48 -08:00
|
|
|
|
2022-01-10 22:29:22 -08:00
|
|
|
public boolean getIsEnabled(SoundType soundType) {
|
|
|
|
String key = "Sounds." + soundType.toString() + ".Enabled";
|
2019-01-21 05:23:48 -08:00
|
|
|
return config.getBoolean(key, true);
|
|
|
|
}
|
2019-01-12 19:08:54 -08:00
|
|
|
}
|