From d6f5259fc2f9278e07a477746b5da59569c7414f Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 26 May 2018 15:23:49 +0200 Subject: [PATCH] Motherlode Mine - Startup / shutdown bugs (#3124) - When starting the Motherlode Mine plugin for the first time inside MLM, the sack overlay will be colored red because the sack values are set to 0. Changed so the plugin refreshes the sack values on startup. - When stopping the plugin, the sack widget will stay hidden. This calls sack.setHidden(false) on plugin shutdown. - When MLM plugin is started, reset session properly --- .../plugins/motherlode/MotherlodePlugin.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) 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 0307e21bb8..359d00203d 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 @@ -67,6 +67,8 @@ import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.WallObjectChanged; import net.runelite.api.events.WallObjectDespawned; import net.runelite.api.events.WallObjectSpawned; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.config.ConfigManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; @@ -118,7 +120,7 @@ public class MotherlodePlugin extends Plugin @Getter(AccessLevel.PACKAGE) private Integer depositsLeft; - private final MotherlodeSession session = new MotherlodeSession(); + private MotherlodeSession session; @Getter(AccessLevel.PACKAGE) private final Set veins = new HashSet<>(); @@ -140,14 +142,28 @@ public class MotherlodePlugin extends Plugin @Override protected void startUp() { + session = new MotherlodeSession(); inMlm = checkInMlm(); + + if (inMlm) + { + refreshSackValues(); + } } @Override protected void shutDown() throws Exception { + session = null; veins.clear(); rocks.clear(); + + Widget sack = client.getWidget(WidgetInfo.MOTHERLODE_MINE); + + if (sack != null && sack.isHidden()) + { + sack.setHidden(false); + } } public MotherlodeSession getSession() @@ -160,9 +176,7 @@ public class MotherlodePlugin extends Plugin { if (inMlm) { - curSackSize = client.getVar(Varbits.SACK_NUMBER); - boolean sackUpgraded = client.getVar(Varbits.SACK_UPGRADED) == 1; - maxSackSize = sackUpgraded ? SACK_LARGE_SIZE : SACK_SIZE; + refreshSackValues(); } } @@ -410,6 +424,13 @@ public class MotherlodePlugin extends Plugin 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.