slayer: Update initial amount if current amount is higher

Prior to this commit it was possible to receive a change or update in
task by playing on mobile or another client, log back in to RuneLite
with incorrect task information saved to config and, once updated via
checking a slayer gem or speaking with a slayer master, having a task
amount greater than the saved initial task length. This updates the
plugin to use the greater of these numbers so that case is no longer
possible.
This commit is contained in:
Jordan Atwood
2020-06-24 14:56:35 -07:00
parent 86ddd6ebd4
commit 1dbf432377
2 changed files with 12 additions and 1 deletions

View File

@@ -683,7 +683,7 @@ public class SlayerPlugin extends Plugin
{
taskName = name;
amount = amt;
initialAmount = initAmt;
initialAmount = Math.max(amt, initAmt);
taskLocation = location;
save();
removeCounter();

View File

@@ -775,6 +775,17 @@ public class SlayerPluginTest
assertEquals(30, slayerPlugin.getAmount());
}
@Test
public void updateInitialAmount()
{
Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_EXISTING);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick());
assertEquals(222, slayerPlugin.getInitialAmount());
}
@Test
public void testTaskLookup() throws IOException
{