chat notifications: load highlights on start

This commit is contained in:
Adam
2018-06-13 13:09:35 -04:00
parent e8f6a13d13
commit 01eeb31d20

View File

@@ -74,6 +74,12 @@ public class ChatNotificationsPlugin extends Plugin
return configManager.getConfig(ChatNotificationsConfig.class); return configManager.getConfig(ChatNotificationsConfig.class);
} }
@Override
public void startUp()
{
updateHighlights();
}
@Subscribe @Subscribe
public void onGameStateChanged(GameStateChanged event) public void onGameStateChanged(GameStateChanged event)
{ {
@@ -91,16 +97,21 @@ public class ChatNotificationsPlugin extends Plugin
{ {
if (event.getGroup().equals("chatnotification")) if (event.getGroup().equals("chatnotification"))
{ {
highlightMatcher = null; updateHighlights();
}
}
if (!config.highlightWordsString().trim().equals("")) private void updateHighlights()
{ {
String[] items = config.highlightWordsString().trim().split(", "); highlightMatcher = null;
String joined = Arrays.stream(items)
.map(Pattern::quote) if (!config.highlightWordsString().trim().equals(""))
.collect(Collectors.joining("|")); {
highlightMatcher = Pattern.compile("\\b(" + joined + ")\\b", Pattern.CASE_INSENSITIVE); String[] items = config.highlightWordsString().trim().split(", ");
} String joined = Arrays.stream(items)
.map(Pattern::quote)
.collect(Collectors.joining("|"));
highlightMatcher = Pattern.compile("\\b(" + joined + ")\\b", Pattern.CASE_INSENSITIVE);
} }
} }