From 9b655588e6da6b6489021d6b30f6b1d328c17dd4 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 16 Jun 2022 13:22:24 -0400 Subject: [PATCH 01/12] xpglobes: add time to level to tooltip Co-authored-by: Shaun Dreclin --- .../plugins/xpglobes/XpGlobesConfig.java | 29 +++++++++++++------ .../plugins/xpglobes/XpGlobesOverlay.java | 10 +++++++ .../plugins/xptracker/XpStateSingle.java | 2 +- .../plugins/xptracker/XpTrackerService.java | 5 ++++ .../xptracker/XpTrackerServiceImpl.java | 6 ++++ 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesConfig.java index 2a956da851..1f93f0483f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesConfig.java @@ -78,11 +78,22 @@ public interface XpGlobesConfig extends Config return true; } + @ConfigItem( + keyName = "showTimeTilGoal", + name = "Show time til goal", + description = "Shows the amount of time until goal level in the globe tooltip box", + position = 4 + ) + default boolean showTimeTilGoal() + { + return true; + } + @ConfigItem( keyName = "hideMaxed", name = "Hide maxed skills", description = "Stop globes from showing up for level 99 skills", - position = 4 + position = 14 ) default boolean hideMaxed() { @@ -93,7 +104,7 @@ public interface XpGlobesConfig extends Config keyName = "showVirtualLevel", name = "Show virtual level", description = "Shows virtual level if over 99 in a skill and Hide maxed skill is not checked", - position = 5 + position = 15 ) default boolean showVirtualLevel() { @@ -104,7 +115,7 @@ public interface XpGlobesConfig extends Config keyName = "enableCustomArcColor", name = "Enable custom arc color", description = "Enables the custom coloring of the globe's arc instead of using the skill's default color.", - position = 6 + position = 16 ) default boolean enableCustomArcColor() { @@ -116,7 +127,7 @@ public interface XpGlobesConfig extends Config keyName = "Progress arc color", name = "Progress arc color", description = "Change the color of the progress arc in the xp orb", - position = 7 + position = 17 ) default Color progressArcColor() { @@ -128,7 +139,7 @@ public interface XpGlobesConfig extends Config keyName = "Progress orb outline color", name = "Progress orb outline color", description = "Change the color of the progress orb outline", - position = 8 + position = 18 ) default Color progressOrbOutLineColor() { @@ -140,7 +151,7 @@ public interface XpGlobesConfig extends Config keyName = "Progress orb background color", name = "Progress orb background color", description = "Change the color of the progress orb background", - position = 9 + position = 19 ) default Color progressOrbBackgroundColor() { @@ -151,7 +162,7 @@ public interface XpGlobesConfig extends Config keyName = "Progress arc width", name = "Progress arc width", description = "Change the stroke width of the progress arc", - position = 10 + position = 20 ) @Units(Units.PIXELS) default int progressArcStrokeWidth() @@ -163,7 +174,7 @@ public interface XpGlobesConfig extends Config keyName = "Orb size", name = "Size of orbs", description = "Change the size of the xp orbs", - position = 11 + position = 21 ) @Units(Units.PIXELS) default int xpOrbSize() @@ -175,7 +186,7 @@ public interface XpGlobesConfig extends Config keyName = "Orb duration", name = "Duration of orbs", description = "Change the duration the xp orbs are visible", - position = 12 + position = 22 ) @Units(Units.SECONDS) default int xpOrbDuration() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java index 1243c76712..abdc1998a7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java @@ -352,6 +352,16 @@ public class XpGlobesOverlay extends Overlay .build()); } } + + if (config.showTimeTilGoal()) + { + String timeLeft = xpTrackerService.getTimeTilGoal(mouseOverSkill.getSkill()); + xpTooltip.getChildren().add(LineComponent.builder() + .left("Time left:") + .leftColor(Color.ORANGE) + .right(timeLeft) + .build()); + } } tooltipManager.add(this.xpTooltip); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpStateSingle.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpStateSingle.java index cc58c69b55..c5a8226666 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpStateSingle.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpStateSingle.java @@ -204,7 +204,7 @@ class XpStateSingle // return time remaining in hh:mm:ss or mm:ss format where hh can be > 24 if (durationHoursTotal > 0) { - return String.format("%02d:%02d:%02d", durationHoursTotal, durationMinutes, durationSeconds); + return String.format("%d:%02d:%02d", durationHoursTotal, durationMinutes, durationSeconds); } // Minutes and seconds will always be present diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerService.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerService.java index f423757528..379aadf9d6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerService.java @@ -62,4 +62,9 @@ public interface XpTrackerService * Get the amount of XP left until goal level */ int getEndGoalXp(Skill skill); + + /** + * Get the amount of time left until goal level + */ + String getTimeTilGoal(Skill skill); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerServiceImpl.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerServiceImpl.java index 0968d14892..d10f410541 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerServiceImpl.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerServiceImpl.java @@ -80,4 +80,10 @@ class XpTrackerServiceImpl implements XpTrackerService { return plugin.getSkillSnapshot(skill).getEndGoalXp(); } + + @Override + public String getTimeTilGoal(Skill skill) + { + return plugin.getSkillSnapshot(skill).getTimeTillGoalShort(); + } } From 8e4d9c4a84614577ed77410d108d354d4a9f3c65 Mon Sep 17 00:00:00 2001 From: Cameron Hetzler Date: Thu, 16 Jun 2022 22:29:09 -0400 Subject: [PATCH 02/12] loottracker: reverse collapse all tooltips --- .../runelite/client/plugins/loottracker/LootTrackerPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java index 9b5cb7dd9b..b59afe8358 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java @@ -211,7 +211,7 @@ class LootTrackerPanel extends PluginPanel SwingUtil.removeButtonDecorations(collapseBtn); collapseBtn.setIcon(EXPAND_ICON); collapseBtn.setSelectedIcon(COLLAPSE_ICON); - SwingUtil.addModalTooltip(collapseBtn, "Collapse All", "Un-Collapse All"); + SwingUtil.addModalTooltip(collapseBtn, "Expand All", "Collapse All"); collapseBtn.setBackground(ColorScheme.DARKER_GRAY_COLOR); collapseBtn.setUI(new BasicButtonUI()); // substance breaks the layout collapseBtn.addActionListener(ev -> changeCollapse()); From 1d5bd756eaa3f0984729ae7bb9afde4cfa818a34 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 8 Jun 2022 11:20:07 -0400 Subject: [PATCH 03/12] corp plugin: add dark core attack deprioritization --- .../client/plugins/corp/CorpConfig.java | 11 ++++++++ .../client/plugins/corp/CorpPlugin.java | 26 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpConfig.java index f6c699e0e4..ea726525c8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpConfig.java @@ -33,6 +33,17 @@ public interface CorpConfig extends Config { String GROUP = "corp"; + @ConfigItem( + keyName = "leftClickCore", + name = "Left click walk on core", + description = "Prioritizes Walk here over Attack on the Dark energy core", + position = 1 + ) + default boolean leftClickCore() + { + return true; + } + @ConfigItem( keyName = "showDamage", name = "Show damage overlay", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java index dda20fd608..05a5afdf02 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java @@ -37,12 +37,15 @@ import net.runelite.api.Actor; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.GameState; +import net.runelite.api.MenuAction; +import net.runelite.api.MenuEntry; import net.runelite.api.NPC; import net.runelite.api.NpcID; import net.runelite.api.Varbits; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.HitsplatApplied; import net.runelite.api.events.InteractingChanged; +import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.VarbitChanged; @@ -66,6 +69,9 @@ import net.runelite.client.ui.overlay.OverlayManager; @Slf4j public class CorpPlugin extends Plugin { + private static final String ATTACK = "Attack"; + private static final String DARK_ENERGY_CORE = "Dark energy core"; + @Getter(AccessLevel.PACKAGE) private NPC corp; @@ -243,4 +249,24 @@ public class CorpPlugin extends Plugin } } } + + @Subscribe + public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) + { + final MenuEntry menuEntry = menuEntryAdded.getMenuEntry(); + final NPC npc = menuEntry.getNpc(); + if (npc == null || !DARK_ENERGY_CORE.equals(npc.getName())) + { + return; + } + + if (menuEntry.getType() != MenuAction.NPC_SECOND_OPTION + || !menuEntry.getOption().equals(ATTACK) + || !config.leftClickCore()) + { + return; + } + + menuEntry.setDeprioritized(true); + } } From bdb480ee6b466407555f76d4be4e9e27d879127f Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 Jun 2022 11:35:39 -0400 Subject: [PATCH 04/12] npc overlay: use true tile for south west tile --- .../client/game/npcoverlay/NpcOverlay.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/game/npcoverlay/NpcOverlay.java b/runelite-client/src/main/java/net/runelite/client/game/npcoverlay/NpcOverlay.java index 803c44fe26..3ed64c499b 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/npcoverlay/NpcOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/game/npcoverlay/NpcOverlay.java @@ -105,15 +105,12 @@ class NpcOverlay extends Overlay if (highlightedNpc.isSwTile()) { - int size = npcComposition.getSize(); - LocalPoint lp = actor.getLocalLocation(); - - int x = lp.getX() - ((size - 1) * Perspective.LOCAL_TILE_SIZE / 2); - int y = lp.getY() - ((size - 1) * Perspective.LOCAL_TILE_SIZE / 2); - - Polygon southWestTilePoly = Perspective.getCanvasTilePoly(client, new LocalPoint(x, y)); - - renderPoly(graphics, borderColor, borderWidth, fillColor, southWestTilePoly); + LocalPoint lp = LocalPoint.fromWorld(client, actor.getWorldLocation()); + if (lp != null) + { + Polygon tilePoly = Perspective.getCanvasTilePoly(client, lp); + renderPoly(graphics, borderColor, borderWidth, fillColor, tilePoly); + } } if (highlightedNpc.isOutline()) From ef6df76d7b42517e78e174a3627b555efbf28fd0 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 8 Jun 2022 11:26:52 -0400 Subject: [PATCH 05/12] menu swapper: remove Pickpocket block --- .../plugins/menuentryswapper/MenuEntrySwapperPlugin.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index d61486f27e..65ff8a39b9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -749,8 +749,7 @@ public class MenuEntrySwapperPlugin extends Plugin continue; } - if ("Pickpocket".equals(actions[actionIdx]) - || "Knock-Out".equals(actions[actionIdx]) + if ("Knock-Out".equals(actions[actionIdx]) || "Lure".equals(actions[actionIdx])) { // https://secure.runescape.com/m=news/another-message-about-unofficial-clients?oldschool=1 From 0a1a10cf1138a7a661d5fe77d0547aeaeafdaba7 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 8 Jun 2022 11:42:53 -0400 Subject: [PATCH 06/12] menu swapper: add option to remove dead npc menu options --- .../MenuEntrySwapperConfig.java | 11 +++++ .../MenuEntrySwapperPlugin.java | 48 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java index b88af6f997..00515d0367 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java @@ -878,4 +878,15 @@ public interface MenuEntrySwapperConfig extends Config { return false; } + + @ConfigItem( + keyName = "removeDeadNpcMenus", + name = "Remove dead npc menus", + description = "Remove menu options such as Attack and Talk-to from dead npcs", + section = npcSection + ) + default boolean removeDeadNpcMenus() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index 65ff8a39b9..b889f746b6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -54,6 +54,7 @@ import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; import net.runelite.api.NPC; import net.runelite.api.NPCComposition; +import net.runelite.api.NpcID; import net.runelite.api.ObjectComposition; import net.runelite.api.events.ClientTick; import net.runelite.api.events.MenuOpened; @@ -1038,6 +1039,53 @@ public class MenuEntrySwapperPlugin extends Plugin { swapMenuEntry(menuEntries, idx++, entry); } + + if (config.removeDeadNpcMenus()) + { + removeDeadNpcs(); + } + } + + private void removeDeadNpcs() + { + MenuEntry[] oldEntries = client.getMenuEntries(); + MenuEntry[] newEntries = Arrays.stream(oldEntries) + .filter(e -> + { + final NPC npc = e.getNpc(); + if (npc == null) + { + return true; + } + + final int id = npc.getId(); + switch (id) + { + // These NPCs hit 0hp but don't actually die + case NpcID.GARGOYLE: + case NpcID.GARGOYLE_413: + case NpcID.GARGOYLE_1543: + case NpcID.ZYGOMITE: + case NpcID.ZYGOMITE_1024: + case NpcID.ANCIENT_ZYGOMITE: + case NpcID.ROCKSLUG: + case NpcID.ROCKSLUG_422: + case NpcID.DESERT_LIZARD: + case NpcID.DESERT_LIZARD_460: + case NpcID.DESERT_LIZARD_461: + case NpcID.ICE_DEMON: + case NpcID.ICE_DEMON_7585: + return true; + default: + return !npc.isDead(); + + } + }) + .toArray(MenuEntry[]::new); + if (oldEntries.length != newEntries.length) + { + client.setMenuEntries(newEntries); + } } @Subscribe From c04b59722865cf2be47f8d3d258181f79dd411b9 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 8 Jun 2022 12:10:28 -0400 Subject: [PATCH 07/12] menu swapper: add npc walk here swap --- .../MenuEntrySwapperPlugin.java | 101 +++++++++++++----- 1 file changed, 74 insertions(+), 27 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index b889f746b6..6198232c3a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -41,6 +41,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Set; +import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; import javax.inject.Inject; @@ -100,6 +101,7 @@ public class MenuEntrySwapperPlugin extends Plugin private static final String ITEM_KEY_PREFIX = "item_"; private static final String OBJECT_KEY_PREFIX = "object_"; private static final String NPC_KEY_PREFIX = "npc_"; + private static final String NPC_SHIFT_KEY_PREFIX = "npc_shift_"; // Shift click private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE_SC = new WidgetMenuOption(CONFIGURE, @@ -702,6 +704,26 @@ public class MenuEntrySwapperPlugin extends Plugin } } + private Consumer walkHereConsumer(boolean shift, NPCComposition composition) + { + return e -> + { + final String message = new ChatMessageBuilder() + .append("The default ").append(shift ? "shift" : "left").append(" click option for '").append(Text.removeTags(composition.getName())).append("' ") + .append("has been set to Walk here.") + .build(); + + chatMessageManager.queue(QueuedMessage.builder() + .type(ChatMessageType.CONSOLE) + .runeLiteFormattedMessage(message) + .build()); + + log.debug("Set npc {} click swap for {} to Walk here", shift ? "shift" : "left", composition.getId()); + + setNpcSwapConfig(shift, composition.getId(), -1); + }; + } + private void configureNpcClick(MenuOpened event) { if (!shiftModifier() || !config.npcLeftClickCustomization()) @@ -722,16 +744,17 @@ public class MenuEntrySwapperPlugin extends Plugin final NPCComposition composition = npc.getTransformedComposition(); final String[] actions = composition.getActions(); - final Integer swapConfig = getNpcSwapConfig(composition.getId()); + final Integer swapConfig = getNpcSwapConfig(false, composition.getId()); final boolean hasAttack = Arrays.stream(composition.getActions()).anyMatch("Attack"::equalsIgnoreCase); - final MenuAction currentAction = swapConfig != null ? NPC_MENU_TYPES.get(swapConfig) : + final MenuAction currentAction = swapConfig == null ? // Attackable NPCs always have Attack as the first, last (deprioritized), or when hidden, no, option. // Due to this the default action would be either Attack or the first non-Attack option, based on // the game settings. Since it may be valid to swap an option up to override Attack, even when Attack // is left-click, we cannot assume any default currentAction on attackable NPCs. // Non-attackable NPCS have a predictable default action which we can prevent a swap to if no swap // config is set, which just avoids showing a Swap option on a 1-op NPC, which looks odd. - (hasAttack ? null : defaultAction(composition)); + (hasAttack ? null : defaultAction(composition)) : + (swapConfig == -1 ? MenuAction.WALK : NPC_MENU_TYPES.get(swapConfig)); for (int actionIdx = 0; actionIdx < NPC_MENU_TYPES.size(); ++actionIdx) { @@ -775,11 +798,24 @@ public class MenuEntrySwapperPlugin extends Plugin log.debug("Set npc swap for {} to {}", composition.getId(), menuAction); - setNpcSwapConfig(composition.getId(), menuIdx); + setNpcSwapConfig(false, composition.getId(), menuIdx); }); } - if (getNpcSwapConfig(composition.getId()) != null) + // Walk here swap + client.createMenuEntry(idx) + .setOption("Swap left click Walk here") + .setTarget(entry.getTarget()) + .setType(MenuAction.RUNELITE) + .onClick(walkHereConsumer(false, composition)); + + client.createMenuEntry(idx) + .setOption("Swap shift click Walk here") + .setTarget(entry.getTarget()) + .setType(MenuAction.RUNELITE) + .onClick(walkHereConsumer(true, composition)); + + if (getNpcSwapConfig(true, composition.getId()) != null || getNpcSwapConfig(false, composition.getId()) != null) { // Reset client.createMenuEntry(idx) @@ -789,8 +825,8 @@ public class MenuEntrySwapperPlugin extends Plugin .onClick(e -> { final String message = new ChatMessageBuilder() - .append("The default left click option for '").append(Text.removeTags(composition.getName())).append("' ") - .append("has been reset.") + .append("The default left and shift click options for '").append(Text.removeTags(composition.getName())).append("' ") + .append("have been reset.") .build(); chatMessageManager.queue(QueuedMessage.builder() @@ -799,7 +835,8 @@ public class MenuEntrySwapperPlugin extends Plugin .build()); log.debug("Unset npc swap for {}", composition.getId()); - unsetNpcSwapConfig(composition.getId()); + unsetNpcSwapConfig(true, composition.getId()); + unsetNpcSwapConfig(false, composition.getId()); }); } } @@ -971,24 +1008,33 @@ public class MenuEntrySwapperPlugin extends Plugin assert npc != null; final NPCComposition composition = npc.getTransformedComposition(); - Integer customOption = getNpcSwapConfig(composition.getId()); + Integer customOption = getNpcSwapConfig(shiftModifier(), composition.getId()); if (customOption != null) { - MenuAction swapAction = NPC_MENU_TYPES.get(customOption); - if (swapAction == menuAction) + // Walk here swap + if (customOption == -1) { - // Advance to the top-most op for this NPC. Normally menuEntries.length - 1 is examine, and swapping - // with that works due to it being sorted later, but if other plugins like NPC indicators add additional - // menus before examine that are also >1000, like RUNELITE menus, that would result in the >1000 menus being - // reordered relative to each other. - int i = index; - while (i < menuEntries.length - 1 && NPC_MENU_TYPES.contains(menuEntries[i + 1].getType())) + // we can achieve this by just deprioritizing the normal npc menus + menuEntry.setDeprioritized(true); + } + else + { + MenuAction swapAction = NPC_MENU_TYPES.get(customOption); + if (swapAction == menuAction) { - ++i; - } + // Advance to the top-most op for this NPC. Normally menuEntries.length - 1 is examine, and swapping + // with that works due to it being sorted later, but if other plugins like NPC indicators add additional + // menus before examine that are also >1000, like RUNELITE menus, that would result in the >1000 menus being + // reordered relative to each other. + int i = index; + while (i < menuEntries.length - 1 && NPC_MENU_TYPES.contains(menuEntries[i + 1].getType())) + { + ++i; + } - swap(optionIndexes, menuEntries, index, i); - return; + swap(optionIndexes, menuEntries, index, i); + return; + } } } } @@ -1315,9 +1361,10 @@ public class MenuEntrySwapperPlugin extends Plugin return null; } - private Integer getNpcSwapConfig(int npcId) + private Integer getNpcSwapConfig(boolean shift, int npcId) { - String config = configManager.getConfiguration(MenuEntrySwapperConfig.GROUP, NPC_KEY_PREFIX + npcId); + String config = configManager.getConfiguration(MenuEntrySwapperConfig.GROUP, + (shift ? NPC_SHIFT_KEY_PREFIX : NPC_KEY_PREFIX) + npcId); if (config == null || config.isEmpty()) { return null; @@ -1326,14 +1373,14 @@ public class MenuEntrySwapperPlugin extends Plugin return Integer.parseInt(config); } - private void setNpcSwapConfig(int npcId, int index) + private void setNpcSwapConfig(boolean shift, int npcId, int index) { - configManager.setConfiguration(MenuEntrySwapperConfig.GROUP, NPC_KEY_PREFIX + npcId, index); + configManager.setConfiguration(MenuEntrySwapperConfig.GROUP, (shift ? NPC_SHIFT_KEY_PREFIX : NPC_KEY_PREFIX) + npcId, index); } - private void unsetNpcSwapConfig(int npcId) + private void unsetNpcSwapConfig(boolean shift, int npcId) { - configManager.unsetConfiguration(MenuEntrySwapperConfig.GROUP, NPC_KEY_PREFIX + npcId); + configManager.unsetConfiguration(MenuEntrySwapperConfig.GROUP, (shift ? NPC_SHIFT_KEY_PREFIX : NPC_KEY_PREFIX) + npcId); } private static MenuAction defaultAction(NPCComposition composition) From acfb7c631da003805d9b41a249c519c3daa63ebf Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 8 Jun 2022 16:34:13 -0400 Subject: [PATCH 08/12] entity hider: add option to hide dead npcs --- .../client/plugins/entityhider/EntityHiderConfig.java | 11 +++++++++++ .../client/plugins/entityhider/EntityHiderPlugin.java | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderConfig.java index 139e3ef835..b554fd352d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderConfig.java @@ -176,4 +176,15 @@ public interface EntityHiderConfig extends Config { return false; } + + @ConfigItem( + position = 14, + keyName = "hideDeadNpcs", + name = "Hide Dead NPCs", + description = "Hides NPCs when their health reaches 0" + ) + default boolean hideDeadNpcs() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderPlugin.java index a8754571e4..ee63182d03 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderPlugin.java @@ -68,6 +68,7 @@ public class EntityHiderPlugin extends Plugin private boolean hideLocalPlayer2D; private boolean hideNPCs; private boolean hideNPCs2D; + private boolean hideDeadNpcs; private boolean hidePets; private boolean hideAttackers; private boolean hideProjectiles; @@ -118,6 +119,7 @@ public class EntityHiderPlugin extends Plugin hideNPCs = config.hideNPCs(); hideNPCs2D = config.hideNPCs2D(); + hideDeadNpcs = config.hideDeadNpcs(); hidePets = config.hidePets(); @@ -187,6 +189,12 @@ public class EntityHiderPlugin extends Plugin return !hidePets; } + // dead npcs can also be interacting so prioritize it over the interacting check + if (npc.isDead() && hideDeadNpcs) + { + return false; + } + if (npc.getInteracting() == client.getLocalPlayer()) { boolean b = hideAttackers; From 020acbffb67fe831a131132c2da15782735b0504 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 8 Jun 2022 17:08:36 -0400 Subject: [PATCH 09/12] menu swapper: add worn item swaps --- .../main/java/net/runelite/api/ParamID.java | 9 + .../MenuEntrySwapperPlugin.java | 166 ++++++++++++++++++ 2 files changed, 175 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/ParamID.java b/runelite-api/src/main/java/net/runelite/api/ParamID.java index d769a715ed..efe4225da7 100644 --- a/runelite-api/src/main/java/net/runelite/api/ParamID.java +++ b/runelite-api/src/main/java/net/runelite/api/ParamID.java @@ -50,4 +50,13 @@ public final class ParamID public static final int SETTING_SLIDER_IS_DRAGGABLE = 1108; public static final int SETTING_SLIDER_DEADZONE = 1109; public static final int SETTING_SLIDER_DEADTIME = 1110; + + public static final int OC_ITEM_OP1 = 451; + public static final int OC_ITEM_OP2 = 452; + public static final int OC_ITEM_OP3 = 453; + public static final int OC_ITEM_OP4 = 454; + public static final int OC_ITEM_OP5 = 455; + public static final int OC_ITEM_OP6 = 456; + public static final int OC_ITEM_OP7 = 457; + public static final int OC_ITEM_OP8 = 458; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index 6198232c3a..879fa76971 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -57,9 +57,11 @@ import net.runelite.api.NPC; import net.runelite.api.NPCComposition; import net.runelite.api.NpcID; import net.runelite.api.ObjectComposition; +import net.runelite.api.ParamID; import net.runelite.api.events.ClientTick; import net.runelite.api.events.MenuOpened; import net.runelite.api.events.PostItemComposition; +import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetID; import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.callback.ClientThread; @@ -102,6 +104,8 @@ public class MenuEntrySwapperPlugin extends Plugin private static final String OBJECT_KEY_PREFIX = "object_"; private static final String NPC_KEY_PREFIX = "npc_"; private static final String NPC_SHIFT_KEY_PREFIX = "npc_shift_"; + private static final String WORN_ITEM_KEY_PREFIX = "wornitem_"; + private static final String WORN_ITEM_SHIFT_KEY_PREFIX = "wornitem_shift_"; // Shift click private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE_SC = new WidgetMenuOption(CONFIGURE, @@ -515,6 +519,33 @@ public class MenuEntrySwapperPlugin extends Plugin configManager.unsetConfiguration(shift ? SHIFTCLICK_CONFIG_GROUP : MenuEntrySwapperConfig.GROUP, ITEM_KEY_PREFIX + itemId); } + private Integer getWornItemSwapConfig(boolean shift, int itemId) + { + itemId = ItemVariationMapping.map(itemId); + String config = configManager.getConfiguration(MenuEntrySwapperConfig.GROUP, + (shift ? WORN_ITEM_SHIFT_KEY_PREFIX : WORN_ITEM_KEY_PREFIX) + itemId); + if (config == null || config.isEmpty()) + { + return null; + } + + return Integer.parseInt(config); + } + + private void setWornItemSwapConfig(boolean shift, int itemId, int index) + { + itemId = ItemVariationMapping.map(itemId); + configManager.setConfiguration(MenuEntrySwapperConfig.GROUP, + (shift ? WORN_ITEM_SHIFT_KEY_PREFIX : WORN_ITEM_KEY_PREFIX) + itemId, index); + } + + private void unsetWornItemSwapConfig(boolean shift, int itemId) + { + itemId = ItemVariationMapping.map(itemId); + configManager.unsetConfiguration(MenuEntrySwapperConfig.GROUP, + (shift ? WORN_ITEM_SHIFT_KEY_PREFIX : WORN_ITEM_KEY_PREFIX) + itemId); + } + private void enableCustomization() { rebuildCustomizationMenus(); @@ -537,6 +568,7 @@ public class MenuEntrySwapperPlugin extends Plugin { configureObjectClick(event); configureNpcClick(event); + configureWornItems(event); return; } @@ -843,6 +875,121 @@ public class MenuEntrySwapperPlugin extends Plugin } } + private void configureWornItems(MenuOpened event) + { + if (!shiftModifier()) + { + return; + } + + final MenuEntry[] entries = event.getMenuEntries(); + for (int idx = entries.length - 1; idx >= 0; --idx) + { + final MenuEntry entry = entries[idx]; + Widget w = entry.getWidget(); + + if (w != null && WidgetInfo.TO_GROUP(w.getId()) == WidgetID.EQUIPMENT_GROUP_ID + && "Examine".equals(entry.getOption()) && entry.getIdentifier() == 10) + { + w = w.getChild(1); + if (w != null && w.getItemId() > -1) + { + final ItemComposition itemComposition = itemManager.getItemComposition(w.getItemId()); + final Integer leftClickOp = getWornItemSwapConfig(false, itemComposition.getId()); + final Integer shiftClickOp = getWornItemSwapConfig(true, itemComposition.getId()); + + for (int paramId = ParamID.OC_ITEM_OP1, opId = 2; paramId <= ParamID.OC_ITEM_OP8; ++paramId, ++opId) + { + final String opName = itemComposition.getStringValue(paramId); + if (!Strings.isNullOrEmpty(opName)) + { + if (leftClickOp == null || leftClickOp != opId) + { + client.createMenuEntry(idx) + .setOption("Swap left click " + opName) + .setTarget(entry.getTarget()) + .setType(MenuAction.RUNELITE) + .onClick(wornItemConsumer(itemComposition, opName, opId, false)); + } + if (shiftClickOp == null || shiftClickOp != opId) + { + client.createMenuEntry(idx) + .setOption("Swap shift click " + opName) + .setTarget(entry.getTarget()) + .setType(MenuAction.RUNELITE) + .onClick(wornItemConsumer(itemComposition, opName, opId, true)); + } + } + } + + if (leftClickOp != null) + { + client.createMenuEntry(idx) + .setOption("Reset swap left click") + .setTarget(entry.getTarget()) + .setType(MenuAction.RUNELITE) + .onClick(e -> + { + final String message = new ChatMessageBuilder() + .append("The default worn left click option for '").append(itemComposition.getName()).append("' ") + .append("has been reset.") + .build(); + + chatMessageManager.queue(QueuedMessage.builder() + .type(ChatMessageType.CONSOLE) + .runeLiteFormattedMessage(message) + .build()); + + log.debug("Unset worn item left swap for {}", itemComposition.getName()); + unsetWornItemSwapConfig(false, itemComposition.getId()); + }); + } + if (shiftClickOp != null) + { + client.createMenuEntry(idx) + .setOption("Reset swap shift click") + .setTarget(entry.getTarget()) + .setType(MenuAction.RUNELITE) + .onClick(e -> + { + final String message = new ChatMessageBuilder() + .append("The default worn shift click option for '").append(itemComposition.getName()).append("' ") + .append("has been reset.") + .build(); + + chatMessageManager.queue(QueuedMessage.builder() + .type(ChatMessageType.CONSOLE) + .runeLiteFormattedMessage(message) + .build()); + + log.debug("Unset worn item shift swap for {}", itemComposition.getName()); + unsetWornItemSwapConfig(true, itemComposition.getId()); + }); + } + } + } + } + } + + private Consumer wornItemConsumer(ItemComposition itemComposition, String opName, int opIdx, boolean shift) + { + return e -> + { + final String message = new ChatMessageBuilder() + .append("The default worn ").append(shift ? "shift" : "left").append(" click option for '").append(Text.removeTags(itemComposition.getName())).append("' ") + .append("has been set to '").append(opName).append("'.") + .build(); + + chatMessageManager.queue(QueuedMessage.builder() + .type(ChatMessageType.CONSOLE) + .runeLiteFormattedMessage(message) + .build()); + + log.debug("Set worn item {} swap for {} to {}", shift ? "shift" : "left", itemComposition.getName(), opIdx); + setWornItemSwapConfig(shift, itemComposition.getId(), opIdx); + }; + } + private boolean swapBank(MenuEntry menuEntry, MenuAction type) { if (type != MenuAction.CC_OP && type != MenuAction.CC_OP_LOW_PRIORITY) @@ -979,6 +1126,25 @@ public class MenuEntrySwapperPlugin extends Plugin } } + // Worn items swap + Widget w = menuEntry.getWidget(); + if (w != null && WidgetInfo.TO_GROUP(w.getId()) == WidgetID.EQUIPMENT_GROUP_ID) + { + w = w.getChild(1); + if (w != null && w.getItemId() > -1) + { + final Integer wornItemSwapConfig = getWornItemSwapConfig(shiftModifier(), w.getItemId()); + if (wornItemSwapConfig != null) + { + if (wornItemSwapConfig == menuEntry.getIdentifier()) + { + swap(optionIndexes, menuEntries, index, menuEntries.length - 1); + } + return; + } + } + } + if (OBJECT_MENU_TYPES.contains(menuAction)) { // Get multiloc id From 463a11da596eb8db981406d6b67801e3f030e2e9 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 17 Jun 2022 10:15:52 -0400 Subject: [PATCH 10/12] menu swapper: disable pmd check --- .../plugins/menuentryswapper/MenuEntrySwapperPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index 879fa76971..4efb4328a9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -774,6 +774,7 @@ public class MenuEntrySwapperPlugin extends Plugin final NPC npc = entry.getNpc(); assert npc != null; final NPCComposition composition = npc.getTransformedComposition(); + assert composition != null; final String[] actions = composition.getActions(); final Integer swapConfig = getNpcSwapConfig(false, composition.getId()); @@ -847,7 +848,7 @@ public class MenuEntrySwapperPlugin extends Plugin .setType(MenuAction.RUNELITE) .onClick(walkHereConsumer(true, composition)); - if (getNpcSwapConfig(true, composition.getId()) != null || getNpcSwapConfig(false, composition.getId()) != null) + if (getNpcSwapConfig(true, composition.getId()) != null || getNpcSwapConfig(false, composition.getId()) != null) // NOPMD: BrokenNullCheck { // Reset client.createMenuEntry(idx) From 06536ae815989ed023fe18e64962af119842fd52 Mon Sep 17 00:00:00 2001 From: RuneLite updater Date: Fri, 17 Jun 2022 14:27:23 +0000 Subject: [PATCH 11/12] Release 1.8.24 --- cache-client/pom.xml | 2 +- cache-updater/pom.xml | 2 +- cache/pom.xml | 2 +- pom.xml | 4 ++-- runelite-api/pom.xml | 2 +- runelite-client/pom.xml | 2 +- runelite-jshell/pom.xml | 2 +- runelite-script-assembler-plugin/pom.xml | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cache-client/pom.xml b/cache-client/pom.xml index 326fea1b33..c9b0d3a7cb 100644 --- a/cache-client/pom.xml +++ b/cache-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.8.24-SNAPSHOT + 1.8.24 cache-client diff --git a/cache-updater/pom.xml b/cache-updater/pom.xml index a2f587ca63..224329c60a 100644 --- a/cache-updater/pom.xml +++ b/cache-updater/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.8.24-SNAPSHOT + 1.8.24 Cache Updater diff --git a/cache/pom.xml b/cache/pom.xml index fdc883e94b..27d755efa9 100644 --- a/cache/pom.xml +++ b/cache/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.8.24-SNAPSHOT + 1.8.24 cache diff --git a/pom.xml b/pom.xml index ebad708caa..da47b1f34b 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.8.24-SNAPSHOT + 1.8.24 pom RuneLite @@ -63,7 +63,7 @@ https://github.com/runelite/runelite scm:git:git://github.com/runelite/runelite scm:git:git@github.com:runelite/runelite - HEAD + runelite-parent-1.8.24 diff --git a/runelite-api/pom.xml b/runelite-api/pom.xml index 6fd3650528..a24530e705 100644 --- a/runelite-api/pom.xml +++ b/runelite-api/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.8.24-SNAPSHOT + 1.8.24 runelite-api diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index 6b35a90611..a61ef616fe 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.8.24-SNAPSHOT + 1.8.24 client diff --git a/runelite-jshell/pom.xml b/runelite-jshell/pom.xml index 5083fe1588..e11653fc34 100644 --- a/runelite-jshell/pom.xml +++ b/runelite-jshell/pom.xml @@ -30,7 +30,7 @@ net.runelite runelite-parent - 1.8.24-SNAPSHOT + 1.8.24 jshell diff --git a/runelite-script-assembler-plugin/pom.xml b/runelite-script-assembler-plugin/pom.xml index eccd0ed7d6..6229574da4 100644 --- a/runelite-script-assembler-plugin/pom.xml +++ b/runelite-script-assembler-plugin/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.8.24-SNAPSHOT + 1.8.24 script-assembler-plugin From e3800badfb1a531efec2fc8a637d6f1aabfc4fcd Mon Sep 17 00:00:00 2001 From: RuneLite updater Date: Fri, 17 Jun 2022 14:27:27 +0000 Subject: [PATCH 12/12] Bump for 1.8.25-SNAPSHOT [ci skip] --- cache-client/pom.xml | 2 +- cache-updater/pom.xml | 2 +- cache/pom.xml | 2 +- pom.xml | 4 ++-- runelite-api/pom.xml | 2 +- runelite-client/pom.xml | 2 +- runelite-jshell/pom.xml | 2 +- runelite-script-assembler-plugin/pom.xml | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cache-client/pom.xml b/cache-client/pom.xml index c9b0d3a7cb..944c559487 100644 --- a/cache-client/pom.xml +++ b/cache-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.8.24 + 1.8.25-SNAPSHOT cache-client diff --git a/cache-updater/pom.xml b/cache-updater/pom.xml index 224329c60a..782b6c8465 100644 --- a/cache-updater/pom.xml +++ b/cache-updater/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.8.24 + 1.8.25-SNAPSHOT Cache Updater diff --git a/cache/pom.xml b/cache/pom.xml index 27d755efa9..fc691a1612 100644 --- a/cache/pom.xml +++ b/cache/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.8.24 + 1.8.25-SNAPSHOT cache diff --git a/pom.xml b/pom.xml index da47b1f34b..a85e344442 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.8.24 + 1.8.25-SNAPSHOT pom RuneLite @@ -63,7 +63,7 @@ https://github.com/runelite/runelite scm:git:git://github.com/runelite/runelite scm:git:git@github.com:runelite/runelite - runelite-parent-1.8.24 + HEAD diff --git a/runelite-api/pom.xml b/runelite-api/pom.xml index a24530e705..e358786a2c 100644 --- a/runelite-api/pom.xml +++ b/runelite-api/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.8.24 + 1.8.25-SNAPSHOT runelite-api diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index a61ef616fe..f2df804d8b 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.8.24 + 1.8.25-SNAPSHOT client diff --git a/runelite-jshell/pom.xml b/runelite-jshell/pom.xml index e11653fc34..ff3ad073f1 100644 --- a/runelite-jshell/pom.xml +++ b/runelite-jshell/pom.xml @@ -30,7 +30,7 @@ net.runelite runelite-parent - 1.8.24 + 1.8.25-SNAPSHOT jshell diff --git a/runelite-script-assembler-plugin/pom.xml b/runelite-script-assembler-plugin/pom.xml index 6229574da4..b0e5ef3dc1 100644 --- a/runelite-script-assembler-plugin/pom.xml +++ b/runelite-script-assembler-plugin/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.8.24 + 1.8.25-SNAPSHOT script-assembler-plugin