Split Valuable and Untradeable screenshot options (#7167)

This commit is contained in:
Spedwards
2019-01-04 09:12:24 +11:00
committed by Tomas Slusny
parent 8dc049e9a5
commit 57d2ec5317
3 changed files with 29 additions and 6 deletions

View File

@@ -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()
{

View File

@@ -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: <col=ff0000>(\\d+)</col>.");
private static final Pattern VALUABLE_DROP_PATTERN = Pattern.compile(".*(Valuable|Untradeable) drop: ([^<>]+)(?:</col>)?");
private static final Pattern VALUABLE_DROP_PATTERN = Pattern.compile(".*Valuable drop: ([^<>]+)(?:</col>)?");
private static final Pattern UNTRADEABLE_DROP_PATTERN = Pattern.compile(".*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");
@@ -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);
}
}

View File

@@ -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