Skip to content

Commit

Permalink
Updated some faulty logic in the chat snitch parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLittleKitty committed Dec 26, 2016
1 parent 3bbea58 commit 053bd76
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void addAlertRecipient(IAlertRecipient recipient)
public void chatParser(ClientChatReceivedEvent event)
{
ITextComponent msg = event.getMessage();
if(event == null || msg == null)
if(msg == null)
return;

String msgText = msg.getUnformattedText();
Expand All @@ -74,32 +74,36 @@ public void chatParser(ClientChatReceivedEvent event)
return;
}

if(!updatingSnitchList)
return;

if (containsAny(msgText, resetSequences)) //Check if this is any of the reset messages (this is kind of quick)
//Only check for reset sequences or /jalist messages if we are updating
if(updatingSnitchList)
{
resetUpdatingSnitchList(true);
return;
if (containsAny(msgText, resetSequences)) //Check if this is any of the reset messages (this is kind of quick)
{
resetUpdatingSnitchList(true);
return;
}

//Check if this matches a snitch entry from the /jalist command (this is less quick than above)
if (tryParseJalistMsg(msg))
return;
}

//Check if this matches a snitch entry from the jalist command (this is less quick than above)
if (tryParseJalistMsg(msg))
//If there are no alert recipients then don't even bother checking if its a snitch alert
if (IAlertRecipients.isEmpty()) //Sometimes an optimization because it avoids building the alert object
return;

//Check if this matches the snitch alert message (slowest of all of these)
Matcher matcher = snitchAlertPattern.matcher(msgText);
if (!matcher.matches())
return;

if (IAlertRecipients.isEmpty()) //Sometimes an optimization because it avoids building the altert object
return;

//Build the snitch alert and send it to all the recipients
SnitchAlert alert = buildSnitchAlert(matcher, msg);
for (IAlertRecipient recipient : IAlertRecipients)
{
recipient.receiveSnitchAlert(alert);
}
//Set the alert's message to whatever the final message is from the alert "event"
event.setMessage(alert.getRawMessage());
}

Expand Down

0 comments on commit 053bd76

Please sign in to comment.