music plugin: add more area mute options

This adds an option to mute your own area sounds, sounds from npcs, and
sounds with no source.
This commit is contained in:
neeerp
2019-11-02 20:08:01 -04:00
committed by Adam
parent 4beb8766ab
commit fd3a235d7f
2 changed files with 53 additions and 3 deletions

View File

@@ -31,16 +31,50 @@ import net.runelite.client.config.ConfigItem;
@ConfigGroup("music")
public interface MusicConfig extends Config
{
@ConfigItem(
keyName = "muteOwnAreaSounds",
name = "Mute player area sounds",
description = "Mute area sounds caused by yourself",
position = 0
)
default boolean muteOwnAreaSounds()
{
return false;
}
@ConfigItem(
keyName = "muteOtherAreaSounds",
name = "Mute others' area sounds",
description = "Mute area sounds caused from other players"
name = "Mute other players' area sounds",
description = "Mute area sounds caused by other players",
position = 1
)
default boolean muteOtherAreaSounds()
{
return false;
}
@ConfigItem(
keyName = "muteOtherAreaNPCSounds",
name = "Mute NPCs' area sounds",
description = "Mute area sounds caused by NPCs",
position = 2
)
default boolean muteNpcAreaSounds()
{
return false;
}
@ConfigItem(
keyName = "muteOtherAreaEnvironmentSounds",
name = "Mute environment area sounds",
description = "Mute area sounds caused by neither NPCs nor players",
position = 3
)
default boolean muteEnvironmentAreaSounds()
{
return false;
}
@ConfigItem(
keyName = "musicVolume",
name = "",

View File

@@ -40,6 +40,7 @@ import lombok.Setter;
import net.runelite.api.Actor;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.NPC;
import net.runelite.api.Player;
import net.runelite.api.ScriptID;
import net.runelite.api.SoundEffectID;
@@ -557,11 +558,26 @@ public class MusicPlugin extends Plugin
public void onAreaSoundEffectPlayed(AreaSoundEffectPlayed areaSoundEffectPlayed)
{
Actor source = areaSoundEffectPlayed.getSource();
if (source != client.getLocalPlayer()
if (source == client.getLocalPlayer()
&& musicConfig.muteOwnAreaSounds())
{
areaSoundEffectPlayed.consume();
}
else if (source != client.getLocalPlayer()
&& source instanceof Player
&& musicConfig.muteOtherAreaSounds())
{
areaSoundEffectPlayed.consume();
}
else if (source instanceof NPC
&& musicConfig.muteNpcAreaSounds())
{
areaSoundEffectPlayed.consume();
}
else if (source == null
&& musicConfig.muteEnvironmentAreaSounds())
{
areaSoundEffectPlayed.consume();
}
}
}