55import  com .eternalcode .core .notice .NoticeService ;
66import  com .eternalcode .core .notice .NoticeTextType ;
77import  dev .rollczi .litecommands .annotations .argument .Arg ;
8+ import  dev .rollczi .litecommands .annotations .command .Command ;
89import  dev .rollczi .litecommands .annotations .context .Sender ;
9- import  dev .rollczi .litecommands .annotations .join .Join ;
1010import  dev .rollczi .litecommands .annotations .execute .Execute ;
11+ import  dev .rollczi .litecommands .annotations .join .Join ;
1112import  dev .rollczi .litecommands .annotations .literal .Literal ;
1213import  dev .rollczi .litecommands .annotations .permission .Permission ;
13- import  dev .rollczi .litecommands .annotations .command .Command ;
14- import  org .bukkit .entity .Player ;
15- 
1614import  java .time .Duration ;
1715import  java .util .Optional ;
16+ import  java .util .UUID ;
17+ import  org .bukkit .entity .Player ;
1818
19- @ Command (name  = "alert-queue" , aliases  = {  "alert-q"   })
19+ @ Command (name  = "alert-queue" , aliases  = {"alert-q" })
2020@ Permission ("eternalcore.alert.queue" )
2121class  AlertQueueCommand  {
2222
@@ -35,11 +35,11 @@ class AlertQueueCommand {
3535    @ Execute (name  = "add" )
3636    @ DescriptionDocs (description  = "Adds alert to the queue with specified notice type and messages" , arguments  = "<type> <message>" )
3737    void  executeAdd (@ Sender  Player  sender , @ Arg  NoticeTextType  type , @ Join  String  text ) {
38- 
39-         this . alertService . addBroadcast ( sender .getUniqueId (), type , this .noticeService .create ()
40-             .notice (type , translation  -> translation .chat ().alertMessageFormat ())
41-             .placeholder ("{BROADCAST}" , text )
42-             .onlinePlayers ());
38+          this . alertService . addBroadcast ( 
39+              sender .getUniqueId (), type , this .noticeService .create ()
40+                  .notice (type , translation  -> translation .chat ().alertMessageFormat ())
41+                  .placeholder ("{BROADCAST}" , text )
42+                  .onlinePlayers ());
4343
4444        this .noticeService .create ()
4545            .player (sender .getUniqueId ())
@@ -54,7 +54,9 @@ void executeRemoveAll(@Sender Player sender, @Arg NoticeTextType type, @Literal(
5454
5555        this .noticeService .create ()
5656            .player (sender .getUniqueId ())
57-             .notice (translation  -> success  ? translation .chat ().alertQueueRemoved () : translation .chat ().alertQueueEmpty ())
57+             .notice (translation  -> success 
58+                 ? translation .chat ().alertQueueRemovedAll ()
59+                 : translation .chat ().alertQueueEmpty ())
5860            .send ();
5961    }
6062
@@ -65,13 +67,23 @@ void executeRemove(@Sender Player sender, @Arg NoticeTextType type, @Literal("la
6567
6668        this .noticeService .create ()
6769            .player (sender .getUniqueId ())
68-             .notice (translation  -> success  ? translation .chat ().alertQueueRemoved () : translation .chat ().alertQueueEmpty ())
70+             .notice (translation  -> success 
71+                 ? translation .chat ().alertQueueRemovedSingle ()
72+                 : translation .chat ().alertQueueEmpty ())
6973            .send ();
7074    }
7175
7276    @ Execute (name  = "clear" )
7377    @ DescriptionDocs (description  = "Clears all alerts from the queue" )
7478    void  executeClear (@ Sender  Player  sender ) {
79+         if  (this .alertService .hasNoBroadcasts (sender .getUniqueId ())) {
80+             this .noticeService .create ()
81+                 .player (sender .getUniqueId ())
82+                 .notice (translation  -> translation .chat ().alertQueueEmpty ())
83+                 .send ();
84+             return ;
85+         }
86+ 
7587        this .alertService .clearBroadcasts (sender .getUniqueId ());
7688        this .noticeService .create ()
7789            .player (sender .getUniqueId ())
@@ -82,7 +94,17 @@ void executeClear(@Sender Player sender) {
8294    @ Execute (name  = "send" )
8395    @ DescriptionDocs (description  = "Sends all alerts from the queue" )
8496    void  executeSend (@ Sender  Player  sender , @ Arg  Optional <Duration > duration ) {
85-         this .alertService .send (sender .getUniqueId (), duration .orElse (Duration .ofSeconds (2 )));
97+         UUID  uniqueId  = sender .getUniqueId ();
98+ 
99+         if  (this .alertService .hasNoBroadcasts (sender .getUniqueId ())) {
100+             this .noticeService .create ()
101+                 .player (uniqueId )
102+                 .notice (translation  -> translation .chat ().alertQueueEmpty ())
103+                 .send ();
104+             return ;
105+         }
106+ 
107+         this .alertService .send (uniqueId , duration .orElse (Duration .ofSeconds (2 )));
86108        this .noticeService .create ()
87109            .player (sender .getUniqueId ())
88110            .notice (translation  -> translation .chat ().alertQueueSent ())
0 commit comments