slayer plugin: store task in rs profile configuration
Co-authored-by: Adam <Adam@sigterm.info>
This commit is contained in:
@@ -32,9 +32,21 @@ import net.runelite.client.config.ConfigGroup;
|
|||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
import net.runelite.client.config.Units;
|
import net.runelite.client.config.Units;
|
||||||
|
|
||||||
@ConfigGroup("slayer")
|
@ConfigGroup(SlayerConfig.GROUP_NAME)
|
||||||
public interface SlayerConfig extends Config
|
public interface SlayerConfig extends Config
|
||||||
{
|
{
|
||||||
|
String GROUP_NAME = "slayer";
|
||||||
|
|
||||||
|
// Key names for stored task values
|
||||||
|
String TASK_NAME_KEY = "taskName";
|
||||||
|
String AMOUNT_KEY = "amount";
|
||||||
|
String INIT_AMOUNT_KEY = "initialAmount";
|
||||||
|
String TASK_LOC_KEY = "taskLocation";
|
||||||
|
String STREAK_KEY = "streak";
|
||||||
|
String POINTS_KEY = "points";
|
||||||
|
String EXPEDITIOUS_CHARGES_KEY = "expeditious";
|
||||||
|
String SLAUGHTER_CHARGES_KEY = "slaughter";
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 1,
|
position = 1,
|
||||||
keyName = "infobox",
|
keyName = "infobox",
|
||||||
@@ -124,148 +136,4 @@ public interface SlayerConfig extends Config
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stored data
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "taskName",
|
|
||||||
name = "",
|
|
||||||
description = "",
|
|
||||||
hidden = true
|
|
||||||
)
|
|
||||||
default String taskName()
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "taskName",
|
|
||||||
name = "",
|
|
||||||
description = ""
|
|
||||||
)
|
|
||||||
void taskName(String key);
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "amount",
|
|
||||||
name = "",
|
|
||||||
description = "",
|
|
||||||
hidden = true
|
|
||||||
)
|
|
||||||
default int amount()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "amount",
|
|
||||||
name = "",
|
|
||||||
description = ""
|
|
||||||
)
|
|
||||||
void amount(int amt);
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "initialAmount",
|
|
||||||
name = "",
|
|
||||||
description = "",
|
|
||||||
hidden = true
|
|
||||||
)
|
|
||||||
default int initialAmount()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "initialAmount",
|
|
||||||
name = "",
|
|
||||||
description = ""
|
|
||||||
)
|
|
||||||
void initialAmount(int initialAmount);
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "taskLocation",
|
|
||||||
name = "",
|
|
||||||
description = "",
|
|
||||||
hidden = true
|
|
||||||
)
|
|
||||||
default String taskLocation()
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "taskLocation",
|
|
||||||
name = "",
|
|
||||||
description = ""
|
|
||||||
)
|
|
||||||
void taskLocation(String key);
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "streak",
|
|
||||||
name = "",
|
|
||||||
description = "",
|
|
||||||
hidden = true
|
|
||||||
)
|
|
||||||
default int streak()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "streak",
|
|
||||||
name = "",
|
|
||||||
description = ""
|
|
||||||
)
|
|
||||||
void streak(int streak);
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "points",
|
|
||||||
name = "",
|
|
||||||
description = "",
|
|
||||||
hidden = true
|
|
||||||
)
|
|
||||||
default int points()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "points",
|
|
||||||
name = "",
|
|
||||||
description = ""
|
|
||||||
)
|
|
||||||
void points(int points);
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "expeditious",
|
|
||||||
name = "",
|
|
||||||
description = "",
|
|
||||||
hidden = true
|
|
||||||
)
|
|
||||||
default int expeditious()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "expeditious",
|
|
||||||
name = "",
|
|
||||||
description = ""
|
|
||||||
)
|
|
||||||
void expeditious(int expeditious);
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "slaughter",
|
|
||||||
name = "",
|
|
||||||
description = "",
|
|
||||||
hidden = true
|
|
||||||
)
|
|
||||||
default int slaughter()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "slaughter",
|
|
||||||
name = "",
|
|
||||||
description = ""
|
|
||||||
)
|
|
||||||
void slaughter(int slaughter);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,9 @@ public class SlayerPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private SlayerConfig config;
|
private SlayerConfig config;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ConfigManager configManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
@@ -227,12 +230,17 @@ public class SlayerPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
cachedXp = client.getSkillExperience(SLAYER);
|
cachedXp = client.getSkillExperience(SLAYER);
|
||||||
|
|
||||||
if (config.amount() != -1
|
migrateConfig();
|
||||||
&& !config.taskName().isEmpty())
|
|
||||||
|
if (getIntProfileConfig(SlayerConfig.AMOUNT_KEY) != -1
|
||||||
|
&& !getStringProfileConfig(SlayerConfig.TASK_NAME_KEY).isEmpty())
|
||||||
{
|
{
|
||||||
setExpeditiousChargeCount(config.expeditious());
|
setExpeditiousChargeCount(getIntProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY));
|
||||||
setSlaughterChargeCount(config.slaughter());
|
setSlaughterChargeCount(getIntProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY));
|
||||||
clientThread.invoke(() -> setTask(config.taskName(), config.amount(), config.initialAmount(), config.taskLocation(), false));
|
clientThread.invoke(() -> setTask(getStringProfileConfig(SlayerConfig.TASK_NAME_KEY),
|
||||||
|
getIntProfileConfig(SlayerConfig.AMOUNT_KEY),
|
||||||
|
getIntProfileConfig(SlayerConfig.INIT_AMOUNT_KEY),
|
||||||
|
getStringProfileConfig(SlayerConfig.TASK_LOC_KEY), false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,27 +283,50 @@ public class SlayerPlugin extends Plugin
|
|||||||
taggedNpcs.clear();
|
taggedNpcs.clear();
|
||||||
break;
|
break;
|
||||||
case LOGGED_IN:
|
case LOGGED_IN:
|
||||||
if (config.amount() != -1
|
migrateConfig();
|
||||||
&& !config.taskName().isEmpty()
|
if (getIntProfileConfig(SlayerConfig.AMOUNT_KEY) != -1
|
||||||
|
&& !getStringProfileConfig(SlayerConfig.TASK_NAME_KEY).isEmpty()
|
||||||
&& loginFlag)
|
&& loginFlag)
|
||||||
{
|
{
|
||||||
setExpeditiousChargeCount(config.expeditious());
|
setExpeditiousChargeCount(getIntProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY));
|
||||||
setSlaughterChargeCount(config.slaughter());
|
setSlaughterChargeCount(getIntProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY));
|
||||||
setTask(config.taskName(), config.amount(), config.initialAmount(), config.taskLocation(), false);
|
setTask(getStringProfileConfig(SlayerConfig.TASK_NAME_KEY),
|
||||||
|
getIntProfileConfig(SlayerConfig.AMOUNT_KEY),
|
||||||
|
getIntProfileConfig(SlayerConfig.INIT_AMOUNT_KEY),
|
||||||
|
getStringProfileConfig(SlayerConfig.TASK_LOC_KEY), false);
|
||||||
loginFlag = false;
|
loginFlag = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
int getIntProfileConfig(String key)
|
||||||
|
{
|
||||||
|
Integer value = configManager.getRSProfileConfiguration(SlayerConfig.GROUP_NAME, key, int.class);
|
||||||
|
return value == null ? -1 : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
String getStringProfileConfig(String key)
|
||||||
|
{
|
||||||
|
String value = configManager.getRSProfileConfiguration(SlayerConfig.GROUP_NAME, key, String.class);
|
||||||
|
return value == null ? "" : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setProfileConfig(String key, Object value)
|
||||||
|
{
|
||||||
|
configManager.setRSProfileConfiguration(SlayerConfig.GROUP_NAME, key, value);
|
||||||
|
}
|
||||||
|
|
||||||
private void save()
|
private void save()
|
||||||
{
|
{
|
||||||
config.amount(amount);
|
setProfileConfig(SlayerConfig.AMOUNT_KEY, amount);
|
||||||
config.initialAmount(initialAmount);
|
setProfileConfig(SlayerConfig.INIT_AMOUNT_KEY, initialAmount);
|
||||||
config.taskName(taskName);
|
setProfileConfig(SlayerConfig.TASK_NAME_KEY, taskName);
|
||||||
config.taskLocation(taskLocation);
|
setProfileConfig(SlayerConfig.TASK_LOC_KEY, taskLocation);
|
||||||
config.expeditious(expeditiousChargeCount);
|
setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount);
|
||||||
config.slaughter(slaughterChargeCount);
|
setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -345,7 +376,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
int amount = Integer.parseInt(mAssignBoss.group(2));
|
int amount = Integer.parseInt(mAssignBoss.group(2));
|
||||||
setTask(mAssignBoss.group(1), amount, amount);
|
setTask(mAssignBoss.group(1), amount, amount);
|
||||||
int points = Integer.parseInt(mAssignBoss.group(3).replaceAll(",", ""));
|
int points = Integer.parseInt(mAssignBoss.group(3).replaceAll(",", ""));
|
||||||
config.points(points);
|
setProfileConfig(SlayerConfig.POINTS_KEY, points);
|
||||||
}
|
}
|
||||||
else if (mCurrent.find())
|
else if (mCurrent.find())
|
||||||
{
|
{
|
||||||
@@ -363,12 +394,12 @@ public class SlayerPlugin extends Plugin
|
|||||||
if (braceletText.contains("bracelet of slaughter"))
|
if (braceletText.contains("bracelet of slaughter"))
|
||||||
{
|
{
|
||||||
slaughterChargeCount = SLAUGHTER_CHARGE;
|
slaughterChargeCount = SLAUGHTER_CHARGE;
|
||||||
config.slaughter(slaughterChargeCount);
|
setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount);
|
||||||
}
|
}
|
||||||
else if (braceletText.contains("expeditious bracelet"))
|
else if (braceletText.contains("expeditious bracelet"))
|
||||||
{
|
{
|
||||||
expeditiousChargeCount = EXPEDITIOUS_CHARGE;
|
expeditiousChargeCount = EXPEDITIOUS_CHARGE;
|
||||||
config.expeditious(expeditiousChargeCount);
|
setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,12 +411,12 @@ public class SlayerPlugin extends Plugin
|
|||||||
Matcher mPoints = REWARD_POINTS.matcher(w.getText());
|
Matcher mPoints = REWARD_POINTS.matcher(w.getText());
|
||||||
if (mPoints.find())
|
if (mPoints.find())
|
||||||
{
|
{
|
||||||
final int prevPoints = config.points();
|
final int prevPoints = getIntProfileConfig(SlayerConfig.POINTS_KEY);
|
||||||
int points = Integer.parseInt(mPoints.group(1).replaceAll(",", ""));
|
int points = Integer.parseInt(mPoints.group(1).replaceAll(",", ""));
|
||||||
|
|
||||||
if (prevPoints != points)
|
if (prevPoints != points)
|
||||||
{
|
{
|
||||||
config.points(points);
|
setProfileConfig(SlayerConfig.POINTS_KEY, points);
|
||||||
removeCounter();
|
removeCounter();
|
||||||
addCounter();
|
addCounter();
|
||||||
}
|
}
|
||||||
@@ -426,7 +457,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
|
|
||||||
amount++;
|
amount++;
|
||||||
slaughterChargeCount = mSlaughter.find() ? Integer.parseInt(mSlaughter.group(1)) : SLAUGHTER_CHARGE;
|
slaughterChargeCount = mSlaughter.find() ? Integer.parseInt(mSlaughter.group(1)) : SLAUGHTER_CHARGE;
|
||||||
config.slaughter(slaughterChargeCount);
|
setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS))
|
if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS))
|
||||||
@@ -435,7 +466,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
|
|
||||||
amount--;
|
amount--;
|
||||||
expeditiousChargeCount = mExpeditious.find() ? Integer.parseInt(mExpeditious.group(1)) : EXPEDITIOUS_CHARGE;
|
expeditiousChargeCount = mExpeditious.find() ? Integer.parseInt(mExpeditious.group(1)) : EXPEDITIOUS_CHARGE;
|
||||||
config.expeditious(expeditiousChargeCount);
|
setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS_CHARGE))
|
if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS_CHARGE))
|
||||||
@@ -448,7 +479,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
expeditiousChargeCount = Integer.parseInt(mExpeditious.group(1));
|
expeditiousChargeCount = Integer.parseInt(mExpeditious.group(1));
|
||||||
config.expeditious(expeditiousChargeCount);
|
setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER_CHARGE))
|
if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER_CHARGE))
|
||||||
@@ -460,7 +491,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
slaughterChargeCount = Integer.parseInt(mSlaughter.group(1));
|
slaughterChargeCount = Integer.parseInt(mSlaughter.group(1));
|
||||||
config.slaughter(slaughterChargeCount);
|
setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatMsg.startsWith("You've completed") && (chatMsg.contains("Slayer master") || chatMsg.contains("Slayer Master")))
|
if (chatMsg.startsWith("You've completed") && (chatMsg.contains("Slayer master") || chatMsg.contains("Slayer Master")))
|
||||||
@@ -479,12 +510,12 @@ public class SlayerPlugin extends Plugin
|
|||||||
if (mTasks != null)
|
if (mTasks != null)
|
||||||
{
|
{
|
||||||
int streak = Integer.parseInt(mTasks.replace(",", ""));
|
int streak = Integer.parseInt(mTasks.replace(",", ""));
|
||||||
config.streak(streak);
|
setProfileConfig(SlayerConfig.STREAK_KEY, streak);
|
||||||
}
|
}
|
||||||
if (mPoints != null)
|
if (mPoints != null)
|
||||||
{
|
{
|
||||||
int points = Integer.parseInt(mPoints.replace(",", ""));
|
int points = Integer.parseInt(mPoints.replace(",", ""));
|
||||||
config.points(points);
|
setProfileConfig(SlayerConfig.POINTS_KEY, points);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,7 +628,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
private void onConfigChanged(ConfigChanged event)
|
private void onConfigChanged(ConfigChanged event)
|
||||||
{
|
{
|
||||||
if (!event.getGroup().equals("slayer") || !event.getKey().equals("infobox"))
|
if (!event.getGroup().equals(SlayerConfig.GROUP_NAME) || !event.getKey().equals("infobox"))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -627,7 +658,8 @@ public class SlayerPlugin extends Plugin
|
|||||||
amount--;
|
amount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.amount(amount); // save changed value
|
// save changed value
|
||||||
|
setProfileConfig(SlayerConfig.AMOUNT_KEY, amount);
|
||||||
|
|
||||||
if (!config.showInfobox())
|
if (!config.showInfobox())
|
||||||
{
|
{
|
||||||
@@ -772,7 +804,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
counter = new TaskCounter(taskImg, this, amount);
|
counter = new TaskCounter(taskImg, this, amount);
|
||||||
counter.setTooltip(String.format(taskTooltip, capsString(taskName), config.points(), config.streak()));
|
counter.setTooltip(String.format(taskTooltip, capsString(taskName), getIntProfileConfig(SlayerConfig.POINTS_KEY), getIntProfileConfig(SlayerConfig.STREAK_KEY)));
|
||||||
|
|
||||||
infoBoxManager.addInfoBox(counter);
|
infoBoxManager.addInfoBox(counter);
|
||||||
}
|
}
|
||||||
@@ -891,4 +923,26 @@ public class SlayerPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void migrateConfig()
|
||||||
|
{
|
||||||
|
migrateConfigKey(SlayerConfig.TASK_NAME_KEY);
|
||||||
|
migrateConfigKey(SlayerConfig.AMOUNT_KEY);
|
||||||
|
migrateConfigKey(SlayerConfig.INIT_AMOUNT_KEY);
|
||||||
|
migrateConfigKey(SlayerConfig.TASK_LOC_KEY);
|
||||||
|
migrateConfigKey(SlayerConfig.STREAK_KEY);
|
||||||
|
migrateConfigKey(SlayerConfig.POINTS_KEY);
|
||||||
|
migrateConfigKey(SlayerConfig.EXPEDITIOUS_CHARGES_KEY);
|
||||||
|
migrateConfigKey(SlayerConfig.SLAUGHTER_CHARGES_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void migrateConfigKey(String key)
|
||||||
|
{
|
||||||
|
Object value = configManager.getConfiguration(SlayerConfig.GROUP_NAME, key);
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
configManager.unsetConfiguration(SlayerConfig.GROUP_NAME, key);
|
||||||
|
configManager.setRSProfileConfiguration(SlayerConfig.GROUP_NAME, key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import net.runelite.api.widgets.WidgetInfo;
|
|||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.chat.ChatCommandManager;
|
import net.runelite.client.chat.ChatCommandManager;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
@@ -64,6 +65,7 @@ import org.junit.runner.RunWith;
|
|||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import static org.mockito.Mockito.lenient;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -137,6 +139,10 @@ public class SlayerPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
ConfigManager configManager;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
SlayerConfig slayerConfig;
|
SlayerConfig slayerConfig;
|
||||||
@@ -283,7 +289,7 @@ public class SlayerPluginTest
|
|||||||
|
|
||||||
assertEquals("Vet'ion", slayerPlugin.getTaskName());
|
assertEquals("Vet'ion", slayerPlugin.getTaskName());
|
||||||
assertEquals(3, slayerPlugin.getAmount());
|
assertEquals(3, slayerPlugin.getAmount());
|
||||||
verify(slayerConfig).points(914);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.POINTS_KEY, 914);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -296,7 +302,7 @@ public class SlayerPluginTest
|
|||||||
|
|
||||||
assertEquals("Chaos Elemental", slayerPlugin.getTaskName());
|
assertEquals("Chaos Elemental", slayerPlugin.getTaskName());
|
||||||
assertEquals(3, slayerPlugin.getAmount());
|
assertEquals(3, slayerPlugin.getAmount());
|
||||||
verify(slayerConfig).points(914);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.POINTS_KEY, 914);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -309,7 +315,7 @@ public class SlayerPluginTest
|
|||||||
|
|
||||||
assertEquals("Alchemical Hydra", slayerPlugin.getTaskName());
|
assertEquals("Alchemical Hydra", slayerPlugin.getTaskName());
|
||||||
assertEquals(35, slayerPlugin.getAmount());
|
assertEquals(35, slayerPlugin.getAmount());
|
||||||
verify(slayerConfig).points(724);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.POINTS_KEY, 724);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -440,7 +446,7 @@ public class SlayerPluginTest
|
|||||||
when(client.getWidget(WidgetInfo.SLAYER_REWARDS_TOPBAR)).thenReturn(rewardBar);
|
when(client.getWidget(WidgetInfo.SLAYER_REWARDS_TOPBAR)).thenReturn(rewardBar);
|
||||||
slayerPlugin.onGameTick(new GameTick());
|
slayerPlugin.onGameTick(new GameTick());
|
||||||
|
|
||||||
verify(slayerConfig).points(17566);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.POINTS_KEY, 17566);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -449,7 +455,7 @@ public class SlayerPluginTest
|
|||||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_ONE, null, 0);
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_ONE, null, 0);
|
||||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
verify(slayerConfig).streak(1);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.STREAK_KEY, 1);
|
||||||
assertEquals("", slayerPlugin.getTaskName());
|
assertEquals("", slayerPlugin.getTaskName());
|
||||||
assertEquals(0, slayerPlugin.getAmount());
|
assertEquals(0, slayerPlugin.getAmount());
|
||||||
}
|
}
|
||||||
@@ -460,7 +466,7 @@ public class SlayerPluginTest
|
|||||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPLETE_NO_POINTS, null, 0);
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPLETE_NO_POINTS, null, 0);
|
||||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
verify(slayerConfig).streak(3);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.STREAK_KEY, 3);
|
||||||
assertEquals("", slayerPlugin.getTaskName());
|
assertEquals("", slayerPlugin.getTaskName());
|
||||||
assertEquals(0, slayerPlugin.getAmount());
|
assertEquals(0, slayerPlugin.getAmount());
|
||||||
}
|
}
|
||||||
@@ -471,10 +477,10 @@ public class SlayerPluginTest
|
|||||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_POINTS, null, 0);
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_POINTS, null, 0);
|
||||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
verify(slayerConfig).streak(9);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.STREAK_KEY, 9);
|
||||||
assertEquals("", slayerPlugin.getTaskName());
|
assertEquals("", slayerPlugin.getTaskName());
|
||||||
assertEquals(0, slayerPlugin.getAmount());
|
assertEquals(0, slayerPlugin.getAmount());
|
||||||
verify(slayerConfig).points(18_000);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.POINTS_KEY, 18_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -483,10 +489,10 @@ public class SlayerPluginTest
|
|||||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_LARGE_STREAK, null, 0);
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_LARGE_STREAK, null, 0);
|
||||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
verify(slayerConfig).streak(2465);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.STREAK_KEY, 2465);
|
||||||
assertEquals("", slayerPlugin.getTaskName());
|
assertEquals("", slayerPlugin.getTaskName());
|
||||||
assertEquals(0, slayerPlugin.getAmount());
|
assertEquals(0, slayerPlugin.getAmount());
|
||||||
verify(slayerConfig).points(131_071);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.POINTS_KEY, 131_071);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -495,7 +501,7 @@ public class SlayerPluginTest
|
|||||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPETE_TURAEL, null, 0);
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPETE_TURAEL, null, 0);
|
||||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
verify(slayerConfig).streak(104);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.STREAK_KEY, 104);
|
||||||
assertEquals("", slayerPlugin.getTaskName());
|
assertEquals("", slayerPlugin.getTaskName());
|
||||||
assertEquals(0, slayerPlugin.getAmount());
|
assertEquals(0, slayerPlugin.getAmount());
|
||||||
}
|
}
|
||||||
@@ -506,8 +512,8 @@ public class SlayerPluginTest
|
|||||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_MAX_STREAK, null, 0);
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_MAX_STREAK, null, 0);
|
||||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
verify(slayerConfig).streak(16_000);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.STREAK_KEY, 16000);
|
||||||
verify(slayerConfig).points(131_071);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.POINTS_KEY, 131_071);
|
||||||
assertEquals("", slayerPlugin.getTaskName());
|
assertEquals("", slayerPlugin.getTaskName());
|
||||||
assertEquals(0, slayerPlugin.getAmount());
|
assertEquals(0, slayerPlugin.getAmount());
|
||||||
}
|
}
|
||||||
@@ -518,8 +524,8 @@ public class SlayerPluginTest
|
|||||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_MAX_POINTS, null, 0);
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_MAX_POINTS, null, 0);
|
||||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
verify(slayerConfig).streak(9);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.STREAK_KEY, 9);
|
||||||
verify(slayerConfig).points(131_071);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.POINTS_KEY, 131_071);
|
||||||
assertEquals("", slayerPlugin.getTaskName());
|
assertEquals("", slayerPlugin.getTaskName());
|
||||||
assertEquals(0, slayerPlugin.getAmount());
|
assertEquals(0, slayerPlugin.getAmount());
|
||||||
}
|
}
|
||||||
@@ -530,8 +536,8 @@ public class SlayerPluginTest
|
|||||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_WILDERNESS, null, 0);
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_WILDERNESS, null, 0);
|
||||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
verify(slayerConfig).streak(9);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.STREAK_KEY, 9);
|
||||||
verify(slayerConfig).points(18_000);
|
verify(configManager).setRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.POINTS_KEY, 18_000);
|
||||||
assertEquals("", slayerPlugin.getTaskName());
|
assertEquals("", slayerPlugin.getTaskName());
|
||||||
assertEquals(0, slayerPlugin.getAmount());
|
assertEquals(0, slayerPlugin.getAmount());
|
||||||
}
|
}
|
||||||
@@ -919,7 +925,10 @@ public class SlayerPluginTest
|
|||||||
@Test
|
@Test
|
||||||
public void infoboxNotAddedOnLogin()
|
public void infoboxNotAddedOnLogin()
|
||||||
{
|
{
|
||||||
when(slayerConfig.taskName()).thenReturn(Task.BLOODVELD.getName());
|
when(slayerPlugin.getStringProfileConfig(SlayerConfig.TASK_NAME_KEY)).thenReturn(Task.BLOODVELD.getName());
|
||||||
|
when(slayerPlugin.getIntProfileConfig(SlayerConfig.AMOUNT_KEY)).thenReturn(50);
|
||||||
|
// Lenient required as this is not called assuming correct plugin logic
|
||||||
|
lenient().when(slayerConfig.showInfobox()).thenReturn(true);
|
||||||
|
|
||||||
GameStateChanged loggingIn = new GameStateChanged();
|
GameStateChanged loggingIn = new GameStateChanged();
|
||||||
loggingIn.setGameState(GameState.LOGGING_IN);
|
loggingIn.setGameState(GameState.LOGGING_IN);
|
||||||
|
|||||||
Reference in New Issue
Block a user