ChatFilterPlugin extends Plugin { @VisibleForTesting boolean shouldFilterByName(final String playerName) { String sanitizedName = Text.standardize(playerName); for (Pattern pattern : filteredNamePatterns) { Matcher m = pattern.matcher(sanitizedName); if (m.find()) { return true; } } return false; }  @Subscribe void onScriptCallbackEvent(ScriptCallbackEvent event); @Subscribe void onOverheadTextChanged(OverheadTextChanged event); @Subscribe(priority = -2) // run after ChatMessageManager void onChatMessage(ChatMessage chatMessage); @Subscribe void onConfigChanged(ConfigChanged event);  }
@Test public void testShouldFilterByName() { when(chatFilterConfig.filteredNames()).thenReturn("Gamble [0-9]*"); chatFilterPlugin.updateFilteredPatterns(); assertTrue(chatFilterPlugin.shouldFilterByName("Gamble 1234")); assertFalse(chatFilterPlugin.shouldFilterByName("Adam")); }