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.