Cannons

Cannons

117k Downloads

Feature Request - Customize Loudness of Sounds

hoorigan opened this issue ยท 2 comments

commented

Would it be possible to make the volume of the assorted cannon sounds customizable?

As the plugin is coded right now, it looks like the volume for all sounds is 15 until the player moves outside of the range specified in the "volume" setting, then it drops off to 0. Would it be possible to make that value adjustable? I've had complaints from players on my server that the cannons are too loud (as in, speakers and headsets crackling). The code I'm referencing is below.

public static void imitateSound(Location loc, SoundHolder sound, int maxDist)
    {
        //https://forums.bukkit.org/threads/playsound-parameters-volume-and-pitch.151517/
        World w = loc.getWorld();
        w.playSound(loc, sound.getSound(), 15F, sound.getPitch());
        for(Player p : w.getPlayers())
        {
            Location pl = p.getLocation();
            //readable code
            Vector v = loc.clone().subtract(pl).toVector();
            double d = v.length();
            if(d<=maxDist)
            {
                //float volume = 2.1f-(float)(d/maxDist);
                float newPitch = sound.getPitch()/(float) Math.sqrt(d);
                //p.playSound(p.getEyeLocation().add(v.normalize().multiply(16)), sound, volume, newPitch);
                p.playSound(loc, sound.getSound(), maxDist/16f, newPitch);
            }
        }
    }
commented

Sure that can be done. I will implement that as soon as possible.

Next time please leave a comment on dev.bukkit too.

commented

Awesome! I'll make sure to leave a comment there next time.

Vielen dank!