mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Wire up sound config
This commit is contained in:
parent
6f3b90d0dd
commit
86a4b74eb3
@ -40,6 +40,10 @@ public class ConfigSound {
|
||||
"\nDefault Value: "+MASTER_VOLUME_DEFAULT)
|
||||
private double masterVolume = MASTER_VOLUME_DEFAULT;
|
||||
|
||||
public boolean isSoundEnabled(SoundType soundType) {
|
||||
return soundSettingsHashMap.get(soundType).isEnabled();
|
||||
}
|
||||
|
||||
public double getMasterVolume() {
|
||||
return masterVolume;
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package com.gmail.nossr50.config.hocon.sound;
|
||||
|
||||
public class SoundSetting {
|
||||
private boolean enabled;
|
||||
private double volume;
|
||||
private double pitch;
|
||||
private float volume;
|
||||
private float pitch;
|
||||
|
||||
public SoundSetting(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
@ -14,22 +14,22 @@ public class SoundSetting {
|
||||
public SoundSetting(boolean enabled, double pitch) {
|
||||
this.enabled = enabled;
|
||||
this.volume = 1.0f;
|
||||
this.pitch = pitch;
|
||||
this.pitch = (float) pitch;
|
||||
}
|
||||
|
||||
public SoundSetting(boolean enabled, double volume, double pitch) {
|
||||
this.enabled = enabled;
|
||||
this.volume = volume;
|
||||
this.pitch = pitch;
|
||||
this.volume = (float) volume;
|
||||
this.pitch = (float) pitch;
|
||||
}
|
||||
|
||||
public SoundSetting(double volume, double pitch) {
|
||||
this.volume = volume;
|
||||
this.pitch = pitch;
|
||||
this.volume = (float) volume;
|
||||
this.pitch = (float) pitch;
|
||||
}
|
||||
|
||||
public SoundSetting(double volume) {
|
||||
this.volume = volume;
|
||||
this.volume = (float) volume;
|
||||
this.pitch = 1.0F;
|
||||
}
|
||||
|
||||
@ -41,19 +41,19 @@ public class SoundSetting {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public double getVolume() {
|
||||
public float getVolume() {
|
||||
return volume;
|
||||
}
|
||||
|
||||
public void setVolume(double volume) {
|
||||
this.volume = volume;
|
||||
this.volume = (float) volume;
|
||||
}
|
||||
|
||||
public double getPitch() {
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public void setPitch(double pitch) {
|
||||
this.pitch = pitch;
|
||||
this.pitch = (float) pitch;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.util.sounds;
|
||||
|
||||
import com.gmail.nossr50.config.SoundConfig;
|
||||
import com.gmail.nossr50.config.hocon.sound.SoundSetting;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
@ -15,24 +16,24 @@ public class SoundManager {
|
||||
* @param soundType the type of sound
|
||||
*/
|
||||
public static void sendSound(Player player, Location location, SoundType soundType) {
|
||||
if (SoundConfig.getInstance().getIsEnabled(soundType))
|
||||
if (mcMMO.getConfigManager().getConfigSound().isSoundEnabled(soundType))
|
||||
player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType));
|
||||
}
|
||||
|
||||
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory) {
|
||||
if (SoundConfig.getInstance().getIsEnabled(soundType))
|
||||
if (mcMMO.getConfigManager().getConfigSound().isSoundEnabled(soundType))
|
||||
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType));
|
||||
}
|
||||
|
||||
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory, float pitchModifier) {
|
||||
float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier));
|
||||
|
||||
if (SoundConfig.getInstance().getIsEnabled(soundType))
|
||||
if (mcMMO.getConfigManager().getConfigSound().isSoundEnabled(soundType))
|
||||
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch);
|
||||
}
|
||||
|
||||
public static void worldSendSound(World world, Location location, SoundType soundType) {
|
||||
if (SoundConfig.getInstance().getIsEnabled(soundType))
|
||||
if (mcMMO.getConfigManager().getConfigSound().isSoundEnabled(soundType))
|
||||
world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
|
||||
}
|
||||
|
||||
@ -43,7 +44,8 @@ public class SoundManager {
|
||||
* @return the volume for this soundtype
|
||||
*/
|
||||
private static float getVolume(SoundType soundType) {
|
||||
return SoundConfig.getInstance().getVolume(soundType) * SoundConfig.getInstance().getMasterVolume();
|
||||
SoundSetting soundSetting = mcMMO.getConfigManager().getConfigSound().getSoundSetting(soundType);
|
||||
return soundSetting.getVolume() * (float) mcMMO.getConfigManager().getConfigSound().getMasterVolume();
|
||||
}
|
||||
|
||||
private static float getPitch(SoundType soundType) {
|
||||
@ -51,8 +53,10 @@ public class SoundManager {
|
||||
return getFizzPitch();
|
||||
else if (soundType == SoundType.POP)
|
||||
return getPopPitch();
|
||||
else
|
||||
return SoundConfig.getInstance().getPitch(soundType);
|
||||
else {
|
||||
SoundSetting soundSetting = mcMMO.getConfigManager().getConfigSound().getSoundSetting(soundType);
|
||||
return soundSetting.getPitch();
|
||||
}
|
||||
}
|
||||
|
||||
private static Sound getSound(SoundType soundType) {
|
||||
|
Loading…
Reference in New Issue
Block a user