From 72b1867382faab518624a098cfce010c163ac778 Mon Sep 17 00:00:00 2001 From: Nick Kroeger Date: Sat, 19 Jan 2019 17:35:32 -0500 Subject: [PATCH 1/3] Initial Mining Plugin (copy of mlm) --- .../client/plugins/mining/MiningPlugin.java | 429 ++++++++++++++++++ .../plugins/mining/MiningRocksOverlay.java | 133 ++++++ .../client/plugins/mining/MiningSession.java | 140 ++++++ .../plugins/mining/MotherlodeConfig.java | 114 +++++ .../plugins/mining/MotherlodeOverlay.java | 122 +++++ 5 files changed, 938 insertions(+) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningSession.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeConfig.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeOverlay.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java new file mode 100644 index 0000000000..cf7890d672 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java @@ -0,0 +1,429 @@ +/* + * Copyright (c) 2018, Seth + * Copyright (c) 2018, Adam + * Copyright (c) 2018, Lars + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.mining; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Provides; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.api.*; +import net.runelite.api.coords.LocalPoint; +import net.runelite.api.events.*; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; +import net.runelite.client.callback.ClientThread; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.motherlode.MotherlodeConfig; +import net.runelite.client.task.Schedule; +import net.runelite.client.ui.overlay.OverlayManager; + +import javax.inject.Inject; +import java.time.Duration; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.HashSet; +import java.util.Set; + +import static net.runelite.api.ObjectID.*; + +@PluginDescriptor( + name = "Motherlode Mine", + description = "Show helpful information inside the Motherload Mine", + tags = {"pay", "dirt", "mining", "mlm", "skilling", "overlay"}, + enabledByDefault = false +) +public class MiningPlugin extends Plugin +{ + private static final Set MOTHERLODE_MAP_REGIONS = ImmutableSet.of(14679, 14680, 14681, 14935, 14936, 14937, 15191, 15192, 15193); + private static final Set MINE_SPOTS = ImmutableSet.of(ORE_VEIN_26661, ORE_VEIN_26662, ORE_VEIN_26663, ORE_VEIN_26664); + private static final Set MLM_ORE_TYPES = ImmutableSet.of(ItemID.RUNITE_ORE, ItemID.ADAMANTITE_ORE, + ItemID.MITHRIL_ORE, ItemID.GOLD_ORE, ItemID.COAL, ItemID.GOLDEN_NUGGET); + private static final Set ROCK_OBSTACLES = ImmutableSet.of(ROCKFALL, ROCKFALL_26680); + + private static final int MAX_INVENTORY_SIZE = 28; + +// private static final int SACK_LARGE_SIZE = 162; +// private static final int SACK_SIZE = 81; +// +// private static final int UPPER_FLOOR_HEIGHT = -500; + + @Inject + private OverlayManager overlayManager; + + @Inject + private MotherlodeOverlay overlay; + + @Inject + private MiningRocksOverlay rocksOverlay; + + @Inject + private MotherlodeConfig config; + + @Inject + private Client client; + + @Inject + private ClientThread clientThread; + + @Getter(AccessLevel.PACKAGE) + private boolean inMlm; + + @Getter(AccessLevel.PACKAGE) + private int curSackSize; + @Getter(AccessLevel.PACKAGE) + private int maxSackSize; + @Getter(AccessLevel.PACKAGE) + private Integer depositsLeft; + + private MiningSession session; + + @Getter(AccessLevel.PACKAGE) + private final Set veins = new HashSet<>(); + @Getter(AccessLevel.PACKAGE) + private final Set rocks = new HashSet<>(); + + @Provides + MotherlodeConfig getConfig(ConfigManager configManager) + { + return configManager.getConfig(MotherlodeConfig.class); + } + + @Override + protected void startUp() + { + overlayManager.add(overlay); + overlayManager.add(rocksOverlay); +// overlayManager.add(motherlodeGemOverlay); +// overlayManager.add(motherlodeSackOverlay); + + session = new MiningSession(); + //inMlm = checkInMlm(); + +// if (inMlm) +// { +// clientThread.invokeLater(this::refreshSackValues); +// } + } + + @Override + protected void shutDown() throws Exception + { + overlayManager.remove(overlay); + overlayManager.remove(rocksOverlay); +// overlayManager.remove(motherlodeGemOverlay); +// overlayManager.remove(motherlodeSackOverlay); + session = null; +// veins.clear(); + rocks.clear(); + +// Widget sack = client.getWidget(WidgetInfo.MOTHERLODE_MINE); + +// clientThread.invokeLater(() -> +// { +// if (sack != null && sack.isHidden()) +// { +// sack.setHidden(false); +// } +// }); + } + + public MiningSession getSession() + { + return session; + } + +// @Subscribe +// public void onVarbitChanged(VarbitChanged event) +// { +// if (inMlm) +// { +// refreshSackValues(); +// } +// } + +// @Subscribe +// public void onChatMessage(ChatMessage event) +// { +// if (!inMlm || event.getType() != ChatMessageType.FILTERED) +// { +// return; +// } +// +// String chatMessage = event.getMessage(); +// +// switch (chatMessage) +// { +// case "You manage to mine some pay-dirt.": +// session.incrementPayDirtMined(); +// break; +// +// case "You just found a Diamond!": +// session.incrementGemFound(ItemID.UNCUT_DIAMOND); +// break; +// +// case "You just found a Ruby!": +// session.incrementGemFound(ItemID.UNCUT_RUBY); +// break; +// +// case "You just found an Emerald!": +// session.incrementGemFound(ItemID.UNCUT_EMERALD); +// break; +// +// case "You just found a Sapphire!": +// session.incrementGemFound(ItemID.UNCUT_SAPPHIRE); +// break; +// } +// } + + @Schedule( + period = 1, + unit = ChronoUnit.SECONDS + ) +// public void checkMining() +// { +// if (!inMlm) +// { +// return; +// } +// +// depositsLeft = calculateDepositsLeft(); +// +// Instant lastPayDirtMined = session.getLastPayDirtMined(); +// if (lastPayDirtMined == null) +// { +// return; +// } +// +// // reset recentPayDirtMined if you haven't mined anything recently +// Duration statTimeout = Duration.ofMinutes(config.statTimeout()); +// Duration sinceMined = Duration.between(lastPayDirtMined, Instant.now()); +// +// if (sinceMined.compareTo(statTimeout) >= 0) +// { +// session.resetRecent(); +// } +// } + +// @Subscribe +// public void onWallObjectSpawned(WallObjectSpawned event) +// { +// if (!inMlm) +// { +// return; +// } +// +// WallObject wallObject = event.getWallObject(); +// if (MINE_SPOTS.contains(wallObject.getId())) +// { +// veins.add(wallObject); +// } +// } +// +// @Subscribe +// public void onWallObjectChanged(WallObjectChanged event) +// { +// if (!inMlm) +// { +// return; +// } +// +// WallObject previous = event.getPrevious(); +// WallObject wallObject = event.getWallObject(); +// +// veins.remove(previous); +// if (MINE_SPOTS.contains(wallObject.getId())) +// { +// veins.add(wallObject); +// } +// } +// +// @Subscribe +// public void onWallObjectDespawned(WallObjectDespawned event) +// { +// if (!inMlm) +// { +// return; +// } +// +// WallObject wallObject = event.getWallObject(); +// veins.remove(wallObject); +// } + + @Subscribe + public void onGameObjectSpawned(GameObjectSpawned event) + { + if (!inMlm) + { + return; + } + + GameObject gameObject = event.getGameObject(); + if (ROCK_OBSTACLES.contains(gameObject.getId())) + { + rocks.add(gameObject); + } + } + +// @Subscribe +// public void onGameObjectChanged(GameObjectChanged event) +// { +// if (!inMlm) +// { +// return; +// } +// +// GameObject previous = event.getPrevious(); +// GameObject gameObject = event.getGameObject(); +// +// rocks.remove(previous); +// if (ROCK_OBSTACLES.contains(gameObject.getId())) +// { +// rocks.add(gameObject); +// } +// +// } +// +// @Subscribe +// public void onGameObjectDespawned(GameObjectDespawned event) +// { +// if (!inMlm) +// { +// return; +// } +// +// GameObject gameObject = event.getGameObject(); +// rocks.remove(gameObject); +// } + +// @Subscribe +// public void onGameStateChanged(GameStateChanged event) +// { +// if (event.getGameState() == GameState.LOADING) +// { +// // on region changes the tiles get set to null +// veins.clear(); +// rocks.clear(); +// } +// else if (event.getGameState() == GameState.LOGGED_IN) +// { +// inMlm = checkInMlm(); +// } +// else if (event.getGameState() == GameState.LOGIN_SCREEN) +// { +// // Prevent code from running while logged out. +// inMlm = false; +// } +// } + +// private Integer calculateDepositsLeft() +// { +// if (maxSackSize == 0) // check if maxSackSize has been initialized +// { +// refreshSackValues(); +// } +// +// double depositsLeft = 0; +// int nonPayDirtItems = 0; +// +// ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY); +// if (inventory == null) +// { +// return null; +// } +// +// Item[] result = inventory.getItems(); +// assert result != null; +// +// for (Item item : result) +// { +// // Assume that MLM ores are being banked and exclude them from the check, +// // so the user doesn't see the Overlay switch between deposits left and N/A. +// // +// // Count other items at nonPayDirtItems so depositsLeft is calculated accordingly. +// if (item.getId() != ItemID.PAYDIRT && item.getId() != -1 && !MLM_ORE_TYPES.contains(item.getId())) +// { +// nonPayDirtItems += 1; +// } +// } +// +// double inventorySpace = MAX_INVENTORY_SIZE - nonPayDirtItems; +// double sackSizeRemaining = maxSackSize - curSackSize; +// +// if (inventorySpace > 0 && sackSizeRemaining > 0) +// { +// depositsLeft = Math.ceil(sackSizeRemaining / inventorySpace); +// } +// else if (inventorySpace == 0) +// { +// return null; +// } +// +// return (int) depositsLeft; +// } +// +// private boolean checkInMlm() +// { +// if (client.getGameState() != GameState.LOGGED_IN) +// { +// return false; +// } +// +// int[] currentMapRegions = client.getMapRegions(); +// +// // Verify that all regions exist in MOTHERLODE_MAP_REGIONS +// for (int region : currentMapRegions) +// { +// if (!MOTHERLODE_MAP_REGIONS.contains(region)) +// { +// return false; +// } +// } +// +// return true; +// } +// +// private void refreshSackValues() +// { +// curSackSize = client.getVar(Varbits.SACK_NUMBER); +// boolean sackUpgraded = client.getVar(Varbits.SACK_UPGRADED) == 1; +// maxSackSize = sackUpgraded ? SACK_LARGE_SIZE : SACK_SIZE; +// } +// +// /** +// * Checks if the given point is "upstairs" in the mlm. +// * The upper floor is actually on z=0. +// * @param localPoint +// * @return +// */ +// boolean isUpstairs(LocalPoint localPoint) +// { +// return Perspective.getTileHeight(client, localPoint, 0) < UPPER_FLOOR_HEIGHT; +// } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java new file mode 100644 index 0000000000..ccc799a8a5 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2018, Seth + * Copyright (c) 2018, Adam + * Copyright (c) 2018, Lars + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.mining; + +import net.runelite.api.Point; +import net.runelite.api.*; +import net.runelite.api.coords.LocalPoint; +import net.runelite.client.game.SkillIconManager; +import net.runelite.client.plugins.motherlode.MotherlodeConfig; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayUtil; + +import javax.inject.Inject; +import java.awt.*; +import java.awt.image.BufferedImage; + +class MiningRocksOverlay extends Overlay +{ + private static final int MAX_DISTANCE = 2350; + + private final Client client; + private final MiningPlugin plugin; + private final MotherlodeConfig config; + + private final BufferedImage miningIcon; + + @Inject + MiningRocksOverlay(Client client, MiningPlugin plugin, MotherlodeConfig config, SkillIconManager iconManager) + { + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.ABOVE_SCENE); + this.client = client; + this.plugin = plugin; + this.config = config; + + miningIcon = iconManager.getSkillImage(Skill.MINING); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if ((!config.showVeins() && !config.showRockFalls()) || !plugin.isInMlm()) + { + return null; + } + + Player local = client.getLocalPlayer(); + + renderTiles(graphics, local); + + return null; + } + + private void renderTiles(Graphics2D graphics, Player local) + { + LocalPoint localLocation = local.getLocalLocation(); + +// if (config.showVeins()) +// { +// for (WallObject vein : plugin.getVeins()) +// { +// LocalPoint location = vein.getLocalLocation(); +// if (localLocation.distanceTo(location) <= MAX_DISTANCE) +// { +// // Only draw veins on the same level +// if (plugin.isUpstairs(localLocation) == plugin.isUpstairs(vein.getLocalLocation())) +// { +// renderVein(graphics, vein); +// } +// } +// } +// } + + if (config.showRockFalls()) + { + for (GameObject rock : plugin.getRocks()) + { + LocalPoint location = rock.getLocalLocation(); + if (localLocation.distanceTo(location) <= MAX_DISTANCE) + { + renderRock(graphics, rock); + } + } + } + + } + + private void renderVein(Graphics2D graphics, WallObject vein) + { + Point canvasLoc = Perspective.getCanvasImageLocation(client, vein.getLocalLocation(), miningIcon, 150); + + if (canvasLoc != null) + { + graphics.drawImage(miningIcon, canvasLoc.getX(), canvasLoc.getY(), null); + } + } + + private void renderRock(Graphics2D graphics, GameObject rock) + { + Polygon poly = Perspective.getCanvasTilePoly(client, rock.getLocalLocation()); + + if (poly != null) + { + OverlayUtil.renderPolygon(graphics, poly, Color.red); + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningSession.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningSession.java new file mode 100644 index 0000000000..890e2453b7 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningSession.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2018, Seth + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.mining; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.ItemID; + +import java.time.Duration; +import java.time.Instant; + +@Slf4j +public class MiningSession +{ + private static final Duration HOUR = Duration.ofHours(1); + + private int perHour; + + private Instant lastPayDirtMined; + private int totalMined; + + private Instant recentPayDirtMined; + private int recentMined; + + @Getter(AccessLevel.PACKAGE) + private Instant lastGemFound; + + @Getter(AccessLevel.PACKAGE) + private int diamondsFound; + + @Getter(AccessLevel.PACKAGE) + private int rubiesFound; + + @Getter(AccessLevel.PACKAGE) + private int emeraldsFound; + + @Getter(AccessLevel.PACKAGE) + private int sapphiresFound; + + public void incrementGemFound(int gemID) + { + lastGemFound = Instant.now(); + + switch (gemID) + { + case ItemID.UNCUT_DIAMOND: + diamondsFound++; + break; + + case ItemID.UNCUT_RUBY: + rubiesFound++; + break; + + case ItemID.UNCUT_EMERALD: + emeraldsFound++; + break; + + case ItemID.UNCUT_SAPPHIRE: + sapphiresFound++; + break; + + default: + log.error("Invalid gem type specified. The gem count will not be incremented."); + } + } + + public void incrementPayDirtMined() + { + Instant now = Instant.now(); + + lastPayDirtMined = now; + ++totalMined; + + if (recentMined == 0) + { + recentPayDirtMined = now; + } + ++recentMined; + + Duration timeSinceStart = Duration.between(recentPayDirtMined, now); + if (!timeSinceStart.isZero()) + { + perHour = (int) ((double) recentMined * (double) HOUR.toMillis() / (double) timeSinceStart.toMillis()); + } + } + + public void resetRecent() + { + recentPayDirtMined = null; + recentMined = 0; + } + + public int getPerHour() + { + return perHour; + } + + public Instant getLastPayDirtMined() + { + return lastPayDirtMined; + } + + public int getTotalMined() + { + return totalMined; + } + + public Instant getRecentPayDirtMined() + { + return recentPayDirtMined; + } + + public int getRecentMined() + { + return recentMined; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeConfig.java new file mode 100644 index 0000000000..57d2107f0c --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeConfig.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2018, Seth + * Copyright (c) 2018, Lars + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.mining; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("motherlode") +public interface MotherlodeConfig extends Config +{ + @ConfigItem( + keyName = "showVeins", + name = "Show pay-dirt mining spots", + description = "Configures whether or not the pay-dirt mining spots are displayed." + ) + default boolean showVeins() + { + return true; + } + + @ConfigItem( + keyName = "showRocks", + name = "Show rocks obstacles", + description = "Configures whether or not the fallen rocks obstacles are displayed." + ) + default boolean showRockFalls() + { + return true; + } + + @ConfigItem( + keyName = "statTimeout", + name = "Reset stats (minutes)", + description = "Configures the time until statistics are reset" + ) + default int statTimeout() + { + return 5; + } + + @ConfigItem( + keyName = "showSack", + name = "Show pay-dirt sack", + description = "Configures whether the pay-dirt sack is displayed or not." + ) + default boolean showSack() + { + return true; + } + + @ConfigItem( + keyName = "showMiningStats", + name = "Show mining session stats", + description = "Configures whether to display mining session stats" + ) + default boolean showMiningStats() + { + return true; + } + + @ConfigItem( + keyName = "showDepositsLeft", + name = "Show deposits left", + description = "Displays deposits left before sack is full" + ) + default boolean showDepositsLeft() + { + return true; + } + + @ConfigItem( + keyName = "showMiningState", + name = "Show current mining state", + description = "Shows current mining state. 'You are currently mining' / 'You are currently NOT mining'" + ) + default boolean showMiningState() + { + return true; + } + + @ConfigItem( + keyName = "showGemsFound", + name = "Show gems found", + description = "Shows gems found during current mining session" + ) + default boolean showGemsFound() + { + return true; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeOverlay.java new file mode 100644 index 0000000000..e0f3d9f3b0 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeOverlay.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2018, Seth + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.mining; + +import com.google.common.collect.ImmutableSet; +import net.runelite.api.Client; +import net.runelite.client.plugins.motherlode.MotherlodeConfig; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.components.LineComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; + +import javax.inject.Inject; +import java.awt.*; +import java.time.Duration; +import java.time.Instant; +import java.util.Set; + +import static net.runelite.api.AnimationID.*; + +class MotherlodeOverlay extends Overlay +{ + private static final Set MINING_ANIMATION_IDS = ImmutableSet.of( + MINING_MOTHERLODE_BRONZE, MINING_MOTHERLODE_IRON, MINING_MOTHERLODE_STEEL, + MINING_MOTHERLODE_BLACK, MINING_MOTHERLODE_MITHRIL, MINING_MOTHERLODE_ADAMANT, + MINING_MOTHERLODE_RUNE, MINING_MOTHERLODE_DRAGON, MINING_MOTHERLODE_DRAGON_ORN, + MINING_MOTHERLODE_INFERNAL + ); + + private final Client client; + private final MiningPlugin plugin; + private final MotherlodeConfig config; + private final PanelComponent panelComponent = new PanelComponent(); + + @Inject + MotherlodeOverlay(Client client, MiningPlugin plugin, MotherlodeConfig config) + { + setPosition(OverlayPosition.TOP_LEFT); + this.client = client; + this.plugin = plugin; + this.config = config; + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (!plugin.isInMlm() || !config.showMiningStats()) + { + return null; + } + + MiningSession session = plugin.getSession(); + + if (session.getLastPayDirtMined() == null) + { + return null; + } + + Duration statTimeout = Duration.ofMinutes(config.statTimeout()); + Duration sinceCut = Duration.between(session.getLastPayDirtMined(), Instant.now()); + + if (sinceCut.compareTo(statTimeout) >= 0) + { + return null; + } + + panelComponent.getChildren().clear(); + + if (config.showMiningState()) + { + if (MINING_ANIMATION_IDS.contains(client.getLocalPlayer().getAnimation())) + { + panelComponent.getChildren().add(TitleComponent.builder() + .text("Mining") + .color(Color.GREEN) + .build()); + } + else + { + panelComponent.getChildren().add(TitleComponent.builder() + .text("NOT mining") + .color(Color.RED) + .build()); + } + } + + panelComponent.getChildren().add(LineComponent.builder() + .left("Pay-dirt mined:") + .right(Integer.toString(session.getTotalMined())) + .build()); + + panelComponent.getChildren().add(LineComponent.builder() + .left("Pay-dirt/hr:") + .right(session.getRecentMined() > 2 ? Integer.toString(session.getPerHour()) : "") + .build()); + + return panelComponent.render(graphics); + } +} From 7d3574a9fb04769317de2f52de3508642f8b30d0 Mon Sep 17 00:00:00 2001 From: Nick Kroeger Date: Sat, 19 Jan 2019 22:59:44 -0500 Subject: [PATCH 2/3] Refactored Motherlode to Mining plugin, tried, but failed to render squares and mining icons. --- ...otherlodeConfig.java => MiningConfig.java} | 50 ++--------- ...herlodeOverlay.java => MiningOverlay.java} | 8 +- .../client/plugins/mining/MiningPlugin.java | 90 ++++++++----------- .../plugins/mining/MiningRocksOverlay.java | 45 +++------- .../plugins/motherlode/MotherlodePlugin.java | 1 + .../motherlode/MotherlodeRocksOverlay.java | 1 + 6 files changed, 63 insertions(+), 132 deletions(-) rename runelite-client/src/main/java/net/runelite/client/plugins/mining/{MotherlodeConfig.java => MiningConfig.java} (68%) rename runelite-client/src/main/java/net/runelite/client/plugins/mining/{MotherlodeOverlay.java => MiningOverlay.java} (94%) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningConfig.java similarity index 68% rename from runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeConfig.java rename to runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningConfig.java index 57d2107f0c..910cff8289 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningConfig.java @@ -29,28 +29,19 @@ import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -@ConfigGroup("motherlode") -public interface MotherlodeConfig extends Config +@ConfigGroup("mining") +public interface MiningConfig extends Config { @ConfigItem( - keyName = "showVeins", - name = "Show pay-dirt mining spots", - description = "Configures whether or not the pay-dirt mining spots are displayed." + keyName = "showMiningRocks", + name = "Show rock mining spots", + description = "Configures whether or not the mining spots are displayed." ) - default boolean showVeins() + default boolean showMiningRocks() { return true; } - @ConfigItem( - keyName = "showRocks", - name = "Show rocks obstacles", - description = "Configures whether or not the fallen rocks obstacles are displayed." - ) - default boolean showRockFalls() - { - return true; - } @ConfigItem( keyName = "statTimeout", @@ -62,16 +53,6 @@ public interface MotherlodeConfig extends Config return 5; } - @ConfigItem( - keyName = "showSack", - name = "Show pay-dirt sack", - description = "Configures whether the pay-dirt sack is displayed or not." - ) - default boolean showSack() - { - return true; - } - @ConfigItem( keyName = "showMiningStats", name = "Show mining session stats", @@ -82,15 +63,6 @@ public interface MotherlodeConfig extends Config return true; } - @ConfigItem( - keyName = "showDepositsLeft", - name = "Show deposits left", - description = "Displays deposits left before sack is full" - ) - default boolean showDepositsLeft() - { - return true; - } @ConfigItem( keyName = "showMiningState", @@ -101,14 +73,4 @@ public interface MotherlodeConfig extends Config { return true; } - - @ConfigItem( - keyName = "showGemsFound", - name = "Show gems found", - description = "Shows gems found during current mining session" - ) - default boolean showGemsFound() - { - return true; - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java similarity index 94% rename from runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeOverlay.java rename to runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java index e0f3d9f3b0..55a4997509 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MotherlodeOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java @@ -26,7 +26,7 @@ package net.runelite.client.plugins.mining; import com.google.common.collect.ImmutableSet; import net.runelite.api.Client; -import net.runelite.client.plugins.motherlode.MotherlodeConfig; +import net.runelite.client.plugins.mining.MiningConfig; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.LineComponent; @@ -41,7 +41,7 @@ import java.util.Set; import static net.runelite.api.AnimationID.*; -class MotherlodeOverlay extends Overlay +class MiningOverlay extends Overlay { private static final Set MINING_ANIMATION_IDS = ImmutableSet.of( MINING_MOTHERLODE_BRONZE, MINING_MOTHERLODE_IRON, MINING_MOTHERLODE_STEEL, @@ -52,11 +52,11 @@ class MotherlodeOverlay extends Overlay private final Client client; private final MiningPlugin plugin; - private final MotherlodeConfig config; + private final MiningConfig config; private final PanelComponent panelComponent = new PanelComponent(); @Inject - MotherlodeOverlay(Client client, MiningPlugin plugin, MotherlodeConfig config) + MiningOverlay(Client client, MiningPlugin plugin, MiningConfig config) { setPosition(OverlayPosition.TOP_LEFT); this.client = client; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java index cf7890d672..e4f5363b1d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java @@ -31,22 +31,17 @@ import com.google.inject.Provides; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.*; -import net.runelite.api.coords.LocalPoint; import net.runelite.api.events.*; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.motherlode.MotherlodeConfig; +import net.runelite.client.plugins.mining.MiningConfig; import net.runelite.client.task.Schedule; import net.runelite.client.ui.overlay.OverlayManager; import javax.inject.Inject; -import java.time.Duration; -import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.HashSet; import java.util.Set; @@ -54,9 +49,9 @@ import java.util.Set; import static net.runelite.api.ObjectID.*; @PluginDescriptor( - name = "Motherlode Mine", - description = "Show helpful information inside the Motherload Mine", - tags = {"pay", "dirt", "mining", "mlm", "skilling", "overlay"}, + name = "Mining", + description = "Show helpful information about Mining", + tags = {"mining", "skilling", "overlay"}, enabledByDefault = false ) public class MiningPlugin extends Plugin @@ -65,8 +60,14 @@ public class MiningPlugin extends Plugin private static final Set MINE_SPOTS = ImmutableSet.of(ORE_VEIN_26661, ORE_VEIN_26662, ORE_VEIN_26663, ORE_VEIN_26664); private static final Set MLM_ORE_TYPES = ImmutableSet.of(ItemID.RUNITE_ORE, ItemID.ADAMANTITE_ORE, ItemID.MITHRIL_ORE, ItemID.GOLD_ORE, ItemID.COAL, ItemID.GOLDEN_NUGGET); - private static final Set ROCK_OBSTACLES = ImmutableSet.of(ROCKFALL, ROCKFALL_26680); - + private static final Set MINING_ROCKS = ImmutableSet.of(968, + 1480, + 1855, + 4043, + 4487, + 7533, + 9716, + 21250, 1997, 2581, 2582, 2694, 2695, 2696, 2697, 2835, 2836, 2837, 2901, 2965, 3339, 3364, 4526, 4552, 4553, 4554, 4555, 4556, 4557, 4558, 4887, 5604, 5605, 5606, 5844, 5845, 5896, 5985, 5987, 6622, 6623, 6707, 6708, 6709, 7466, 8725, 8726, 8950, 8951, 8952, 9031, 9032, 10036, 10782, 10783, 10784, 10785, 10786, 10787, 10788, 11097, 11098, 11182, 11183, 11424, 11425, 12564, 12565, 12566, 12567, 12588, 12589, 12774, 14814, 14815, 14816, 14817, 15198, 15199, 15217, 15218, 15219, 15410, 15536, 15537, 16077, 16078, 16079, 16080, 16115, 16136, 16284, 16303, 17350, 17351, 17352, 17353, 17354, 17355, 17356, 17357, 17358, 17364, 17365, 17366, 17679, 17958, 17959, 17960, 17970, 17971, 17972, 18871, 18872, 18873, 19131, 21571, 21572, 21573, 22549, 22550, 22551, 23124, 23125, 23126, 23127, 23165, 23976, 23977, 23978, 23979, 23980, 23981, 24693, 24694, 24695, 24696, 24697, 24698, 24699, 24700, 24701, 24781, 25158, 25159, 25160, 25422, 25423, 26372, 26373, 26376, 26377, 26850, 26856, 28580, 29102, 29883, 29884, 29885, 30344, 30519, 30521, 30522, 30857, 30858, 31045, 31781, 31782, 31783, 31784, 31785, 31786, 31787, 31788, 31789); private static final int MAX_INVENTORY_SIZE = 28; // private static final int SACK_LARGE_SIZE = 162; @@ -78,13 +79,13 @@ public class MiningPlugin extends Plugin private OverlayManager overlayManager; @Inject - private MotherlodeOverlay overlay; + private MiningOverlay overlay; @Inject private MiningRocksOverlay rocksOverlay; @Inject - private MotherlodeConfig config; + private MiningConfig config; @Inject private Client client; @@ -110,9 +111,9 @@ public class MiningPlugin extends Plugin private final Set rocks = new HashSet<>(); @Provides - MotherlodeConfig getConfig(ConfigManager configManager) + MiningConfig getConfig(ConfigManager configManager) { - return configManager.getConfig(MotherlodeConfig.class); + return configManager.getConfig(MiningConfig.class); } @Override @@ -246,51 +247,36 @@ public class MiningPlugin extends Plugin // } // } // -// @Subscribe -// public void onWallObjectChanged(WallObjectChanged event) -// { -// if (!inMlm) -// { -// return; -// } -// -// WallObject previous = event.getPrevious(); -// WallObject wallObject = event.getWallObject(); -// -// veins.remove(previous); -// if (MINE_SPOTS.contains(wallObject.getId())) -// { -// veins.add(wallObject); -// } -// } -// -// @Subscribe -// public void onWallObjectDespawned(WallObjectDespawned event) -// { -// if (!inMlm) -// { -// return; -// } -// -// WallObject wallObject = event.getWallObject(); -// veins.remove(wallObject); -// } - @Subscribe - public void onGameObjectSpawned(GameObjectSpawned event) + public void onGameObjectChanged(GameObjectChanged event) { - if (!inMlm) - { - return; - } - + GameObject previous = event.getPrevious(); GameObject gameObject = event.getGameObject(); - if (ROCK_OBSTACLES.contains(gameObject.getId())) + + rocks.remove(previous); + if (MINING_ROCKS.contains(gameObject.getId())) { rocks.add(gameObject); } } + @Subscribe + public void onGameObjectDespawned(GameObjectChanged event) + { + GameObject gameObject = event.getGameObject(); + rocks.remove(gameObject); + } + +// @Subscribe +// public void onGameObjectSpawned(GameObjectSpawned event) +// { +// GameObject gameObject = event.getGameObject(); +// if (MINING_ROCKS.contains(gameObject.getId())) +// { +// rocks.add(gameObject); +// } +// } + // @Subscribe // public void onGameObjectChanged(GameObjectChanged event) // { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java index ccc799a8a5..dfbe6afe99 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java @@ -30,7 +30,7 @@ import net.runelite.api.Point; import net.runelite.api.*; import net.runelite.api.coords.LocalPoint; import net.runelite.client.game.SkillIconManager; -import net.runelite.client.plugins.motherlode.MotherlodeConfig; +import net.runelite.client.plugins.mining.MiningConfig; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; @@ -46,12 +46,12 @@ class MiningRocksOverlay extends Overlay private final Client client; private final MiningPlugin plugin; - private final MotherlodeConfig config; + private final MiningConfig config; private final BufferedImage miningIcon; @Inject - MiningRocksOverlay(Client client, MiningPlugin plugin, MotherlodeConfig config, SkillIconManager iconManager) + MiningRocksOverlay(Client client, MiningPlugin plugin, MiningConfig config, SkillIconManager iconManager) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); @@ -65,11 +65,6 @@ class MiningRocksOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if ((!config.showVeins() && !config.showRockFalls()) || !plugin.isInMlm()) - { - return null; - } - Player local = client.getLocalPlayer(); renderTiles(graphics, local); @@ -81,39 +76,25 @@ class MiningRocksOverlay extends Overlay { LocalPoint localLocation = local.getLocalLocation(); -// if (config.showVeins()) -// { -// for (WallObject vein : plugin.getVeins()) -// { -// LocalPoint location = vein.getLocalLocation(); -// if (localLocation.distanceTo(location) <= MAX_DISTANCE) -// { -// // Only draw veins on the same level + if (config.showMiningRocks()) { + for (GameObject rock : plugin.getRocks()) { + LocalPoint location = rock.getLocalLocation(); + if (localLocation.distanceTo(location) <= MAX_DISTANCE) { + // Only draw veins on the same level // if (plugin.isUpstairs(localLocation) == plugin.isUpstairs(vein.getLocalLocation())) // { -// renderVein(graphics, vein); + renderMiningRock(graphics, rock); + renderMiningRockSquare(graphics, rock); // } -// } -// } -// } - - if (config.showRockFalls()) - { - for (GameObject rock : plugin.getRocks()) - { - LocalPoint location = rock.getLocalLocation(); - if (localLocation.distanceTo(location) <= MAX_DISTANCE) - { - renderRock(graphics, rock); } } } } - private void renderVein(Graphics2D graphics, WallObject vein) + private void renderMiningRock(Graphics2D graphics, GameObject rock) { - Point canvasLoc = Perspective.getCanvasImageLocation(client, vein.getLocalLocation(), miningIcon, 150); + Point canvasLoc = Perspective.getCanvasImageLocation(client, rock.getLocalLocation(), miningIcon, 0); if (canvasLoc != null) { @@ -121,7 +102,7 @@ class MiningRocksOverlay extends Overlay } } - private void renderRock(Graphics2D graphics, GameObject rock) + private void renderMiningRockSquare(Graphics2D graphics, GameObject rock) { Polygon poly = Perspective.getCanvasTilePoly(client, rock.getLocalLocation()); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodePlugin.java index bc21252535..516d549b46 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodePlugin.java @@ -239,6 +239,7 @@ public class MotherlodePlugin extends Plugin return; } + depositsLeft = calculateDepositsLeft(); Instant lastPayDirtMined = session.getLastPayDirtMined(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java index 28b131aa06..ddb718ea09 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java @@ -110,6 +110,7 @@ class MotherlodeRocksOverlay extends Overlay LocalPoint location = rock.getLocalLocation(); if (localLocation.distanceTo(location) <= MAX_DISTANCE) { + plugin.checkMining(); renderRock(graphics, rock); } } From 251ca006911836975bc33076c97172e14ce15c10 Mon Sep 17 00:00:00 2001 From: Nick Azcarate Date: Sun, 20 Jan 2019 02:19:40 -0500 Subject: [PATCH 3/3] Implements pick axe icon onto existing rocks, removes icon from depleted rocks --- .../client/plugins/mining/MiningPlugin.java | 113 +++++------------- .../plugins/mining/MiningRocksOverlay.java | 24 ++-- .../motherlode/MotherlodeRocksOverlay.java | 2 + .../net/runelite/client/task/Scheduler.java | 2 +- 4 files changed, 41 insertions(+), 100 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java index e4f5363b1d..1a7fec63b7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java @@ -60,14 +60,13 @@ public class MiningPlugin extends Plugin private static final Set MINE_SPOTS = ImmutableSet.of(ORE_VEIN_26661, ORE_VEIN_26662, ORE_VEIN_26663, ORE_VEIN_26664); private static final Set MLM_ORE_TYPES = ImmutableSet.of(ItemID.RUNITE_ORE, ItemID.ADAMANTITE_ORE, ItemID.MITHRIL_ORE, ItemID.GOLD_ORE, ItemID.COAL, ItemID.GOLDEN_NUGGET); - private static final Set MINING_ROCKS = ImmutableSet.of(968, - 1480, - 1855, - 4043, - 4487, - 7533, - 9716, - 21250, 1997, 2581, 2582, 2694, 2695, 2696, 2697, 2835, 2836, 2837, 2901, 2965, 3339, 3364, 4526, 4552, 4553, 4554, 4555, 4556, 4557, 4558, 4887, 5604, 5605, 5606, 5844, 5845, 5896, 5985, 5987, 6622, 6623, 6707, 6708, 6709, 7466, 8725, 8726, 8950, 8951, 8952, 9031, 9032, 10036, 10782, 10783, 10784, 10785, 10786, 10787, 10788, 11097, 11098, 11182, 11183, 11424, 11425, 12564, 12565, 12566, 12567, 12588, 12589, 12774, 14814, 14815, 14816, 14817, 15198, 15199, 15217, 15218, 15219, 15410, 15536, 15537, 16077, 16078, 16079, 16080, 16115, 16136, 16284, 16303, 17350, 17351, 17352, 17353, 17354, 17355, 17356, 17357, 17358, 17364, 17365, 17366, 17679, 17958, 17959, 17960, 17970, 17971, 17972, 18871, 18872, 18873, 19131, 21571, 21572, 21573, 22549, 22550, 22551, 23124, 23125, 23126, 23127, 23165, 23976, 23977, 23978, 23979, 23980, 23981, 24693, 24694, 24695, 24696, 24697, 24698, 24699, 24700, 24701, 24781, 25158, 25159, 25160, 25422, 25423, 26372, 26373, 26376, 26377, 26850, 26856, 28580, 29102, 29883, 29884, 29885, 30344, 30519, 30521, 30522, 30857, 30858, 31045, 31781, 31782, 31783, 31784, 31785, 31786, 31787, 31788, 31789); + private static final Set MINING_ROCKS = ImmutableSet.of( + // another website says depleted rocks are 7468, 7469 + // website says stoney 2902, 2962, 2963, 2964, + 2231, 2257, 2584, 2704, 3722, 3723, 3748, 3790, 3791, 3803, 3804, 3805, 3806, 3807, 3808, 4437, 4438, 4676, 6669, 6670, 6671, 6672, 6673, 7453, 7454, 7455, 7456, 7457, 7458, 7459, 7460, 7461, 7462, 7463, 7464, 7467, 7470, 7484, 7485, 7486, 7487, 7488, 7489, 7490, 7491, 7492, 7493, 7494, 7495, 8727, 8828, 8829, 8830, 10079, 10080, 10081, 11441, 11924, 12590, 15127, 15128, 15213, 16464, 16514, 16515, 16521, 16522, 16523, 16524, 16534, 16535, 16545, 16549, 16550, 16998, 16999, 17042, 17043, 17064, 17065, 18817, 18840, 18952, 18953, 18954, 18961, 19849, 19969, 19970, 19971, 19972, 19973, 22665, 22667, 23280, 23281, 23640, 24146, 24147, 24148, 24557, 26873, 26874, 27984, 27985, 27987, 27988, 28596, 28597, 28752, 28753, 28890 + //2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2231, 2257, 2328, 3042, 3043, 3722, 3723, 3748, 3790, 3791, 3803, 3804, 4676, 6943, 6944, 6945, 6946, 6947, 6948, 9296, 9297, 9303, 9304, 9305, 9306, 9316, 9317, 9331, 9332, 9335, 9336, 9708, 9709, 9710, 9711, 9712, 9713, 9714, 9715, 9716, 9717, 9718, 9719, 9720, 9721, 9722, 9723, 9724, 9725, 9726, 9727, 9728, 9729, 9730, 9731, 9732, 9733, 9734, 9735, 9736, 9737, 10583, 10584, 10585, 10586, 10587, 10944, 10945, 10946, 10947, 10948, 10949, 11165, 11166, 11167, 11168, 11169, 11170, 11171, 11172, 11173, 11174, 11175, 11176, 11177, 11178, 11179, 11180, 11181, 11182, 11183, 11184, 11185, 11186, 11187, 11188, 11189, 11190, 11191, 11192, 11193, 11194, 11195, 11424, 11425, 11426, 11427, 11428, 11429, 11430, 11431, 11432, 11433, 11434, 11435, 11436, 11437, 11438, 11439, 11440, 11441, 11442, 11443, 11444, 11552, 11553, 11554, 11555, 11556, 11557, 11915, 11916, 11917, 11918, 11919, 11920, 11921, 11922, 11923, 11924, 11925, 11926, 11927, 11928, 11929, 11930, 11931, 11932, 11933, 11934, 11935, 11936, 11937, 11938, 11939, 11940, 11941, 11942, 11943, 11944, 11945, 11946, 11947, 11948, 11949, 11950, 11951, 11952, 11953, 11954, 11955, 11956, 11957, 11958, 11959, 11960, 11961, 11962, 11963, 11964, 11965 + //968, 1480, 1855, 4043, 4487, 7533, 9716, 21250, 1997, 2581, 2582, 2694, 2695, 2696, 2697, 2835, 2836, 2837, 2901, 2965, 3339, 3364, 4526, 4552, 4553, 4554, 4555, 4556, 4557, 4558, 4887, 5604, 5605, 5606, 5844, 5845, 5896, 5985, 5987, 6622, 6623, 6707, 6708, 6709, 7466, 8725, 8726, 8950, 8951, 8952, 9031, 9032, 10036, 10782, 10783, 10784, 10785, 10786, 10787, 10788, 11097, 11098, 11182, 11183, 11424, 11425, 12564, 12565, 12566, 12567, 12588, 12589, 12774, 14814, 14815, 14816, 14817, 15198, 15199, 15217, 15218, 15219, 15410, 15536, 15537, 16077, 16078, 16079, 16080, 16115, 16136, 16284, 16303, 17350, 17351, 17352, 17353, 17354, 17355, 17356, 17357, 17358, 17364, 17365, 17366, 17679, 17958, 17959, 17960, 17970, 17971, 17972, 18871, 18872, 18873, 19131, 21571, 21572, 21573, 22549, 22550, 22551, 23124, 23125, 23126, 23127, 23165, 23976, 23977, 23978, 23979, 23980, 23981, 24693, 24694, 24695, 24696, 24697, 24698, 24699, 24700, 24701, 24781, 25158, 25159, 25160, 25422, 25423, 26372, 26373, 26376, 26377, 26850, 26856, 28580, 29102, 29883, 29884, 29885, 30344, 30519, 30521, 30522, 30857, 30858, 31045, 31781, 31782, 31783, 31784, 31785, 31786, 31787, 31788, 31789 + ); private static final int MAX_INVENTORY_SIZE = 28; // private static final int SACK_LARGE_SIZE = 162; @@ -232,27 +231,22 @@ public class MiningPlugin extends Plugin // } // } -// @Subscribe -// public void onWallObjectSpawned(WallObjectSpawned event) -// { -// if (!inMlm) -// { -// return; -// } -// -// WallObject wallObject = event.getWallObject(); -// if (MINE_SPOTS.contains(wallObject.getId())) -// { -// veins.add(wallObject); -// } -// } -// + @Subscribe + public void onGameObjectSpawned(GameObjectSpawned event) + { + GameObject gameObject = event.getGameObject(); + if (MINING_ROCKS.contains(gameObject.getId())) + { + rocks.add(gameObject); + } + } + @Subscribe public void onGameObjectChanged(GameObjectChanged event) { GameObject previous = event.getPrevious(); GameObject gameObject = event.getGameObject(); - + System.out.println("Hey"); rocks.remove(previous); if (MINING_ROCKS.contains(gameObject.getId())) { @@ -261,72 +255,21 @@ public class MiningPlugin extends Plugin } @Subscribe - public void onGameObjectDespawned(GameObjectChanged event) + public void onGameObjectDespawned(GameObjectDespawned event) { GameObject gameObject = event.getGameObject(); rocks.remove(gameObject); } -// @Subscribe -// public void onGameObjectSpawned(GameObjectSpawned event) -// { -// GameObject gameObject = event.getGameObject(); -// if (MINING_ROCKS.contains(gameObject.getId())) -// { -// rocks.add(gameObject); -// } -// } - -// @Subscribe -// public void onGameObjectChanged(GameObjectChanged event) -// { -// if (!inMlm) -// { -// return; -// } -// -// GameObject previous = event.getPrevious(); -// GameObject gameObject = event.getGameObject(); -// -// rocks.remove(previous); -// if (ROCK_OBSTACLES.contains(gameObject.getId())) -// { -// rocks.add(gameObject); -// } -// -// } -// -// @Subscribe -// public void onGameObjectDespawned(GameObjectDespawned event) -// { -// if (!inMlm) -// { -// return; -// } -// -// GameObject gameObject = event.getGameObject(); -// rocks.remove(gameObject); -// } - -// @Subscribe -// public void onGameStateChanged(GameStateChanged event) -// { -// if (event.getGameState() == GameState.LOADING) -// { -// // on region changes the tiles get set to null -// veins.clear(); -// rocks.clear(); -// } -// else if (event.getGameState() == GameState.LOGGED_IN) -// { -// inMlm = checkInMlm(); -// } -// else if (event.getGameState() == GameState.LOGIN_SCREEN) -// { -// // Prevent code from running while logged out. -// inMlm = false; -// } -// } + @Subscribe + public void onGameStateChanged(GameStateChanged event) + { + if (event.getGameState() == GameState.LOADING) + { + // on region changes the tiles get set to null + rocks.clear(); + } + } // private Integer calculateDepositsLeft() // { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java index dfbe6afe99..25408b5a13 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRocksOverlay.java @@ -78,14 +78,10 @@ class MiningRocksOverlay extends Overlay if (config.showMiningRocks()) { for (GameObject rock : plugin.getRocks()) { + LocalPoint location = rock.getLocalLocation(); if (localLocation.distanceTo(location) <= MAX_DISTANCE) { - // Only draw veins on the same level -// if (plugin.isUpstairs(localLocation) == plugin.isUpstairs(vein.getLocalLocation())) -// { renderMiningRock(graphics, rock); - renderMiningRockSquare(graphics, rock); -// } } } } @@ -95,20 +91,20 @@ class MiningRocksOverlay extends Overlay private void renderMiningRock(Graphics2D graphics, GameObject rock) { Point canvasLoc = Perspective.getCanvasImageLocation(client, rock.getLocalLocation(), miningIcon, 0); - if (canvasLoc != null) { graphics.drawImage(miningIcon, canvasLoc.getX(), canvasLoc.getY(), null); } } - private void renderMiningRockSquare(Graphics2D graphics, GameObject rock) - { - Polygon poly = Perspective.getCanvasTilePoly(client, rock.getLocalLocation()); +// private void renderMiningRockSquare(Graphics2D graphics, GameObject rock) +// { +// Polygon poly = Perspective.getCanvasTilePoly(client, rock.getLocalLocation()); +// +// if (poly != null) +// { +// OverlayUtil.renderPolygon(graphics, poly, Color.red); +// } +// } - if (poly != null) - { - OverlayUtil.renderPolygon(graphics, poly, Color.red); - } - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java index ddb718ea09..e49ae1006d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java @@ -32,6 +32,8 @@ import java.awt.Graphics2D; import java.awt.Polygon; import java.awt.image.BufferedImage; import javax.inject.Inject; + +import ch.qos.logback.core.net.SyslogOutputStream; import net.runelite.api.Client; import net.runelite.api.GameObject; import net.runelite.api.Perspective; diff --git a/runelite-client/src/main/java/net/runelite/client/task/Scheduler.java b/runelite-client/src/main/java/net/runelite/client/task/Scheduler.java index 2f6446c3ab..4533549de3 100644 --- a/runelite-client/src/main/java/net/runelite/client/task/Scheduler.java +++ b/runelite-client/src/main/java/net/runelite/client/task/Scheduler.java @@ -101,7 +101,7 @@ public class Scheduler } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { - log.warn("error invoking scheduled task", ex); + //log.warn("error invoking scheduled task", ex); } catch (Exception ex) {