Fix combat brace slayer task race condition
Apparently combat bracelet message is sent before XP drop is received, so task updates to correct amount and then is substracted by 1. To combat this, virtually increase amount by 1 so the xp drop will substract to correct amount. Closes #6091 Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.slayer;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.Color;
|
||||
@@ -434,7 +435,9 @@ public class SlayerPlugin extends Plugin
|
||||
{
|
||||
final int taskAmount = Integer.parseInt(bracerProgress.group(1));
|
||||
setTask(taskName, taskAmount);
|
||||
return;
|
||||
|
||||
// Avoid race condition (combat brace message goes through first before XP drop)
|
||||
amount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,7 +485,8 @@ public class SlayerPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private void killedOne()
|
||||
@VisibleForTesting
|
||||
void killedOne()
|
||||
{
|
||||
if (amount == 0)
|
||||
{
|
||||
|
||||
@@ -429,6 +429,7 @@ public class SlayerPluginTest
|
||||
slayerPlugin.onChatMessage(chatMessage);
|
||||
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
slayerPlugin.killedOne();
|
||||
assertEquals(30, slayerPlugin.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user