Merge pull request #721 from devLotto/issue-471

notifier: add option to disable notification sounds
This commit is contained in:
Adam
2018-02-27 20:05:20 -05:00
committed by GitHub
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.ArrayList;
import java.util.List; import java.util.List;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.client.config.RuneLiteConfig;
@Slf4j @Slf4j
public class Notifier public class Notifier
@@ -79,14 +80,15 @@ public class Notifier
private final String appName; private final String appName;
private final TrayIcon trayIcon; 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.appName = appName;
this.trayIcon = trayIcon; this.trayIcon = trayIcon;
this.runeLiteConfig = runeliteConfig;
} }
public void notify(String message) public void notify(String message)
{ {
notify(message, TrayIcon.MessageType.NONE); notify(message, TrayIcon.MessageType.NONE);
@@ -95,7 +97,11 @@ public class Notifier
public void notify(String message, TrayIcon.MessageType type) public void notify(String message, TrayIcon.MessageType type)
{ {
sendNotification(appName, message, type, null); sendNotification(appName, message, type, null);
Toolkit.getDefaultToolkit().beep();
if (runeLiteConfig.enableNotificationSound())
{
Toolkit.getDefaultToolkit().beep();
}
} }
private void sendNotification( private void sendNotification(

View File

@@ -162,7 +162,7 @@ public class RuneLite
eventBus.register(pluginManager); eventBus.register(pluginManager);
// Setup the notifier // 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 // Tell the plugin manager if client is outdated or not
pluginManager.setOutdated(isOutdated); pluginManager.setOutdated(isOutdated);

View File

@@ -75,4 +75,14 @@ public interface RuneLiteConfig extends Config
{ {
return false; 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;
}
} }