Merge pull request #884 from xaviergmail/superior-foes
Add slayer superior foe notification
This commit is contained in:
@@ -55,6 +55,16 @@ public interface SlayerConfig extends Config
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "superiornotification",
|
||||||
|
name = "Superior foe notification",
|
||||||
|
description = "Toggles notifications on superior foe encounters"
|
||||||
|
)
|
||||||
|
default boolean showSuperiorNotification()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Stored data
|
// Stored data
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "taskName",
|
keyName = "taskName",
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import net.runelite.api.events.ExperienceChanged;
|
|||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
@@ -66,6 +67,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
private static final String CHAT_GEM_COMPLETE_MESSAGE = "You need something new to hunt.";
|
private static final String CHAT_GEM_COMPLETE_MESSAGE = "You need something new to hunt.";
|
||||||
private static final Pattern CHAT_COMPLETE_MESSAGE = Pattern.compile("[\\d]+(?:,[\\d]+)?");
|
private static final Pattern CHAT_COMPLETE_MESSAGE = Pattern.compile("[\\d]+(?:,[\\d]+)?");
|
||||||
private static final String CHAT_CANCEL_MESSAGE = "Your task has been cancelled.";
|
private static final String CHAT_CANCEL_MESSAGE = "Your task has been cancelled.";
|
||||||
|
private static final String CHAT_SUPERIOR_MESSAGE = "A superior foe has appeared...";
|
||||||
|
|
||||||
//NPC messages
|
//NPC messages
|
||||||
private static final Pattern NPC_ASSIGN_MESSAGE = Pattern.compile(".*Your new task is to kill (\\d*) (.*)\\.");
|
private static final Pattern NPC_ASSIGN_MESSAGE = Pattern.compile(".*Your new task is to kill (\\d*) (.*)\\.");
|
||||||
@@ -89,6 +91,9 @@ public class SlayerPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private ItemManager itemManager;
|
private ItemManager itemManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Notifier notifier;
|
||||||
|
|
||||||
private String taskName;
|
private String taskName;
|
||||||
private int amount;
|
private int amount;
|
||||||
private TaskCounter counter;
|
private TaskCounter counter;
|
||||||
@@ -230,6 +235,12 @@ public class SlayerPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.showSuperiorNotification() && chatMsg.equals(CHAT_SUPERIOR_MESSAGE))
|
||||||
|
{
|
||||||
|
notifier.notify(CHAT_SUPERIOR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Matcher mProgress = CHAT_GEM_PROGRESS_MESSAGE.matcher(chatMsg);
|
Matcher mProgress = CHAT_GEM_PROGRESS_MESSAGE.matcher(chatMsg);
|
||||||
if (!mProgress.find())
|
if (!mProgress.find())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,22 +24,27 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.slayer;
|
package net.runelite.client.plugins.slayer;
|
||||||
|
|
||||||
import static net.runelite.api.ChatMessageType.SERVER;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.testing.fieldbinder.Bind;
|
import com.google.inject.testing.fieldbinder.Bind;
|
||||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import static net.runelite.api.ChatMessageType.SERVER;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class SlayerPluginTest
|
public class SlayerPluginTest
|
||||||
{
|
{
|
||||||
@@ -50,6 +55,8 @@ public class SlayerPluginTest
|
|||||||
private static final String TASK_COMPLETE = "You need something new to hunt.";
|
private static final String TASK_COMPLETE = "You need something new to hunt.";
|
||||||
private static final String TASK_CANCELED = "Your task has been cancelled.";
|
private static final String TASK_CANCELED = "Your task has been cancelled.";
|
||||||
|
|
||||||
|
private static final String SUPERIOR_MESSAGE = "A superior foe has appeared...";
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
Client client;
|
Client client;
|
||||||
@@ -70,6 +77,10 @@ public class SlayerPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
ItemManager itemManager;
|
ItemManager itemManager;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
Notifier notifier;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SlayerPlugin slayerPlugin;
|
SlayerPlugin slayerPlugin;
|
||||||
|
|
||||||
@@ -138,4 +149,18 @@ public class SlayerPluginTest
|
|||||||
assertEquals("", slayerPlugin.getTaskName());
|
assertEquals("", slayerPlugin.getTaskName());
|
||||||
assertEquals(0, slayerPlugin.getAmount());
|
assertEquals(0, slayerPlugin.getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuperiorNotification()
|
||||||
|
{
|
||||||
|
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "Superior", SUPERIOR_MESSAGE, null);
|
||||||
|
|
||||||
|
when(slayerConfig.showSuperiorNotification()).thenReturn(true);
|
||||||
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
verify(notifier).notify(SUPERIOR_MESSAGE);
|
||||||
|
|
||||||
|
when(slayerConfig.showSuperiorNotification()).thenReturn(false);
|
||||||
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
verifyNoMoreInteractions(notifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user