Skip to content

Commit

Permalink
Stop while sending msg
Browse files Browse the repository at this point in the history
  • Loading branch information
Elikill58 committed Oct 18, 2023
1 parent a35a5fd commit c007c3c
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -47,7 +49,7 @@ public void close() {
public String getWebhookName() {
return name;
}

/**
* Add message to queue of given webhook
*
Expand Down Expand Up @@ -91,10 +93,12 @@ public void runQueue() {
}
combinedMessages.add(msg);
}
combinedMessages.stream().collect(Collectors.groupingBy(WebhookMessage::getMessageType, Collectors.groupingBy(WebhookMessage::getConcerned, Collectors.toList()))).forEach((type, messagesPerPlayer) -> {
messagesPerPlayer.forEach((p, web) -> send(type, p, web));
});

for(Entry<WebhookMessageType, Map<Player, List<WebhookMessage>>> entries : combinedMessages.stream().collect(Collectors.groupingBy(WebhookMessage::getMessageType, Collectors.groupingBy(WebhookMessage::getConcerned, Collectors.toList()))).entrySet()) {
if (time > System.currentTimeMillis())
return;
entries.getValue().forEach((p, web) -> send(entries.getKey(), p, web));
}

}

/**
Expand Down

0 comments on commit c007c3c

Please sign in to comment.