notifier: Add username to tray notification title

This also removes the player's ingame name from notifications which are
referring to the active player in favor of the title.
This commit is contained in:
Jordan Atwood
2021-02-06 17:19:40 -08:00
committed by Adam
parent fadfc15cd0
commit 0fa078d8f1
7 changed files with 41 additions and 36 deletions

View File

@@ -59,6 +59,7 @@ import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.Constants;
import net.runelite.api.GameState;
import net.runelite.api.Player;
import net.runelite.client.chat.ChatColorType;
import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager;
@@ -175,7 +176,7 @@ public class Notifier
if (runeLiteConfig.enableTrayNotifications())
{
sendNotification(appName, message, type);
sendNotification(buildTitle(), message, type);
}
switch (runeLiteConfig.notificationSound())
@@ -210,6 +211,23 @@ public class Notifier
log.debug(message);
}
private String buildTitle()
{
Player player = client.getLocalPlayer();
if (player == null)
{
return appName;
}
String name = player.getName();
if (Strings.isNullOrEmpty(name))
{
return appName;
}
return appName + " - " + name;
}
public void processFlash(final Graphics2D graphics)
{
FlashNotification flashNotification = runeLiteConfig.flashNotification();

View File

@@ -377,7 +377,7 @@ public class FishingPlugin extends Plugin
{
if (!trawlerNotificationSent)
{
notifier.notify("[" + client.getLocalPlayer().getName() + "] has low Fishing Trawler activity!");
notifier.notify("You have low Fishing Trawler activity!");
trawlerNotificationSent = true;
}
}

View File

@@ -59,7 +59,6 @@ import net.runelite.api.ItemContainer;
import net.runelite.api.ItemID;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.Player;
import net.runelite.api.Tile;
import net.runelite.api.TileItem;
import net.runelite.api.coords.WorldPoint;
@@ -643,11 +642,8 @@ public class GroundItemsPlugin extends Plugin
return;
}
final Player local = client.getLocalPlayer();
final StringBuilder notificationStringBuilder = new StringBuilder()
.append('[')
.append(local.getName())
.append("] received a ")
.append("You received a ")
.append(dropType)
.append(" drop: ")
.append(item.getName());

View File

@@ -438,64 +438,64 @@ public class IdleNotifierPlugin extends Plugin
if (config.logoutIdle() && checkIdleLogout())
{
notifier.notify("[" + local.getName() + "] is about to log out from idling too long!");
notifier.notify("You are about to log out from idling too long!");
}
if (check6hrLogout())
{
notifier.notify("[" + local.getName() + "] is about to log out from being online for 6 hours!");
notifier.notify("You are about to log out from being online for 6 hours!");
}
if (config.animationIdle() && checkAnimationIdle(waitDuration, local))
{
notifier.notify("[" + local.getName() + "] is now idle!");
notifier.notify("You are now idle!");
}
if (config.movementIdle() && checkMovementIdle(waitDuration, local))
{
notifier.notify("[" + local.getName() + "] has stopped moving!");
notifier.notify("You have stopped moving!");
}
if (config.interactionIdle() && checkInteractionIdle(waitDuration, local))
{
if (lastInteractWasCombat)
{
notifier.notify("[" + local.getName() + "] is now out of combat!");
notifier.notify("You are now out of combat!");
}
else
{
notifier.notify("[" + local.getName() + "] is now idle!");
notifier.notify("You are now idle!");
}
}
if (checkLowHitpoints())
{
notifier.notify("[" + local.getName() + "] has low hitpoints!");
notifier.notify("You have low hitpoints!");
}
if (checkLowPrayer())
{
notifier.notify("[" + local.getName() + "] has low prayer!");
notifier.notify("You have low prayer!");
}
if (checkLowEnergy())
{
notifier.notify("[" + local.getName() + "] has low run energy!");
notifier.notify("You have low run energy!");
}
if (checkHighEnergy())
{
notifier.notify("[" + local.getName() + "] has restored run energy!");
notifier.notify("You have restored run energy!");
}
if (checkLowOxygen())
{
notifier.notify("[" + local.getName() + "] has low oxygen!");
notifier.notify("You have low oxygen!");
}
if (checkFullSpecEnergy())
{
notifier.notify("[" + local.getName() + "] has restored spec energy!");
notifier.notify("You have restored spec energy!");
}
}

View File

@@ -166,7 +166,7 @@ public class RegenMeterPlugin extends Plugin
if (config.getNotifyBeforeHpRegenSeconds() > 0 && currentHP < maxHP && shouldNotifyHpRegenThisTick(ticksPerHPRegen))
{
notifier.notify("[" + client.getLocalPlayer().getName() + "] regenerates their next hitpoint soon!");
notifier.notify("Your next hitpoint will regenerate soon!");
}
}