2019-01-12 19:08:54 -08:00
|
|
|
package com.gmail.nossr50.config;
|
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2019-01-12 19:08:54 -08:00
|
|
|
import com.gmail.nossr50.util.sounds.SoundType;
|
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class SoundConfig extends ConfigValidated {
|
2019-02-17 08:59:09 -08:00
|
|
|
//private static SoundConfig instance;
|
2019-01-12 19:08:54 -08:00
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
public SoundConfig() {
|
|
|
|
//super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "sounds.yml", true);
|
2019-02-20 22:08:46 -08:00
|
|
|
super(mcMMO.p.getDataFolder().getAbsoluteFile(), "sounds.yml", true, true);
|
2019-01-12 19:08:54 -08:00
|
|
|
}
|
|
|
|
|
2019-02-17 11:32:53 -08:00
|
|
|
/**
|
|
|
|
* This grabs an instance of this config class from the Config Manager
|
|
|
|
* This method is deprecated and will be removed in the future
|
|
|
|
* @see mcMMO#getConfigManager()
|
|
|
|
* @return the instance of this config
|
|
|
|
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public static SoundConfig getInstance() {
|
|
|
|
return mcMMO.getConfigManager().getSoundConfig();
|
|
|
|
}
|
2019-01-12 19:08:54 -08:00
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
@Override
|
|
|
|
public void unload() {
|
2019-02-17 11:32:53 -08:00
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
}
|
2019-01-12 19:08:54 -08:00
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
/**
|
|
|
|
* The version of this config
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public double getConfigVersion() {
|
|
|
|
return 1;
|
2019-01-12 19:08:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-02-16 16:09:48 -08:00
|
|
|
public List<String> validateKeys() {
|
|
|
|
ArrayList<String> reasons = new ArrayList<>();
|
|
|
|
|
|
|
|
for (SoundType soundType : SoundType.values()) {
|
|
|
|
if (getDoubleValue("Sounds." + soundType.toString() + ".Volume") < 0) {
|
|
|
|
reasons.add("[mcMMO] Sound volume cannot be below 0 for " + soundType.toString());
|
2019-01-12 19:08:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
//Sounds with custom pitching don't use pitch values
|
2019-02-16 16:09:48 -08:00
|
|
|
if (!soundType.usesCustomPitch()) {
|
|
|
|
if (getDoubleValue("Sounds." + soundType.toString() + ".Pitch") < 0) {
|
|
|
|
reasons.add("[mcMMO] Sound pitch cannot be below 0 for " + soundType.toString());
|
2019-01-12 19:08:54 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-16 16:09:48 -08:00
|
|
|
|
|
|
|
return reasons;
|
2019-01-12 19:08:54 -08:00
|
|
|
}
|
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
public float getMasterVolume() {
|
|
|
|
return (float) getDoubleValue("Sounds.MasterVolume");
|
|
|
|
}
|
2019-01-12 19:08:54 -08:00
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
public float getVolume(SoundType soundType) {
|
|
|
|
String key = "Sounds." + soundType.toString() + ".Volume";
|
|
|
|
return (float) getDoubleValue(key);
|
2019-01-12 19:08:54 -08:00
|
|
|
}
|
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
public float getPitch(SoundType soundType) {
|
|
|
|
String key = "Sounds." + soundType.toString() + ".Pitch";
|
|
|
|
return (float) getDoubleValue(key);
|
2019-01-12 19:08:54 -08:00
|
|
|
}
|
2019-01-21 05:23:48 -08:00
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
public boolean getIsEnabled(SoundType soundType) {
|
|
|
|
String key = "Sounds." + soundType.toString() + ".Enabled";
|
|
|
|
return getBooleanValue(key, true);
|
2019-01-21 05:23:48 -08:00
|
|
|
}
|
2019-01-12 19:08:54 -08:00
|
|
|
}
|