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
This commit is contained in:
TheStonedTurtle
2018-11-23 04:14:17 -08:00
committed by Tomas Slusny
parent 6c1169c776
commit 3c533c6136

View File

@@ -87,6 +87,8 @@ public class MotherlodePlugin extends Plugin
ItemID.MITHRIL_ORE, ItemID.GOLD_ORE, ItemID.COAL, ItemID.GOLDEN_NUGGET);
private static final Set<Integer> 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)