mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-04-01 17:26:25 +02:00

Revert "Disabling mcMMO when the config breaks is dumb" This reverts commit 86e7bfbf89f027fec63730fa5a5da1884ed8a098. Revert "Config validation rewrite part 1" This reverts commit 16e90da8fdfe49741074294b9d7cc6438f6d27a2. Revert "Update changelog" This reverts commit 0ccd89fad4897b4a15e36437bed0d2f9b4ef7544.
65 lines
1.8 KiB
Java
65 lines
1.8 KiB
Java
package com.gmail.nossr50.config;
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
import com.gmail.nossr50.util.sounds.SoundType;
|
|
|
|
public class SoundConfig extends BukkitConfig {
|
|
private static SoundConfig instance;
|
|
|
|
public SoundConfig() {
|
|
super("sounds.yml");
|
|
validate();
|
|
instance = this;
|
|
}
|
|
|
|
public static SoundConfig getInstance() {
|
|
if (instance == null)
|
|
return new SoundConfig();
|
|
|
|
return instance;
|
|
}
|
|
|
|
@Override
|
|
protected void loadKeys() {
|
|
|
|
}
|
|
|
|
@Override
|
|
protected boolean validateKeys() {
|
|
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);
|
|
return false;
|
|
}
|
|
|
|
//Sounds with custom pitching don't use pitch values
|
|
if (!soundType.usesCustomPitch()) {
|
|
if (config.getDouble("Sounds." + soundType + ".Pitch") < 0) {
|
|
mcMMO.p.getLogger().info("[mcMMO] Sound pitch cannot be below 0 for " + soundType);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public float getMasterVolume() {
|
|
return (float) config.getDouble("Sounds.MasterVolume", 1.0);
|
|
}
|
|
|
|
public float getVolume(SoundType soundType) {
|
|
String key = "Sounds." + soundType.toString() + ".Volume";
|
|
return (float) config.getDouble(key);
|
|
}
|
|
|
|
public float getPitch(SoundType soundType) {
|
|
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);
|
|
}
|
|
}
|