Slayer plugin: Added support for slayer bracelets.
This commit is contained in:
@@ -78,6 +78,8 @@ public class SlayerPlugin extends Plugin
|
|||||||
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...";
|
private static final String CHAT_SUPERIOR_MESSAGE = "A superior foe has appeared...";
|
||||||
|
private static final String CHAT_BRACELET_SLAUGHTER = "Your bracelet of slaughter prevents your slayer count decreasing.";
|
||||||
|
private static final String CHAT_BRACELET_EXPEDITIOUS = "Your expeditious bracelet helps you progress your slayer task faster.";
|
||||||
|
|
||||||
//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*) (.*)\\.");
|
||||||
@@ -243,12 +245,23 @@ public class SlayerPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onChatMessage(ChatMessage event)
|
public void onChatMessage(ChatMessage event)
|
||||||
{
|
{
|
||||||
if (event.getType() != ChatMessageType.SERVER)
|
if (event.getType() != ChatMessageType.SERVER && event.getType() != ChatMessageType.FILTERED)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String chatMsg = Text.removeTags(event.getMessage()); //remove color and linebreaks
|
String chatMsg = Text.removeTags(event.getMessage()); //remove color and linebreaks
|
||||||
|
|
||||||
|
if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER))
|
||||||
|
{
|
||||||
|
amount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS))
|
||||||
|
{
|
||||||
|
amount--;
|
||||||
|
}
|
||||||
|
|
||||||
if (chatMsg.endsWith("; return to a Slayer master."))
|
if (chatMsg.endsWith("; return to a Slayer master."))
|
||||||
{
|
{
|
||||||
Matcher mComplete = CHAT_COMPLETE_MESSAGE.matcher(chatMsg);
|
Matcher mComplete = CHAT_COMPLETE_MESSAGE.matcher(chatMsg);
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ public class SlayerPluginTest
|
|||||||
|
|
||||||
private static final String SUPERIOR_MESSAGE = "A superior foe has appeared...";
|
private static final String SUPERIOR_MESSAGE = "A superior foe has appeared...";
|
||||||
|
|
||||||
|
private static final String BRACLET_SLAUGHTER = "Your bracelet of slaughter prevents your slayer count decreasing.";
|
||||||
|
private static final String BRACLET_EXPEDITIOUS = "Your expeditious bracelet helps you progress your slayer task faster.";
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
Client client;
|
Client client;
|
||||||
@@ -163,4 +166,28 @@ public class SlayerPluginTest
|
|||||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
verifyNoMoreInteractions(notifier);
|
verifyNoMoreInteractions(notifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBracletSlaughter()
|
||||||
|
{
|
||||||
|
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "", BRACLET_SLAUGHTER, null);
|
||||||
|
|
||||||
|
slayerPlugin.setAmount(42);
|
||||||
|
|
||||||
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
|
assertEquals(43, slayerPlugin.getAmount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBraceletExpeditious()
|
||||||
|
{
|
||||||
|
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "", BRACLET_EXPEDITIOUS, null);
|
||||||
|
|
||||||
|
slayerPlugin.setAmount(42);
|
||||||
|
|
||||||
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
|
assertEquals(41, slayerPlugin.getAmount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user