From ac547210f7e2e11ff8453b16965ba87aae292d4c Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 12 Jan 2022 14:30:19 -0500 Subject: [PATCH] ground items: fix show item quantities to work with no item highlight mode This also cleans up the telegrab highlighting code --- .../grounditems/GroundItemsPlugin.java | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) 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 25338d4285..01055a6d96 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 @@ -116,8 +116,6 @@ public class GroundItemsPlugin extends Plugin // ItemID for coins private static final int COINS = ItemID.COINS_995; - private static final String TELEGRAB_TEXT = ColorUtil.wrapWithColorTag("Telekinetic Grab", Color.GREEN) + ColorUtil.prependColorTag(" -> ", Color.WHITE); - @Getter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE) private Map.Entry textBoxBounds; @@ -481,14 +479,11 @@ public class GroundItemsPlugin extends Plugin @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { - if (config.itemHighlightMode() == ItemHighlightMode.MENU || config.itemHighlightMode() == ItemHighlightMode.BOTH) + MenuAction type = MenuAction.of(event.getType()); + if (type == MenuAction.GROUND_ITEM_FIRST_OPTION || type == MenuAction.GROUND_ITEM_SECOND_OPTION || + type == MenuAction.GROUND_ITEM_THIRD_OPTION || type == MenuAction.GROUND_ITEM_FOURTH_OPTION || + type == MenuAction.GROUND_ITEM_FIFTH_OPTION || type == MenuAction.SPELL_CAST_ON_GROUND_ITEM) { - final boolean telegrabEntry = event.getOption().equals("Cast") && event.getTarget().startsWith(TELEGRAB_TEXT) && event.getType() == MenuAction.SPELL_CAST_ON_GROUND_ITEM.getId(); - if (!(event.getOption().equals("Take") && event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId()) && !telegrabEntry) - { - return; - } - final int itemId = event.getIdentifier(); final int sceneX = event.getActionParam0(); final int sceneY = event.getActionParam1(); @@ -507,33 +502,24 @@ public class GroundItemsPlugin extends Plugin final Color color = getItemColor(highlighted, hidden); final boolean canBeRecolored = highlighted != null || (hidden != null && config.recolorMenuHiddenItems()); - if (color != null && canBeRecolored && !color.equals(config.defaultColor())) + if ((config.itemHighlightMode() == ItemHighlightMode.MENU || config.itemHighlightMode() == ItemHighlightMode.BOTH) && + (color != null && canBeRecolored && !color.equals(config.defaultColor()))) { final MenuHighlightMode mode = config.menuHighlightMode(); if (mode == BOTH || mode == OPTION) { - final String optionText = telegrabEntry ? "Cast" : "Take"; - lastEntry.setOption(ColorUtil.prependColorTag(optionText, color)); + lastEntry.setOption(ColorUtil.prependColorTag(lastEntry.getOption(), color)); } if (mode == BOTH || mode == NAME) { + // Logs + // Telekinetic Grab -> Logs String target = lastEntry.getTarget(); - if (telegrabEntry) - { - target = target.substring(TELEGRAB_TEXT.length()); - } - - target = ColorUtil.prependColorTag(target.substring(target.indexOf('>') + 1), color); - - if (telegrabEntry) - { - target = TELEGRAB_TEXT + target; - } - - lastEntry.setTarget(target); + int i = target.lastIndexOf('>'); + lastEntry.setTarget(target.substring(0, i - 11) + ColorUtil.colorTag(color) + target.substring(i + 1)); } }