notifier: add option to disable notification sounds

This commit is contained in:
Lotto
2018-02-27 14:09:44 +01:00
parent cc8e8f7006
commit 13b03a4710
3 changed files with 20 additions and 4 deletions

View File

@@ -32,6 +32,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.config.RuneLiteConfig;
@Slf4j
public class Notifier
@@ -79,14 +80,15 @@ public class Notifier
private final String appName;
private final TrayIcon trayIcon;
private final RuneLiteConfig runeLiteConfig;
Notifier(final String appName, final TrayIcon trayIcon)
Notifier(final String appName, final TrayIcon trayIcon, final RuneLiteConfig runeliteConfig)
{
this.appName = appName;
this.trayIcon = trayIcon;
this.runeLiteConfig = runeliteConfig;
}
public void notify(String message)
{
notify(message, TrayIcon.MessageType.NONE);
@@ -95,7 +97,11 @@ public class Notifier
public void notify(String message, TrayIcon.MessageType type)
{
sendNotification(appName, message, type, null);
Toolkit.getDefaultToolkit().beep();
if (runeLiteConfig.enableNotificationSound())
{
Toolkit.getDefaultToolkit().beep();
}
}
private void sendNotification(

View File

@@ -162,7 +162,7 @@ public class RuneLite
eventBus.register(pluginManager);
// Setup the notifier
notifier = new Notifier(properties.getTitle(), gui.getTrayIcon());
notifier = new Notifier(properties.getTitle(), gui.getTrayIcon(), runeliteConfig);
// Tell the plugin manager if client is outdated or not
pluginManager.setOutdated(isOutdated);

View File

@@ -75,4 +75,14 @@ public interface RuneLiteConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "notificationSound",
name = "Enable sound on notifications",
description = "Enables the playing of a beep sound when notifications are displayed"
)
default boolean enableNotificationSound()
{
return true;
}
}