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:
@@ -683,7 +683,7 @@ public class SlayerPlugin extends Plugin
|
||||
{
|
||||
taskName = name;
|
||||
amount = amt;
|
||||
initialAmount = initAmt;
|
||||
initialAmount = Math.max(amt, initAmt);
|
||||
taskLocation = location;
|
||||
save();
|
||||
removeCounter();
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user