diff --git a/cluescroll/cluescroll.gradle.kts b/cluescroll/cluescroll.gradle.kts index dc627f9805..7f1e647111 100644 --- a/cluescroll/cluescroll.gradle.kts +++ b/cluescroll/cluescroll.gradle.kts @@ -23,7 +23,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -version = "0.0.24" +version = "0.0.25" project.extra["PluginName"] = "Clue Scroll" project.extra["PluginDescription"] = "Show answers to clue scroll riddles, anagrams, ciphers, and cryptic clues" diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollEmoteOverlay.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollEmoteOverlay.java index bf6c3d85d5..ecaa85b8ba 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollEmoteOverlay.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollEmoteOverlay.java @@ -27,7 +27,6 @@ import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; -import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; @@ -37,7 +36,6 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; -@Singleton class ClueScrollEmoteOverlay extends Overlay { private final ClueScrollPlugin plugin; @@ -46,7 +44,7 @@ class ClueScrollEmoteOverlay extends Overlay private boolean hasScrolled; @Inject - private ClueScrollEmoteOverlay(final ClueScrollPlugin plugin, final Client client) + private ClueScrollEmoteOverlay(ClueScrollPlugin plugin, Client client) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollMusicOverlay.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollMusicOverlay.java index 19e0b5b01e..2b44290fb5 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollMusicOverlay.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollMusicOverlay.java @@ -28,7 +28,6 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import javax.inject.Inject; -import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; @@ -38,7 +37,6 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; -@Singleton class ClueScrollMusicOverlay extends Overlay { private static final Rectangle PADDING = new Rectangle(2, 1, 0, 1); @@ -49,7 +47,7 @@ class ClueScrollMusicOverlay extends Overlay private boolean hasScrolled; @Inject - private ClueScrollMusicOverlay(final ClueScrollPlugin plugin, final Client client) + private ClueScrollMusicOverlay(ClueScrollPlugin plugin, Client client) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollOverlay.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollOverlay.java index 80032667c3..d8e425839f 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollOverlay.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollOverlay.java @@ -1,6 +1,7 @@ /* * Copyright (c) 2016-2017, Seth * Copyright (c) 2018, Lotto + * Copyright (c) 2019, David * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,7 +31,6 @@ import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; -import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Item; import static net.runelite.api.ItemID.*; @@ -47,7 +47,6 @@ import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.components.LineComponent; -@Singleton public class ClueScrollOverlay extends OverlayPanel { private static final ItemRequirement HAS_SPADE = new SingleItemRequirement(SPADE); @@ -81,7 +80,7 @@ public class ClueScrollOverlay extends OverlayPanel private final Client client; @Inject - private ClueScrollOverlay(final ClueScrollPlugin plugin, final Client client) + private ClueScrollOverlay(ClueScrollPlugin plugin, Client client) { super(plugin); this.plugin = plugin; @@ -117,8 +116,8 @@ public Dimension render(Graphics2D graphics) if (clue.isRequiresLight() && ((clue.getHasFirePit() == null || client.getVar(clue.getHasFirePit()) != 1) - && (inventoryItems == null || !HAS_LIGHT.fulfilledBy(inventoryItems)) - && (equippedItems == null || !HAS_LIGHT.fulfilledBy(equippedItems)))) + && (inventoryItems == null || !HAS_LIGHT.fulfilledBy(inventoryItems)) + && (equippedItems == null || !HAS_LIGHT.fulfilledBy(equippedItems)))) { panelComponent.getChildren().add(LineComponent.builder().left("").build()); panelComponent.getChildren().add(LineComponent.builder().left("Requires Light Source!").leftColor(Color.RED).build()); diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java index c80d2b617d..43d37360f3 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java @@ -43,8 +43,8 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.inject.Inject; +import javax.inject.Named; import joptsimple.internal.Strings; -import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; @@ -53,6 +53,7 @@ import net.runelite.api.GameState; import net.runelite.api.InventoryID; import net.runelite.api.Item; +import net.runelite.api.ItemContainer; import net.runelite.api.ItemDefinition; import net.runelite.api.ItemID; import net.runelite.api.MenuOpcode; @@ -124,7 +125,6 @@ import net.runelite.client.ui.overlay.components.TextComponent; import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager; import net.runelite.client.util.ImageUtil; -import net.runelite.client.util.ItemUtil; import org.apache.commons.lang3.ArrayUtils; import org.pf4j.Extension; @@ -148,28 +148,27 @@ public class ClueScrollPlugin extends Plugin 13150, 9011, 13151, 9012 }; - @Getter(AccessLevel.PUBLIC) + + @Getter + private ClueScroll clue; + + @Getter private final List npcsToMark = new ArrayList<>(); - @Getter(AccessLevel.PUBLIC) + @Getter private final List objectsToMark = new ArrayList<>(); - @Getter(AccessLevel.PUBLIC) + @Getter private final Set namedObjectsToMark = new HashSet<>(); - private final TextComponent textComponent = new TextComponent(); - - @Getter(AccessLevel.PACKAGE) - private ClueScroll clue; - - @Getter(AccessLevel.PUBLIC) + @Getter private Item[] equippedItems; - @Getter(AccessLevel.PUBLIC) + @Getter private Item[] inventoryItems; @Inject - @Getter(AccessLevel.PUBLIC) + @Getter private Client client; @Inject @@ -196,11 +195,14 @@ public class ClueScrollPlugin extends Plugin @Inject private WorldMapPointManager worldMapPointManager; + @Inject + @Named("developerMode") + boolean developerMode; + private BufferedImage emoteImage; private BufferedImage mapArrow; private Integer clueItemId; private boolean worldMapPointsSet = false; - private boolean displayHintArrows; // Some objects will only update to their "active" state when changing to their plane after varbit changes, // which take one extra tick to fire after the plane change. These fields are used to track those changes and delay @@ -208,30 +210,7 @@ public class ClueScrollPlugin extends Plugin private int currentPlane = -1; private boolean namedObjectCheckThisTick; - /** - * Translate a coordinate either between overworld and real, or real and overworld - * - * @param worldPoint - * @param toOverworld whether to convert to overworld coordinates, or to real coordinates - * @return - */ - public static WorldPoint getMirrorPoint(WorldPoint worldPoint, boolean toOverworld) - { - int region = worldPoint.getRegionID(); - for (int i = 0; i < REGION_MIRRORS.length; i += 2) - { - int real = REGION_MIRRORS[i]; - int overworld = REGION_MIRRORS[i + 1]; - - // Test against what we are converting from - if (region == (toOverworld ? real : overworld)) - { - return WorldPoint.fromRegion(toOverworld ? overworld : real, - worldPoint.getRegionX(), worldPoint.getRegionY(), worldPoint.getPlane()); - } - } - return worldPoint; - } + private final TextComponent textComponent = new TextComponent(); @Provides ClueScrollConfig getConfig(ConfigManager configManager) @@ -246,10 +225,8 @@ public void configure(Binder binder) } @Override - protected void startUp() + protected void startUp() throws Exception { - - this.displayHintArrows = config.displayHintArrows(); overlayManager.add(clueScrollOverlay); overlayManager.add(clueScrollEmoteOverlay); overlayManager.add(clueScrollWorldOverlay); @@ -257,7 +234,7 @@ protected void startUp() } @Override - protected void shutDown() + protected void shutDown() throws Exception { overlayManager.remove(clueScrollOverlay); overlayManager.remove(clueScrollEmoteOverlay); @@ -273,16 +250,19 @@ protected void shutDown() } @Subscribe - void onChatMessage(ChatMessage event) + public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.GAMEMESSAGE && event.getType() != ChatMessageType.SPAM) { return; } - if (clue instanceof HotColdClue && ((HotColdClue) clue).update(event.getMessage(), this)) + if (clue instanceof HotColdClue) { - worldMapPointsSet = false; + if (((HotColdClue) clue).update(event.getMessage(), this)) + { + worldMapPointsSet = false; + } } if (clue instanceof SkillChallengeClue) @@ -299,7 +279,7 @@ void onChatMessage(ChatMessage event) } @Subscribe - private void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked) + public void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked) { OverlayMenuEntry overlayMenuEntry = overlayMenuClicked.getEntry(); if (overlayMenuEntry.getMenuOpcode() == MenuOpcode.RUNELITE_OVERLAY @@ -311,22 +291,22 @@ private void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked) } @Subscribe - private void onMenuOptionClicked(final MenuOptionClicked event) + public void onMenuOptionClicked(final MenuOptionClicked event) { - if ("read".equalsIgnoreCase(event.getOption())) + if (event.getOption() != null && event.getOption().equals("Read")) { - final ItemDefinition itemComposition = itemManager.getItemDefinition(event.getIdentifier()); + final ItemDefinition itemDefinition = itemManager.getItemDefinition(event.getIdentifier()); - if (itemComposition != null && (itemComposition.getName().startsWith("Clue scroll") || itemComposition.getName().startsWith("Challenge scroll"))) + if (itemDefinition != null && (itemDefinition.getName().startsWith("Clue scroll") || itemDefinition.getName().startsWith("Challenge scroll"))) { - clueItemId = itemComposition.getId(); + clueItemId = itemDefinition.getId(); updateClue(MapClue.forItemId(clueItemId)); } } } @Subscribe - private void onItemContainerChanged(final ItemContainerChanged event) + public void onItemContainerChanged(final ItemContainerChanged event) { if (event.getItemContainer() == client.getItemContainer(InventoryID.EQUIPMENT)) { @@ -344,37 +324,42 @@ private void onItemContainerChanged(final ItemContainerChanged event) // Check if item was removed from inventory if (clue != null && clueItemId != null) { + ItemContainer itemContainer = event.getItemContainer(); + // Check if clue was removed from inventory - if (!ItemUtil.containsItemId(event.getItemContainer().getItems(), clueItemId)) + if (!itemContainer.contains(clueItemId)) { resetClue(true); } } // if three step clue check for clue scroll pieces - if (clue instanceof ThreeStepCrypticClue && ((ThreeStepCrypticClue) clue).update(client, event, itemManager)) + if (clue instanceof ThreeStepCrypticClue) { - worldMapPointsSet = false; - npcsToMark.clear(); - - if (this.displayHintArrows) + if (((ThreeStepCrypticClue) clue).update(event.getContainerId(), event.getItemContainer())) { - client.clearHintArrow(); - } + worldMapPointsSet = false; + npcsToMark.clear(); + + if (config.displayHintArrows()) + { + client.clearHintArrow(); + } - checkClueNPCs(clue, client.getCachedNPCs()); + checkClueNPCs(clue, client.getCachedNPCs()); + } } } @Subscribe - private void onNpcSpawned(final NpcSpawned event) + public void onNpcSpawned(final NpcSpawned event) { final NPC npc = event.getNpc(); checkClueNPCs(clue, npc); } @Subscribe - private void onNpcDespawned(final NpcDespawned event) + public void onNpcDespawned(final NpcDespawned event) { final boolean removed = npcsToMark.remove(event.getNpc()); @@ -481,29 +466,32 @@ private void tileObjectSpawnedHandler(final TileObject spawned) } @Subscribe - private void onConfigChanged(ConfigChanged event) + public void onConfigChanged(ConfigChanged event) { - if (event.getGroup().equals("cluescroll")) + if (event.getGroup().equals("cluescroll") && !config.displayHintArrows()) { - this.displayHintArrows = config.displayHintArrows(); - if (!this.displayHintArrows) - { - client.clearHintArrow(); - } + client.clearHintArrow(); } } @Subscribe - private void onGameStateChanged(final GameStateChanged event) + public void onGameStateChanged(final GameStateChanged event) { - if (event.getGameState() == GameState.LOGIN_SCREEN) + final GameState state = event.getGameState(); + + if (state != GameState.LOGGED_IN) + { + namedObjectsToMark.clear(); + } + + if (state == GameState.LOGIN_SCREEN) { resetClue(true); } } @Subscribe - void onGameTick(final GameTick event) + public void onGameTick(final GameTick event) { objectsToMark.clear(); @@ -536,19 +524,17 @@ void onGameTick(final GameTick event) if (clue instanceof LocationClueScroll) { final WorldPoint[] locations = ((LocationClueScroll) clue).getLocations(); + final boolean npcHintArrowMarked = client.getHintArrowNpc() != null && npcsToMark.contains(client.getHintArrowNpc()); - for (WorldPoint location : locations) + if (!npcHintArrowMarked) { - if (location == null) - { - continue; - } + client.clearHintArrow(); + } + for (WorldPoint location : locations) + { // Only set the location hint arrow if we do not already have more accurate location - if (location.isInScene(client) - && this.displayHintArrows - && (client.getHintArrowNpc() == null - || !npcsToMark.contains(client.getHintArrowNpc()))) + if (location.isInScene(client) && config.displayHintArrows() && !npcHintArrowMarked) { client.setHintArrow(location); } @@ -590,8 +576,6 @@ void onGameTick(final GameTick event) resetClue(true); } - // If we have a clue, save that knowledge - // so the clue window doesn't have to be open. final Widget clueScrollText = client.getWidget(WidgetInfo.CLUE_SCROLL_TEXT); if (clueScrollText != null) @@ -602,7 +586,7 @@ void onGameTick(final GameTick event) } @Subscribe - private void onWidgetLoaded(WidgetLoaded event) + public void onWidgetLoaded(WidgetLoaded event) { if (event.getGroupId() < WidgetID.BEGINNER_CLUE_MAP_CHAMPIONS_GUILD || event.getGroupId() > WidgetID.BEGINNER_CLUE_MAP_WIZARDS_TOWER) @@ -616,9 +600,10 @@ private void onWidgetLoaded(WidgetLoaded event) @Subscribe public void onCommandExecuted(CommandExecuted commandExecuted) { - if (commandExecuted.getCommand().equals("clue")) + if (developerMode && commandExecuted.getCommand().equals("clue")) { String text = Strings.join(commandExecuted.getArguments(), " "); + if (text.isEmpty()) { resetClue(true); @@ -684,7 +669,7 @@ private void resetClue(boolean withItemId) npcsToMark.clear(); namedObjectsToMark.clear(); - if (this.displayHintArrows) + if (config.displayHintArrows()) { client.clearHintArrow(); } @@ -696,9 +681,12 @@ private ClueScroll findClueScroll(String rawText) final String text = Text.sanitizeMultilineText(rawText).toLowerCase(); // Early return if this is same clue as already existing one - if (clue instanceof TextClueScroll && ((TextClueScroll) clue).getText().equalsIgnoreCase(text)) + if (clue instanceof TextClueScroll) { - return clue; + if (((TextClueScroll) clue).getText().equalsIgnoreCase(text)) + { + return clue; + } } if (text.startsWith("i'd like to hear some music.")) @@ -869,11 +857,6 @@ private void highlightObjectsForLocation(final WorldPoint location, final int... final Tile[][][] tiles = scene.getTiles(); final Tile tile = tiles[client.getPlane()][localLocation.getSceneX()][localLocation.getSceneY()]; - if (tile == null || tile.getGameObjects() == null) - { - return; - } - for (GameObject object : tile.getGameObjects()) { if (object == null) @@ -933,7 +916,7 @@ private void checkClueNPCs(ClueScroll clue, final NPC... npcs) } } - if (!npcsToMark.isEmpty() && this.displayHintArrows) + if (!npcsToMark.isEmpty() && config.displayHintArrows()) { // Always set hint arrow to first seen NPC client.setHintArrow(npcsToMark.get(0)); @@ -1105,4 +1088,29 @@ void scrollToWidget(WidgetInfo list, WidgetInfo scrollbar, Widget... toHighlight newScroll ); } -} + + /** + * Translate a coordinate either between overworld and real, or real and overworld + * + * @param worldPoint + * @param toOverworld whether to convert to overworld coordinates, or to real coordinates + * @return + */ + public static WorldPoint getMirrorPoint(WorldPoint worldPoint, boolean toOverworld) + { + int region = worldPoint.getRegionID(); + for (int i = 0; i < REGION_MIRRORS.length; i += 2) + { + int real = REGION_MIRRORS[i]; + int overworld = REGION_MIRRORS[i + 1]; + + // Test against what we are converting from + if (region == (toOverworld ? real : overworld)) + { + return WorldPoint.fromRegion(toOverworld ? overworld : real, + worldPoint.getRegionX(), worldPoint.getRegionY(), worldPoint.getPlane()); + } + } + return worldPoint; + } +} \ No newline at end of file diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollServiceImpl.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollServiceImpl.java index 53887d80c6..3dd2d55a33 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollServiceImpl.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollServiceImpl.java @@ -35,7 +35,7 @@ class ClueScrollServiceImpl implements ClueScrollService private final ClueScrollPlugin plugin; @Inject - private ClueScrollServiceImpl(final ClueScrollPlugin plugin) + private ClueScrollServiceImpl(ClueScrollPlugin plugin) { this.plugin = plugin; } diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java index 0ee530285c..45fa1f874c 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java @@ -36,7 +36,7 @@ class ClueScrollWorldMapPoint extends WorldMapPoint private final BufferedImage clueScrollWorldImage; private final Point clueScrollWorldImagePoint; - ClueScrollWorldMapPoint(final WorldPoint worldPoint, final ClueScrollPlugin plugin) + ClueScrollWorldMapPoint(final WorldPoint worldPoint, ClueScrollPlugin plugin) { super(worldPoint, null); diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldOverlay.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldOverlay.java index 0c4598043b..d68f06a691 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldOverlay.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldOverlay.java @@ -28,13 +28,11 @@ import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; -import javax.inject.Singleton; import net.runelite.client.plugins.cluescrolls.clues.ClueScroll; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; -@Singleton public class ClueScrollWorldOverlay extends Overlay { public static final int IMAGE_Z_OFFSET = 30; @@ -46,7 +44,7 @@ public class ClueScrollWorldOverlay extends Overlay private final ClueScrollPlugin plugin; @Inject - private ClueScrollWorldOverlay(final ClueScrollPlugin plugin) + private ClueScrollWorldOverlay(ClueScrollPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java index f8625cb3c7..0f0e4125be 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java @@ -189,11 +189,11 @@ public void makeOverlayHint(PanelComponent panelComponent, ClueScrollPlugin plug if (digLocations.size() > 10) { - for (Map.Entry locationCount : locationCounts.entrySet()) + for (HotColdArea area : locationCounts.keySet()) { panelComponent.getChildren().add(LineComponent.builder() - .left(locationCount.getKey().getName()) - .right(Integer.toString(locationCount.getValue())) + .left(area.getName()) + .right(Integer.toString(locationCounts.get(area))) .build()); } } @@ -213,6 +213,14 @@ public void makeOverlayHint(PanelComponent panelComponent, ClueScrollPlugin plug .left("- " + hotColdLocation.getArea()) .leftColor(Color.LIGHT_GRAY) .build()); + + if (digLocations.size() <= 5 && hotColdLocation.getEnemy() != null) + { + panelComponent.getChildren().add(LineComponent.builder() + .left(hotColdLocation.getEnemy().getText()) + .leftColor(Color.YELLOW) + .build()); + } } } } @@ -366,4 +374,4 @@ public String[] getNpcs() { return new String[]{npc}; } -} +} \ No newline at end of file diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/ThreeStepCrypticClue.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/ThreeStepCrypticClue.java index c5cf8289e7..3f92964e72 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/ThreeStepCrypticClue.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/ThreeStepCrypticClue.java @@ -28,30 +28,24 @@ import java.awt.Graphics2D; import java.util.AbstractMap; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.stream.Stream; -import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; -import net.runelite.api.Client; import net.runelite.api.InventoryID; -import net.runelite.api.Item; +import net.runelite.api.ItemContainer; import static net.runelite.api.ItemID.TORN_CLUE_SCROLL_PART_1; import static net.runelite.api.ItemID.TORN_CLUE_SCROLL_PART_2; import static net.runelite.api.ItemID.TORN_CLUE_SCROLL_PART_3; import net.runelite.api.coords.WorldPoint; -import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.util.Text; -import net.runelite.client.game.ItemManager; import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR; import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin; import net.runelite.client.ui.overlay.components.LineComponent; import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TitleComponent; -@Getter(AccessLevel.PUBLIC) +@Getter @RequiredArgsConstructor public class ThreeStepCrypticClue extends ClueScroll implements TextClueScroll, ObjectClueScroll, NpcClueScroll, LocationsClueScroll { @@ -123,26 +117,22 @@ public void makeWorldOverlayHint(Graphics2D graphics, ClueScrollPlugin plugin) } } - public boolean update(Client client, final ItemContainerChanged event, ItemManager itemManager) + public boolean update(int containerId, final ItemContainer itemContainer) { - if (event.getItemContainer() == client.getItemContainer(InventoryID.INVENTORY)) + if (containerId == InventoryID.INVENTORY.getId()) { - boolean success = false; - success |= checkForPart(event, itemManager, TORN_CLUE_SCROLL_PART_1, 0); - success |= checkForPart(event, itemManager, TORN_CLUE_SCROLL_PART_2, 1); - success |= checkForPart(event, itemManager, TORN_CLUE_SCROLL_PART_3, 2); - return success; + return checkForPart(itemContainer, TORN_CLUE_SCROLL_PART_1, 0) || + checkForPart(itemContainer, TORN_CLUE_SCROLL_PART_2, 1) || + checkForPart(itemContainer, TORN_CLUE_SCROLL_PART_3, 2); } return false; } - private boolean checkForPart(final ItemContainerChanged event, ItemManager itemManager, int clueScrollPart, int index) + private boolean checkForPart(final ItemContainer itemContainer, int clueScrollPart, int index) { - final Stream items = Arrays.stream(event.getItemContainer().getItems()); - // If we have the part then that step is done - if (items.anyMatch(item -> itemManager.getItemDefinition(item.getId()).getId() == clueScrollPart)) + if (itemContainer.contains(clueScrollPart)) { final Map.Entry entry = clueSteps.get(index); diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/AllRequirementsCollection.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/AllRequirementsCollection.java index bfe7a773ab..a9187bb5a0 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/AllRequirementsCollection.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/AllRequirementsCollection.java @@ -29,22 +29,22 @@ public class AllRequirementsCollection implements ItemRequirement { - private final String name; - private final ItemRequirement[] requirements; + private String name; + private ItemRequirement[] requirements; - public AllRequirementsCollection(final String name, final ItemRequirement... requirements) + public AllRequirementsCollection(String name, ItemRequirement... requirements) { this.name = name; this.requirements = requirements; } - public AllRequirementsCollection(final ItemRequirement... requirements) + public AllRequirementsCollection(ItemRequirement... requirements) { this("N/A", requirements); } @Override - public boolean fulfilledBy(final int itemId) + public boolean fulfilledBy(int itemId) { for (ItemRequirement requirement : requirements) { @@ -58,7 +58,7 @@ public boolean fulfilledBy(final int itemId) } @Override - public boolean fulfilledBy(final Item[] items) + public boolean fulfilledBy(Item[] items) { for (ItemRequirement requirement : requirements) { @@ -72,7 +72,7 @@ public boolean fulfilledBy(final Item[] items) } @Override - public String getCollectiveName(final Client client) + public String getCollectiveName(Client client) { return name; } diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/AnyRequirementCollection.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/AnyRequirementCollection.java index ae223285c5..886cf13f0c 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/AnyRequirementCollection.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/AnyRequirementCollection.java @@ -29,8 +29,8 @@ public class AnyRequirementCollection implements ItemRequirement { - private final String name; - private final ItemRequirement[] requirements; + private String name; + private ItemRequirement[] requirements; public AnyRequirementCollection(String name, ItemRequirement... requirements) { diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/MultipleOfItemRequirement.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/MultipleOfItemRequirement.java index 152840c027..f5e5905ab8 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/MultipleOfItemRequirement.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/MultipleOfItemRequirement.java @@ -30,8 +30,8 @@ public class MultipleOfItemRequirement implements ItemRequirement { - private final int itemId; - private final int quantity; + private int itemId; + private int quantity; public MultipleOfItemRequirement(int itemId, int quantity) { diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/RangeItemRequirement.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/RangeItemRequirement.java index ef81ced371..51a0d34f8b 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/RangeItemRequirement.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/RangeItemRequirement.java @@ -29,9 +29,9 @@ public class RangeItemRequirement implements ItemRequirement { - private final String name; - private final int startItemId; - private final int endItemId; + private String name; + private int startItemId; + private int endItemId; public RangeItemRequirement(String name, int startItemId, int endItemId) { diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/SingleItemRequirement.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/SingleItemRequirement.java index 7c1e02e6e0..e77e384fd6 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/SingleItemRequirement.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/SingleItemRequirement.java @@ -30,7 +30,7 @@ public class SingleItemRequirement implements ItemRequirement { - private final int itemId; + private int itemId; public SingleItemRequirement(int itemId) { diff --git a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/SlotLimitationRequirement.java b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/SlotLimitationRequirement.java index f52f0ee19d..604355c4f1 100644 --- a/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/SlotLimitationRequirement.java +++ b/cluescroll/src/main/java/net/runelite/client/plugins/cluescrolls/clues/item/SlotLimitationRequirement.java @@ -30,8 +30,8 @@ public class SlotLimitationRequirement implements ItemRequirement { - private final String description; - private final EquipmentInventorySlot[] slots; + private String description; + private EquipmentInventorySlot[] slots; public SlotLimitationRequirement(String description, EquipmentInventorySlot... slots) {