Merge pull request #10752 from Trevor159/notification-event
client: add notification fired event
This commit is contained in:
@@ -64,6 +64,8 @@ import net.runelite.client.chat.ChatMessageManager;
|
||||
import net.runelite.client.chat.QueuedMessage;
|
||||
import net.runelite.client.config.FlashNotification;
|
||||
import net.runelite.client.config.RuneLiteConfig;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.events.NotificationFired;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.util.OSType;
|
||||
|
||||
@@ -107,6 +109,7 @@ public class Notifier
|
||||
private final ClientUI clientUI;
|
||||
private final ScheduledExecutorService executorService;
|
||||
private final ChatMessageManager chatMessageManager;
|
||||
private final EventBus eventBus;
|
||||
private final Path notifyIconPath;
|
||||
private final boolean terminalNotifierAvailable;
|
||||
private Instant flashStart;
|
||||
@@ -118,13 +121,15 @@ public class Notifier
|
||||
final Client client,
|
||||
final RuneLiteConfig runeliteConfig,
|
||||
final ScheduledExecutorService executorService,
|
||||
final ChatMessageManager chatMessageManager)
|
||||
final ChatMessageManager chatMessageManager,
|
||||
final EventBus eventBus)
|
||||
{
|
||||
this.client = client;
|
||||
this.clientUI = clientUI;
|
||||
this.runeLiteConfig = runeliteConfig;
|
||||
this.executorService = executorService;
|
||||
this.chatMessageManager = chatMessageManager;
|
||||
this.eventBus = eventBus;
|
||||
this.notifyIconPath = RuneLite.RUNELITE_DIR.toPath().resolve("icon.png");
|
||||
|
||||
// First check if we are running in launcher
|
||||
@@ -142,6 +147,8 @@ public class Notifier
|
||||
|
||||
public void notify(String message, TrayIcon.MessageType type)
|
||||
{
|
||||
eventBus.post(new NotificationFired(message, type));
|
||||
|
||||
if (!runeLiteConfig.sendNotificationsWhenFocused() && clientUI.isFocused())
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Trevor <https://github.com/Trevor159>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.events;
|
||||
|
||||
import java.awt.TrayIcon;
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class NotificationFired
|
||||
{
|
||||
final String message;
|
||||
final TrayIcon.MessageType type;
|
||||
}
|
||||
Reference in New Issue
Block a user