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)
|
"\nDefault Value: "+MASTER_VOLUME_DEFAULT)
|
||||||
private double masterVolume = MASTER_VOLUME_DEFAULT;
|
private double masterVolume = MASTER_VOLUME_DEFAULT;
|
||||||
|
|
||||||
|
public boolean isSoundEnabled(SoundType soundType) {
|
||||||
|
return soundSettingsHashMap.get(soundType).isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
public double getMasterVolume() {
|
public double getMasterVolume() {
|
||||||
return masterVolume;
|
return masterVolume;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package com.gmail.nossr50.config.hocon.sound;
|
|||||||
|
|
||||||
public class SoundSetting {
|
public class SoundSetting {
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private double volume;
|
private float volume;
|
||||||
private double pitch;
|
private float pitch;
|
||||||
|
|
||||||
public SoundSetting(boolean enabled) {
|
public SoundSetting(boolean enabled) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
@ -14,22 +14,22 @@ public class SoundSetting {
|
|||||||
public SoundSetting(boolean enabled, double pitch) {
|
public SoundSetting(boolean enabled, double pitch) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.volume = 1.0f;
|
this.volume = 1.0f;
|
||||||
this.pitch = pitch;
|
this.pitch = (float) pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoundSetting(boolean enabled, double volume, double pitch) {
|
public SoundSetting(boolean enabled, double volume, double pitch) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.volume = volume;
|
this.volume = (float) volume;
|
||||||
this.pitch = pitch;
|
this.pitch = (float) pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoundSetting(double volume, double pitch) {
|
public SoundSetting(double volume, double pitch) {
|
||||||
this.volume = volume;
|
this.volume = (float) volume;
|
||||||
this.pitch = pitch;
|
this.pitch = (float) pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoundSetting(double volume) {
|
public SoundSetting(double volume) {
|
||||||
this.volume = volume;
|
this.volume = (float) volume;
|
||||||
this.pitch = 1.0F;
|
this.pitch = 1.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,19 +41,19 @@ public class SoundSetting {
|
|||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getVolume() {
|
public float getVolume() {
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVolume(double volume) {
|
public void setVolume(double volume) {
|
||||||
this.volume = volume;
|
this.volume = (float) volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPitch() {
|
public float getPitch() {
|
||||||
return pitch;
|
return pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPitch(double pitch) {
|
public void setPitch(double pitch) {
|
||||||
this.pitch = pitch;
|
this.pitch = (float) pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.util.sounds;
|
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 com.gmail.nossr50.util.Misc;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -15,24 +16,24 @@ public class SoundManager {
|
|||||||
* @param soundType the type of sound
|
* @param soundType the type of sound
|
||||||
*/
|
*/
|
||||||
public static void sendSound(Player player, Location location, SoundType soundType) {
|
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));
|
player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory) {
|
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));
|
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory, float pitchModifier) {
|
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory, float pitchModifier) {
|
||||||
float totalPitch = Math.min(2.0F, (getPitch(soundType) + 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);
|
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void worldSendSound(World world, Location location, SoundType soundType) {
|
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));
|
world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +44,8 @@ public class SoundManager {
|
|||||||
* @return the volume for this soundtype
|
* @return the volume for this soundtype
|
||||||
*/
|
*/
|
||||||
private static float getVolume(SoundType 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) {
|
private static float getPitch(SoundType soundType) {
|
||||||
@ -51,8 +53,10 @@ public class SoundManager {
|
|||||||
return getFizzPitch();
|
return getFizzPitch();
|
||||||
else if (soundType == SoundType.POP)
|
else if (soundType == SoundType.POP)
|
||||||
return getPopPitch();
|
return getPopPitch();
|
||||||
else
|
else {
|
||||||
return SoundConfig.getInstance().getPitch(soundType);
|
SoundSetting soundSetting = mcMMO.getConfigManager().getConfigSound().getSoundSetting(soundType);
|
||||||
|
return soundSetting.getPitch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Sound getSound(SoundType soundType) {
|
private static Sound getSound(SoundType soundType) {
|
||||||
|
Loading…
Reference in New Issue
Block a user