notifier: add option to disable notification sounds
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user