Add option to screenshot duel wins and losses (#7576)

Fixes #7573
This commit is contained in:
Zakru
2019-01-29 11:28:29 +02:00
committed by Tomas Slusny
parent 5c0d3f073c
commit fe9409b9f3
3 changed files with 32 additions and 4 deletions

View File

@@ -116,6 +116,10 @@ public enum ChatMessageType
* A message received when somebody sends a trade offer.
*/
TRADE(101),
/**
* A message received when completing a trade or a duel
*/
TRANSACTION_COMPLETE(102),
/**
* A message received when somebody sends a duel offer.
*/

View File

@@ -154,11 +154,22 @@ public interface ScreenshotConfig extends Config
return false;
}
@ConfigItem(
keyName = "duels",
name = "Screenshot Duels",
description = "Configures whether or not screenshots are automatically taken of the duel end screen.",
position = 11
)
default boolean screenshotDuels()
{
return false;
}
@ConfigItem(
keyName = "valuableDrop",
name = "Screenshot Valuable drops",
description = "Configures whether or not screenshots are automatically taken when you receive a valuable drop.",
position = 11
position = 12
)
default boolean screenshotValuableDrop()
{
@@ -169,7 +180,7 @@ public interface ScreenshotConfig extends Config
keyName = "untradeableDrop",
name = "Screenshot Untradeable drops",
description = "Configures whether or not screenshots are automatically taken when you receive an untradeable drop.",
position = 12
position = 13
)
default boolean screenshotUntradeableDrop()
{
@@ -180,7 +191,7 @@ public interface ScreenshotConfig extends Config
keyName = "hotkey",
name = "Screenshot hotkey",
description = "When you press this key a screenshot will be taken",
position = 13
position = 14
)
default Keybind hotkey()
{

View File

@@ -123,6 +123,7 @@ public class ScreenshotPlugin extends Plugin
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 drop: ([^<>]+)(?:</col>)?");
private static final Pattern UNTRADEABLE_DROP_PATTERN = Pattern.compile(".*Untradeable drop: ([^<>]+)(?:</col>)?");
private static final Pattern DUEL_END_PATTERN = Pattern.compile("You have now (won|lost) ([0-9]+) duels?\\.");
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");
@@ -299,7 +300,7 @@ public class ScreenshotPlugin extends Plugin
@Subscribe
public void onChatMessage(ChatMessage event)
{
if (event.getType() != ChatMessageType.SERVER && event.getType() != ChatMessageType.FILTERED)
if (event.getType() != ChatMessageType.SERVER && event.getType() != ChatMessageType.FILTERED && event.getType() != ChatMessageType.TRANSACTION_COMPLETE)
{
return;
}
@@ -392,6 +393,18 @@ public class ScreenshotPlugin extends Plugin
takeScreenshot(fileName);
}
}
if (config.screenshotDuels())
{
Matcher m = DUEL_END_PATTERN.matcher(chatMessage);
if (m.find())
{
String result = m.group(1);
String count = m.group(2);
String fileName = "Duel " + result + " (" + count + ")";
takeScreenshot(fileName);
}
}
}
@Subscribe