From 57d2ec531731992241f1f362b1ad6c13bc0538a7 Mon Sep 17 00:00:00 2001 From: Spedwards Date: Fri, 4 Jan 2019 09:12:24 +1100 Subject: [PATCH] Split Valuable and Untradeable screenshot options (#7167) --- .../plugins/screenshot/ScreenshotConfig.java | 15 +++++++++++++-- .../plugins/screenshot/ScreenshotPlugin.java | 19 +++++++++++++++---- .../screenshot/ScreenshotPluginTest.java | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotConfig.java index 5d26420889..aef1ea6b4c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotConfig.java @@ -157,7 +157,7 @@ public interface ScreenshotConfig extends Config @ConfigItem( keyName = "valuableDrop", name = "Screenshot Valuable drops", - description = "Configures whether or not screenshots are automatically taken when you receive a valuable/untradeable drop.", + description = "Configures whether or not screenshots are automatically taken when you receive a valuable drop.", position = 11 ) default boolean screenshotValuableDrop() @@ -165,11 +165,22 @@ public interface ScreenshotConfig extends Config return false; } + @ConfigItem( + keyName = "untradeableDrop", + name = "Screenshot Untradeable drops", + description = "Configures whether or not screenshots are automatically taken when you receive an untradeable drop.", + position = 12 + ) + default boolean screenshotUntradeableDrop() + { + return false; + } + @ConfigItem( keyName = "hotkey", name = "Screenshot hotkey", description = "When you press this key a screenshot will be taken", - position = 12 + position = 13 ) default Keybind hotkey() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java index 8632840831..6d53b1c366 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java @@ -121,7 +121,8 @@ 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: (\\d+)."); - private static final Pattern VALUABLE_DROP_PATTERN = Pattern.compile(".*(Valuable|Untradeable) drop: ([^<>]+)(?:)?"); + private static final Pattern VALUABLE_DROP_PATTERN = Pattern.compile(".*Valuable drop: ([^<>]+)(?:)?"); + private static final Pattern UNTRADEABLE_DROP_PATTERN = Pattern.compile(".*Untradeable drop: ([^<>]+)(?:)?"); private static final ImmutableList 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"); @@ -375,9 +376,19 @@ public class ScreenshotPlugin extends Plugin 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()); + String valuableDropName = m.group(1); + String fileName = "Valuable drop " + valuableDropName + " " + format(new Date()); + takeScreenshot(fileName); + } + } + + if (config.screenshotUntradeableDrop()) + { + Matcher m = UNTRADEABLE_DROP_PATTERN.matcher(chatMessage); + if (m.matches()) + { + String untradeableDropName = m.group(1); + String fileName = "Untradeable drop " + untradeableDropName + " " + format(new Date()); takeScreenshot(fileName); } } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/screenshot/ScreenshotPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/screenshot/ScreenshotPluginTest.java index 765ca672df..18e6e23700 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/screenshot/ScreenshotPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/screenshot/ScreenshotPluginTest.java @@ -104,6 +104,7 @@ public class ScreenshotPluginTest when(screenshotConfig.screenshotRewards()).thenReturn(true); when(screenshotConfig.screenshotLevels()).thenReturn(true); when(screenshotConfig.screenshotValuableDrop()).thenReturn(true); + when(screenshotConfig.screenshotUntradeableDrop()).thenReturn(true); } @Test