@Test public void testSuperiorNotification() { ChatMessage chatMessageEvent = new ChatMessage(SERVER, "Superior", SUPERIOR_MESSAGE, null); when(slayerConfig.showSuperiorNotification()).thenReturn(true); slayerPlugin.onChatMessage(chatMessageEvent); verify(notifier).notify(SUPERIOR_MESSAGE); when(slayerConfig.showSuperiorNotification()).thenReturn(false); slayerPlugin.onChatMessage(chatMessageEvent); verifyNoMoreInteractions(notifier); }
@Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.SERVER && event.getType() != ChatMessageType.FILTERED) { return; } String chatMsg = Text.removeTags(event.getMessage()); if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER)) { amount++; slaughterChargeCount = --slaughterChargeCount <= 0 ? SLAUGHTER_CHARGE : slaughterChargeCount; config.slaughter(slaughterChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS)) { amount--; expeditiousChargeCount = --expeditiousChargeCount <= 0 ? EXPEDITIOUS_CHARGE : expeditiousChargeCount; config.expeditious(expeditiousChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS_CHARGE)) { expeditiousChargeCount = Integer.parseInt(chatMsg .replace(CHAT_BRACELET_EXPEDITIOUS_CHARGE, "") .replace(" charges left.", "")); config.expeditious(expeditiousChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER_CHARGE)) { slaughterChargeCount = Integer.parseInt(chatMsg .replace(CHAT_BRACELET_SLAUGHTER_CHARGE, "") .replace(" charges left.", "")); config.slaughter(slaughterChargeCount); } if (chatMsg.endsWith("; return to a Slayer master.")) { Matcher mComplete = CHAT_COMPLETE_MESSAGE.matcher(chatMsg); List<String> matches = new ArrayList<>(); while (mComplete.find()) { matches.add(mComplete.group(0)); } switch (matches.size()) { case 0: streak = 1; break; case 1: streak = Integer.parseInt(matches.get(0)); break; case 3: streak = Integer.parseInt(matches.get(0)); points = Integer.parseInt(matches.get(2).replaceAll(",", "")); break; default: log.warn("Unreachable default case for message ending in '; return to Slayer master'"); } setTask("", 0); return; } if (chatMsg.equals(CHAT_GEM_COMPLETE_MESSAGE) || chatMsg.equals(CHAT_CANCEL_MESSAGE)) { setTask("", 0); return; } if (config.showSuperiorNotification() && chatMsg.equals(CHAT_SUPERIOR_MESSAGE)) { notifier.notify(CHAT_SUPERIOR_MESSAGE); return; } Matcher mProgress = CHAT_GEM_PROGRESS_MESSAGE.matcher(chatMsg); if (!mProgress.find()) { return; } String taskName = mProgress.group(1); int amount = Integer.parseInt(mProgress.group(2)); setTask(taskName, amount); }
SlayerPlugin extends Plugin { @Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.SERVER && event.getType() != ChatMessageType.FILTERED) { return; } String chatMsg = Text.removeTags(event.getMessage()); if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER)) { amount++; slaughterChargeCount = --slaughterChargeCount <= 0 ? SLAUGHTER_CHARGE : slaughterChargeCount; config.slaughter(slaughterChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS)) { amount--; expeditiousChargeCount = --expeditiousChargeCount <= 0 ? EXPEDITIOUS_CHARGE : expeditiousChargeCount; config.expeditious(expeditiousChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS_CHARGE)) { expeditiousChargeCount = Integer.parseInt(chatMsg .replace(CHAT_BRACELET_EXPEDITIOUS_CHARGE, "") .replace(" charges left.", "")); config.expeditious(expeditiousChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER_CHARGE)) { slaughterChargeCount = Integer.parseInt(chatMsg .replace(CHAT_BRACELET_SLAUGHTER_CHARGE, "") .replace(" charges left.", "")); config.slaughter(slaughterChargeCount); } if (chatMsg.endsWith("; return to a Slayer master.")) { Matcher mComplete = CHAT_COMPLETE_MESSAGE.matcher(chatMsg); List<String> matches = new ArrayList<>(); while (mComplete.find()) { matches.add(mComplete.group(0)); } switch (matches.size()) { case 0: streak = 1; break; case 1: streak = Integer.parseInt(matches.get(0)); break; case 3: streak = Integer.parseInt(matches.get(0)); points = Integer.parseInt(matches.get(2).replaceAll(",", "")); break; default: log.warn("Unreachable default case for message ending in '; return to Slayer master'"); } setTask("", 0); return; } if (chatMsg.equals(CHAT_GEM_COMPLETE_MESSAGE) || chatMsg.equals(CHAT_CANCEL_MESSAGE)) { setTask("", 0); return; } if (config.showSuperiorNotification() && chatMsg.equals(CHAT_SUPERIOR_MESSAGE)) { notifier.notify(CHAT_SUPERIOR_MESSAGE); return; } Matcher mProgress = CHAT_GEM_PROGRESS_MESSAGE.matcher(chatMsg); if (!mProgress.find()) { return; } String taskName = mProgress.group(1); int amount = Integer.parseInt(mProgress.group(2)); setTask(taskName, amount); } }
SlayerPlugin extends Plugin { @Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.SERVER && event.getType() != ChatMessageType.FILTERED) { return; } String chatMsg = Text.removeTags(event.getMessage()); if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER)) { amount++; slaughterChargeCount = --slaughterChargeCount <= 0 ? SLAUGHTER_CHARGE : slaughterChargeCount; config.slaughter(slaughterChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS)) { amount--; expeditiousChargeCount = --expeditiousChargeCount <= 0 ? EXPEDITIOUS_CHARGE : expeditiousChargeCount; config.expeditious(expeditiousChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS_CHARGE)) { expeditiousChargeCount = Integer.parseInt(chatMsg .replace(CHAT_BRACELET_EXPEDITIOUS_CHARGE, "") .replace(" charges left.", "")); config.expeditious(expeditiousChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER_CHARGE)) { slaughterChargeCount = Integer.parseInt(chatMsg .replace(CHAT_BRACELET_SLAUGHTER_CHARGE, "") .replace(" charges left.", "")); config.slaughter(slaughterChargeCount); } if (chatMsg.endsWith("; return to a Slayer master.")) { Matcher mComplete = CHAT_COMPLETE_MESSAGE.matcher(chatMsg); List<String> matches = new ArrayList<>(); while (mComplete.find()) { matches.add(mComplete.group(0)); } switch (matches.size()) { case 0: streak = 1; break; case 1: streak = Integer.parseInt(matches.get(0)); break; case 3: streak = Integer.parseInt(matches.get(0)); points = Integer.parseInt(matches.get(2).replaceAll(",", "")); break; default: log.warn("Unreachable default case for message ending in '; return to Slayer master'"); } setTask("", 0); return; } if (chatMsg.equals(CHAT_GEM_COMPLETE_MESSAGE) || chatMsg.equals(CHAT_CANCEL_MESSAGE)) { setTask("", 0); return; } if (config.showSuperiorNotification() && chatMsg.equals(CHAT_SUPERIOR_MESSAGE)) { notifier.notify(CHAT_SUPERIOR_MESSAGE); return; } Matcher mProgress = CHAT_GEM_PROGRESS_MESSAGE.matcher(chatMsg); if (!mProgress.find()) { return; } String taskName = mProgress.group(1); int amount = Integer.parseInt(mProgress.group(2)); setTask(taskName, amount); }  }
SlayerPlugin extends Plugin { @Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.SERVER && event.getType() != ChatMessageType.FILTERED) { return; } String chatMsg = Text.removeTags(event.getMessage()); if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER)) { amount++; slaughterChargeCount = --slaughterChargeCount <= 0 ? SLAUGHTER_CHARGE : slaughterChargeCount; config.slaughter(slaughterChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS)) { amount--; expeditiousChargeCount = --expeditiousChargeCount <= 0 ? EXPEDITIOUS_CHARGE : expeditiousChargeCount; config.expeditious(expeditiousChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS_CHARGE)) { expeditiousChargeCount = Integer.parseInt(chatMsg .replace(CHAT_BRACELET_EXPEDITIOUS_CHARGE, "") .replace(" charges left.", "")); config.expeditious(expeditiousChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER_CHARGE)) { slaughterChargeCount = Integer.parseInt(chatMsg .replace(CHAT_BRACELET_SLAUGHTER_CHARGE, "") .replace(" charges left.", "")); config.slaughter(slaughterChargeCount); } if (chatMsg.endsWith("; return to a Slayer master.")) { Matcher mComplete = CHAT_COMPLETE_MESSAGE.matcher(chatMsg); List<String> matches = new ArrayList<>(); while (mComplete.find()) { matches.add(mComplete.group(0)); } switch (matches.size()) { case 0: streak = 1; break; case 1: streak = Integer.parseInt(matches.get(0)); break; case 3: streak = Integer.parseInt(matches.get(0)); points = Integer.parseInt(matches.get(2).replaceAll(",", "")); break; default: log.warn("Unreachable default case for message ending in '; return to Slayer master'"); } setTask("", 0); return; } if (chatMsg.equals(CHAT_GEM_COMPLETE_MESSAGE) || chatMsg.equals(CHAT_CANCEL_MESSAGE)) { setTask("", 0); return; } if (config.showSuperiorNotification() && chatMsg.equals(CHAT_SUPERIOR_MESSAGE)) { notifier.notify(CHAT_SUPERIOR_MESSAGE); return; } Matcher mProgress = CHAT_GEM_PROGRESS_MESSAGE.matcher(chatMsg); if (!mProgress.find()) { return; } String taskName = mProgress.group(1); int amount = Integer.parseInt(mProgress.group(2)); setTask(taskName, amount); }  @Subscribe void onGameStateChange(GameStateChanged event); @Subscribe void onGameTick(GameTick tick); @Subscribe void onChatMessage(ChatMessage event); @Subscribe void onExperienceChanged(ExperienceChanged event); @Override Collection<Overlay> getOverlays(); String getTaskName(); int getAmount(); int getStreak(); int getPoints(); }
SlayerPlugin extends Plugin { @Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.SERVER && event.getType() != ChatMessageType.FILTERED) { return; } String chatMsg = Text.removeTags(event.getMessage()); if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER)) { amount++; slaughterChargeCount = --slaughterChargeCount <= 0 ? SLAUGHTER_CHARGE : slaughterChargeCount; config.slaughter(slaughterChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS)) { amount--; expeditiousChargeCount = --expeditiousChargeCount <= 0 ? EXPEDITIOUS_CHARGE : expeditiousChargeCount; config.expeditious(expeditiousChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS_CHARGE)) { expeditiousChargeCount = Integer.parseInt(chatMsg .replace(CHAT_BRACELET_EXPEDITIOUS_CHARGE, "") .replace(" charges left.", "")); config.expeditious(expeditiousChargeCount); } if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER_CHARGE)) { slaughterChargeCount = Integer.parseInt(chatMsg .replace(CHAT_BRACELET_SLAUGHTER_CHARGE, "") .replace(" charges left.", "")); config.slaughter(slaughterChargeCount); } if (chatMsg.endsWith("; return to a Slayer master.")) { Matcher mComplete = CHAT_COMPLETE_MESSAGE.matcher(chatMsg); List<String> matches = new ArrayList<>(); while (mComplete.find()) { matches.add(mComplete.group(0)); } switch (matches.size()) { case 0: streak = 1; break; case 1: streak = Integer.parseInt(matches.get(0)); break; case 3: streak = Integer.parseInt(matches.get(0)); points = Integer.parseInt(matches.get(2).replaceAll(",", "")); break; default: log.warn("Unreachable default case for message ending in '; return to Slayer master'"); } setTask("", 0); return; } if (chatMsg.equals(CHAT_GEM_COMPLETE_MESSAGE) || chatMsg.equals(CHAT_CANCEL_MESSAGE)) { setTask("", 0); return; } if (config.showSuperiorNotification() && chatMsg.equals(CHAT_SUPERIOR_MESSAGE)) { notifier.notify(CHAT_SUPERIOR_MESSAGE); return; } Matcher mProgress = CHAT_GEM_PROGRESS_MESSAGE.matcher(chatMsg); if (!mProgress.find()) { return; } String taskName = mProgress.group(1); int amount = Integer.parseInt(mProgress.group(2)); setTask(taskName, amount); }  @Subscribe void onGameStateChange(GameStateChanged event); @Subscribe void onGameTick(GameTick tick); @Subscribe void onChatMessage(ChatMessage event); @Subscribe void onExperienceChanged(ExperienceChanged event); @Override Collection<Overlay> getOverlays(); String getTaskName(); int getAmount(); int getStreak(); int getPoints();  }