ScreenshotPlugin extends Plugin { @VisibleForTesting static String parseQuestCompletedWidget(final String text) { final Matcher questMatch1 = QUEST_PATTERN_1.matcher(text); final Matcher questMatch2 = QUEST_PATTERN_2.matcher(text); final Matcher questMatchFinal = questMatch1.matches() ? questMatch1 : questMatch2; if (!questMatchFinal.matches()) { return "Quest(quest not found)"; } String quest = questMatchFinal.group("quest"); String verb = questMatchFinal.group("verb") != null ? questMatchFinal.group("verb") : ""; if (verb.contains("kind of")) { quest += " partial completion"; } else if (verb.contains("completely")) { quest += " II"; } if (RFD_TAGS.stream().anyMatch((quest + verb)::contains)) { quest = "Recipe for Disaster - " + quest; } if (WORD_QUEST_IN_NAME_TAGS.stream().anyMatch(quest::contains)) { quest += " Quest"; } return "Quest(" + quest + ')'; }  @Subscribe void onGameTick(GameTick event); @Subscribe void onActorDeath(ActorDeath actorDeath); @Subscribe void onPlayerLootReceived(final PlayerLootReceived playerLootReceived); @Subscribe void onScriptCallbackEvent(ScriptCallbackEvent e); @Subscribe void onChatMessage(ChatMessage event); @Subscribe void onWidgetLoaded(WidgetLoaded event);  }
@Test public void testQuestParsing() { assertEquals("Quest(The Corsair Curse)", ScreenshotPlugin.parseQuestCompletedWidget("You have completed The Corsair Curse!")); assertEquals("Quest(One Small Favour)", ScreenshotPlugin.parseQuestCompletedWidget("'One Small Favour' completed!")); assertEquals("Quest(Hazeel Cult partial completion)", ScreenshotPlugin.parseQuestCompletedWidget("You have... kind of... completed the Hazeel Cult Quest!")); assertEquals("Quest(Rag and Bone Man II)", ScreenshotPlugin.parseQuestCompletedWidget("You have completely completed Rag and Bone Man!")); assertEquals("Quest(Recipe for Disaster - Culinaromancer)", ScreenshotPlugin.parseQuestCompletedWidget("Congratulations! You have defeated the Culinaromancer!")); assertEquals("Quest(Recipe for Disaster - Another Cook's Quest)", ScreenshotPlugin.parseQuestCompletedWidget("You have completed Another Cook's Quest!")); assertEquals("Quest(Doric's Quest)", ScreenshotPlugin.parseQuestCompletedWidget("You have completed Doric's Quest!")); assertEquals("Quest(quest not found)", ScreenshotPlugin.parseQuestCompletedWidget("Sins of the Father forgiven!")); }