screenshot plugin: add screenshot on valuable/untradeable item drop
This commit is contained in:
@@ -154,11 +154,22 @@ public interface ScreenshotConfig extends Config
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "valuableDrop",
|
||||
name = "Screenshot Valuable drops",
|
||||
description = "Configures whether or not screenshots are automatically taken when you receive a valuable/untradeable drop.",
|
||||
position = 11
|
||||
)
|
||||
default boolean screenshotValuableDrop()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hotkey",
|
||||
name = "Screenshot hotkey",
|
||||
description = "When you press this key a screenshot will be taken",
|
||||
position = 11
|
||||
position = 12
|
||||
)
|
||||
default Keybind hotkey()
|
||||
{
|
||||
|
||||
@@ -119,6 +119,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
private static final Pattern NUMBER_PATTERN = Pattern.compile("([0-9]+)");
|
||||
private static final Pattern LEVEL_UP_PATTERN = Pattern.compile(".*Your ([a-zA-Z]+) (?:level is|are)? now (\\d+)\\.");
|
||||
private static final Pattern BOSSKILL_MESSAGE_PATTERN = Pattern.compile("Your (.+) kill count is: <col=ff0000>(\\d+)</col>.");
|
||||
private static final Pattern VALUABLE_DROP_PATTERN = Pattern.compile(".*(Valuable|Untradeable) drop: ([^<>]+)(?:</col>)?");
|
||||
private static final ImmutableList<String> PET_MESSAGES = ImmutableList.of("You have a funny feeling like you're being followed",
|
||||
"You feel something weird sneaking into your backpack",
|
||||
"You have a funny feeling like you would have been followed");
|
||||
@@ -366,6 +367,18 @@ public class ScreenshotPlugin extends Plugin
|
||||
takeScreenshot(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.screenshotValuableDrop())
|
||||
{
|
||||
Matcher m = VALUABLE_DROP_PATTERN.matcher(chatMessage);
|
||||
if (m.matches())
|
||||
{
|
||||
String valuableDropType = m.group(1);
|
||||
String valuableDropName = m.group(2);
|
||||
String fileName = valuableDropType + " drop " + valuableDropName + " " + format(new Date());
|
||||
takeScreenshot(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -63,6 +63,8 @@ public class ScreenshotPluginTest
|
||||
private static final String BARROWS_CHEST = "Your Barrows chest count is <col=ff0000>310</col>";
|
||||
private static final String CHAMBERS_OF_XERIC_CHEST = "Your completed Chambers of Xeric count is: <col=ff0000>489</col>.";
|
||||
private static final String THEATRE_OF_BLOOD_CHEST = "Your completed Theatre of Blood count is: <col=ff0000>73</col>.";
|
||||
private static final String VALUABLE_DROP = "<col=ef1020>Valuable drop: 6 x Bronze arrow (42 coins)</col>";
|
||||
private static final String UNTRADEABLE_DROP = "<col=ef1020>Untradeable drop: Rusty sword";
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
@@ -101,6 +103,7 @@ public class ScreenshotPluginTest
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
when(screenshotConfig.screenshotRewards()).thenReturn(true);
|
||||
when(screenshotConfig.screenshotLevels()).thenReturn(true);
|
||||
when(screenshotConfig.screenshotValuableDrop()).thenReturn(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -140,6 +143,24 @@ public class ScreenshotPluginTest
|
||||
assertEquals(73, screenshotPlugin.gettheatreOfBloodNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValuableDrop()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "", VALUABLE_DROP, null);
|
||||
screenshotPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUntradeableDrop()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "", UNTRADEABLE_DROP, null);
|
||||
screenshotPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHitpointsLevel99()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user