From 3c533c6136f6cd2c95d627addb7d814ad33a5d2c Mon Sep 17 00:00:00 2001 From: TheStonedTurtle <29030969+TheStonedTurtle@users.noreply.github.com> Date: Fri, 23 Nov 2018 04:14:17 -0800 Subject: [PATCH] Properly update MLM sack values on login/logout (#6627) - Prevent unnecessary code execution while logged out - Fix inventory size on initial login - Refresh sack values on initial login --- .../client/plugins/motherlode/MotherlodePlugin.java | 13 +++++++++---- 1 file changed, 9 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 72dd25c268..f20faca83d 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 @@ -87,6 +87,8 @@ public class MotherlodePlugin extends Plugin 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; @@ -359,13 +361,18 @@ public class MotherlodePlugin extends Plugin { 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 { - return null; + refreshSackValues(); } double depositsLeft = 0; @@ -380,8 +387,6 @@ public class MotherlodePlugin extends Plugin Item[] result = inventory.getItems(); assert result != null; - int inventorySize = result.length; - for (Item item : result) { // Assume that MLM ores are being banked and exclude them from the check, @@ -394,7 +399,7 @@ public class MotherlodePlugin extends Plugin } } - double inventorySpace = inventorySize - nonPayDirtItems; + double inventorySpace = MAX_INVENTORY_SIZE - nonPayDirtItems; double sackSizeRemaining = maxSackSize - curSackSize; if (inventorySpace > 0 && sackSizeRemaining > 0)