Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
imDMK committed Aug 19, 2023
1 parent ed8bb7e commit 8b0698d
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ public AutoMessageCreateCommand(NotificationConfiguration notificationConfigurat
void createChat(CommandSender sender, @Joiner @Name("message") String message) {
ChatNotification chatNotification = new ChatNotification(message);

this.notificationConfiguration.autoMessages.add(chatNotification);

this.notificationSender.sendNotification(sender, this.createAddedNotification(chatNotification));
this.addAutoNotification(chatNotification);
this.sendAddedNotification(sender, chatNotification);
}

@Execute(route = "ACTIONBAR")
void createActionbar(CommandSender sender, @Joiner @Name("message") String message) {
ActionBarNotification actionBarNotification = new ActionBarNotification(message);

this.notificationConfiguration.autoMessages.add(actionBarNotification);

this.notificationSender.sendNotification(sender, this.createAddedNotification(actionBarNotification));
this.addAutoNotification(actionBarNotification);
this.sendAddedNotification(sender, actionBarNotification);
}

@Execute(route = "TITLE")
Expand All @@ -59,24 +57,28 @@ void createTitle(CommandSender sender, @Joiner @Name("message") String message)

TitleNotification titleNotification = new TitleNotification(splitMessage[0], splitMessage[1]);

this.notificationConfiguration.autoMessages.add(titleNotification);

this.notificationSender.sendNotification(sender, this.createAddedNotification(titleNotification));
this.addAutoNotification(titleNotification);
this.sendAddedNotification(sender, titleNotification);
}

@Execute(route = "BOSSBAR")
void createBossBar(CommandSender sender, @Arg @Name("time") Duration time, @Arg @By("bossBarProgress") @Name("progress") float progress, @Arg @Name("timeChangesProgress") boolean timeChangesProgress, @Arg @Name("color") BossBar.Color color, @Arg @Name("overlay") BossBar.Overlay overlay, @Joiner @Name("name") String name) {
BossBarNotification bossBarNotification = new BossBarNotification(name, time, progress, timeChangesProgress, color, overlay);

this.notificationConfiguration.autoMessages.add(bossBarNotification);
this.addAutoNotification(bossBarNotification);
this.sendAddedNotification(sender, bossBarNotification);
}

this.notificationSender.sendNotification(sender, this.createAddedNotification(bossBarNotification));
private void addAutoNotification(Notification notification) {
this.notificationConfiguration.autoMessages.add(notification);
}

private Notification createAddedNotification(Notification notification) {
return new NotificationFormatter(this.notificationConfiguration.autoMessageAddedNotification)
.placeholder("{TYPE}", notification.type().name().toUpperCase())
.placeholder("{POSITION}", this.notificationConfiguration.autoMessages.size() + 1)
private void sendAddedNotification(CommandSender sender, Notification addedNotification) {
Notification notification = new NotificationFormatter(this.notificationConfiguration.autoMessageAddedNotification)
.placeholder("{TYPE}", addedNotification.type().name().toUpperCase())
.placeholder("{POSITION}", this.notificationConfiguration.autoMessages.size())
.build();

this.notificationSender.sendNotification(sender, notification);
}
}

0 comments on commit 8b0698d

Please sign in to comment.