From 7ce518f29b61bb735fbc3e097acd94adca9c7e1d Mon Sep 17 00:00:00 2001 From: Marshall Date: Sun, 7 Oct 2018 14:28:31 -0700 Subject: [PATCH] Add highlighted ground item notifications (#3647) Add notification for highlighted item spawning on ground. Closes #3643 --- .../grounditems/GroundItemsConfig.java | 43 ++++++++++++------- .../grounditems/GroundItemsPlugin.java | 43 +++++++++++++++++++ 2 files changed, 70 insertions(+), 16 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java index ab10f5ea91..1a7f3dea5f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java @@ -127,11 +127,22 @@ public interface GroundItemsConfig extends Config return false; } + @ConfigItem( + keyName = "notifyHighlightedDrops", + name = "Notify for Highlighted drops", + description = "Configures whether or not to notify for drops on your highlighted list", + position = 7 + ) + default boolean notifyHighlightedDrops() + { + return false; + } + @ConfigItem( keyName = "priceDisplayMode", name = "Price Display Mode", description = "Configures what price types are shown alongside of ground item name", - position = 7 + position = 8 ) default PriceDisplayMode priceDisplayMode() { @@ -142,7 +153,7 @@ public interface GroundItemsConfig extends Config keyName = "itemHighlightMode", name = "Item Highlight Mode", description = "Configures how ground items will be highlighted", - position = 8 + position = 9 ) default ItemHighlightMode itemHighlightMode() { @@ -153,7 +164,7 @@ public interface GroundItemsConfig extends Config keyName = "menuHighlightMode", name = "Menu Highlight Mode", description = "Configures what to highlight in right-click menu", - position = 9 + position = 10 ) default MenuHighlightMode menuHighlightMode() { @@ -164,7 +175,7 @@ public interface GroundItemsConfig extends Config keyName = "highlightOverValue2", name = "Highlight > Value", description = "Configures highlighted ground items over either GE or HA value", - position = 10 + position = 11 ) default int getHighlightOverValue() { @@ -175,7 +186,7 @@ public interface GroundItemsConfig extends Config keyName = "hideUnderValue", name = "Hide < Value", description = "Configures hidden ground items under both GE and HA value", - position = 11 + position = 12 ) default int getHideUnderValue() { @@ -186,7 +197,7 @@ public interface GroundItemsConfig extends Config keyName = "defaultColor", name = "Default items color", description = "Configures the color for default, non-highlighted items", - position = 12 + position = 13 ) default Color defaultColor() { @@ -197,7 +208,7 @@ public interface GroundItemsConfig extends Config keyName = "highlightedColor", name = "Highlighted items color", description = "Configures the color for highlighted items", - position = 13 + position = 14 ) default Color highlightedColor() { @@ -208,7 +219,7 @@ public interface GroundItemsConfig extends Config keyName = "hiddenColor", name = "Hidden items color", description = "Configures the color for hidden items in right-click menu and when holding ALT", - position = 14 + position = 15 ) default Color hiddenColor() { @@ -219,7 +230,7 @@ public interface GroundItemsConfig extends Config keyName = "lowValueColor", name = "Low value items color", description = "Configures the color for low value items", - position = 15 + position = 16 ) default Color lowValueColor() { @@ -230,7 +241,7 @@ public interface GroundItemsConfig extends Config keyName = "lowValuePrice", name = "Low value price", description = "Configures the start price for low value items", - position = 16 + position = 17 ) default int lowValuePrice() { @@ -241,7 +252,7 @@ public interface GroundItemsConfig extends Config keyName = "mediumValueColor", name = "Medium value items color", description = "Configures the color for medium value items", - position = 17 + position = 18 ) default Color mediumValueColor() { @@ -252,7 +263,7 @@ public interface GroundItemsConfig extends Config keyName = "mediumValuePrice", name = "Medium value price", description = "Configures the start price for medium value items", - position = 18 + position = 19 ) default int mediumValuePrice() { @@ -263,7 +274,7 @@ public interface GroundItemsConfig extends Config keyName = "highValueColor", name = "High value items color", description = "Configures the color for high value items", - position = 19 + position = 20 ) default Color highValueColor() { @@ -274,7 +285,7 @@ public interface GroundItemsConfig extends Config keyName = "highValuePrice", name = "High value price", description = "Configures the start price for high value items", - position = 20 + position = 21 ) default int highValuePrice() { @@ -285,7 +296,7 @@ public interface GroundItemsConfig extends Config keyName = "insaneValueColor", name = "Insane value items color", description = "Configures the color for insane value items", - position = 21 + position = 22 ) default Color insaneValueColor() { @@ -296,7 +307,7 @@ public interface GroundItemsConfig extends Config keyName = "insaneValuePrice", name = "Insane value price", description = "Configures the start price for insane value items", - position = 22 + position = 23 ) default int insaneValuePrice() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index 42b4ab8583..1fb6a01af7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -54,6 +54,7 @@ import net.runelite.api.ItemLayer; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; import net.runelite.api.Node; +import net.runelite.api.Player; import net.runelite.api.Scene; import net.runelite.api.Tile; import net.runelite.api.events.ConfigChanged; @@ -63,6 +64,7 @@ import net.runelite.api.events.ItemDespawned; import net.runelite.api.events.ItemQuantityChanged; import net.runelite.api.events.ItemSpawned; import net.runelite.api.events.MenuEntryAdded; +import net.runelite.client.Notifier; import net.runelite.client.config.ConfigManager; import net.runelite.client.game.ItemManager; import net.runelite.client.input.KeyManager; @@ -76,6 +78,7 @@ import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.N import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.OPTION; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ColorUtil; +import net.runelite.client.util.StackFormatter; @PluginDescriptor( name = "Ground Items", @@ -138,6 +141,9 @@ public class GroundItemsPlugin extends Plugin @Inject private GroundItemsOverlay overlay; + @Inject + private Notifier notifier; + @Getter private final Map collectedGroundItems = new LinkedHashMap<>(); private final Map priceChecks = new LinkedHashMap<>(); @@ -206,6 +212,13 @@ public class GroundItemsPlugin extends Plugin { existing.setQuantity(existing.getQuantity() + groundItem.getQuantity()); } + + boolean isHighlighted = config.highlightedColor().equals(getHighlighted(groundItem.getName(), + groundItem.getGePrice(), groundItem.getHaPrice())); + if (config.notifyHighlightedDrops() && isHighlighted) + { + notifyHighlightedItem(groundItem); + } } @Subscribe @@ -484,4 +497,34 @@ public class GroundItemsPlugin extends Plugin setHotKeyPressed(false); } } + + private void notifyHighlightedItem(GroundItem item) + { + final Player local = client.getLocalPlayer(); + final StringBuilder notificationStringBuilder = new StringBuilder() + .append("[") + .append(local.getName()) + .append("] received a highlighted drop: ") + .append(item.getName()); + + if (item.getQuantity() > 1) + { + notificationStringBuilder.append(" x ").append(item.getQuantity()); + + + if (item.getQuantity() > (int) Character.MAX_VALUE) + { + notificationStringBuilder.append(" (Lots!)"); + } + else + { + notificationStringBuilder.append(" (") + .append(StackFormatter.quantityToStackSize(item.getQuantity())) + .append(")"); + } + } + + notificationStringBuilder.append("!"); + notifier.notify(notificationStringBuilder.toString()); + } }