Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
imDMK committed Jul 17, 2023
1 parent 84c24c6 commit e48094b
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/main/java/me/dmk/automessage/task/AutoMessageTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ public void run() {
return;
}

Optional<Notification> selectedNotificationOptional = this.selectNotification();
if (selectedNotificationOptional.isEmpty()) {
return;
}

Notification selectedNotification = selectedNotificationOptional.get();
this.notificationSender.broadcast(selectedNotification);
this.selectNotification().ifPresent(this.notificationSender::broadcast);
}

private Optional<Notification> selectNotification() {
Expand All @@ -52,11 +46,11 @@ private Optional<Notification> selectRandomNotification() {
}

private Optional<Notification> selectNextNotification() {
List<Notification> notifications = this.pluginConfiguration.autoMessages;
List<Notification> autoMessages = this.pluginConfiguration.autoMessages;

int position = this.position.getAndIncrement() % notifications.size();
int position = this.position.getAndIncrement() % autoMessages.size();

return notifications.stream()
return autoMessages.stream()
.skip(position)
.findFirst();
}
Expand Down

0 comments on commit e48094b

Please sign in to comment.