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:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,13 +109,7 @@ public class GroundItemsPluginTest
|
||||
return null;
|
||||
}).when(executor).execute(any(Runnable.class));
|
||||
|
||||
when(client.getLocalPlayer()).then(a ->
|
||||
{
|
||||
Player player = mock(Player.class);
|
||||
when(player.getName()).thenReturn("Adam");
|
||||
return player;
|
||||
});
|
||||
|
||||
when(client.getLocalPlayer()).thenReturn(mock(Player.class));
|
||||
when(config.getHiddenItems()).thenReturn("");
|
||||
}
|
||||
|
||||
@@ -149,6 +143,6 @@ public class GroundItemsPluginTest
|
||||
|
||||
groundItemsPlugin.onItemSpawned(new ItemSpawned(tile, tileItem));
|
||||
|
||||
verify(notifier).notify("[Adam] received a highlighted drop: Abyssal whip");
|
||||
verify(notifier).notify("You received a highlighted drop: Abyssal whip");
|
||||
}
|
||||
}
|
||||
@@ -62,8 +62,6 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class IdleNotifierPluginTest
|
||||
{
|
||||
private static final String PLAYER_NAME = "Deathbeam";
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
@@ -116,7 +114,6 @@ public class IdleNotifierPluginTest
|
||||
when(fishingSpot.getName()).thenReturn("Fishing spot");
|
||||
|
||||
// Mock player
|
||||
when(player.getName()).thenReturn(PLAYER_NAME);
|
||||
when(player.getAnimation()).thenReturn(AnimationID.IDLE);
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
@@ -145,7 +142,7 @@ public class IdleNotifierPluginTest
|
||||
when(player.getAnimation()).thenReturn(AnimationID.IDLE);
|
||||
plugin.onAnimationChanged(animationChanged);
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier).notify("[" + PLAYER_NAME + "] is now idle!");
|
||||
verify(notifier).notify("You are now idle!");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -201,7 +198,7 @@ public class IdleNotifierPluginTest
|
||||
when(player.getInteracting()).thenReturn(null);
|
||||
plugin.onInteractingChanged(new InteractingChanged(player, null));
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier).notify("[" + PLAYER_NAME + "] is now out of combat!");
|
||||
verify(notifier).notify("You are now out of combat!");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -292,7 +289,7 @@ public class IdleNotifierPluginTest
|
||||
plugin.onInteractingChanged(new InteractingChanged(player, null));
|
||||
plugin.onGameTick(new GameTick());
|
||||
|
||||
verify(notifier).notify("[" + PLAYER_NAME + "] is now idle!");
|
||||
verify(notifier).notify("You are now idle!");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -306,7 +303,7 @@ public class IdleNotifierPluginTest
|
||||
|
||||
when(client.getVar(eq(VarPlayer.SPECIAL_ATTACK_PERCENT))).thenReturn(500); // 50%
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier).notify(eq("[" + PLAYER_NAME + "] has restored spec energy!"));
|
||||
verify(notifier).notify(eq("You have restored spec energy!"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -321,6 +318,6 @@ public class IdleNotifierPluginTest
|
||||
// No movement here
|
||||
plugin.onGameTick(new GameTick());
|
||||
|
||||
verify(notifier).notify(eq("[" + PLAYER_NAME + "] has stopped moving!"));
|
||||
verify(notifier).notify(eq("You have stopped moving!"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user