5
5
import com .eternalcode .core .notice .NoticeService ;
6
6
import com .eternalcode .core .notice .NoticeTextType ;
7
7
import dev .rollczi .litecommands .annotations .argument .Arg ;
8
+ import dev .rollczi .litecommands .annotations .command .Command ;
8
9
import dev .rollczi .litecommands .annotations .context .Sender ;
9
- import dev .rollczi .litecommands .annotations .join .Join ;
10
10
import dev .rollczi .litecommands .annotations .execute .Execute ;
11
+ import dev .rollczi .litecommands .annotations .join .Join ;
11
12
import dev .rollczi .litecommands .annotations .literal .Literal ;
12
13
import dev .rollczi .litecommands .annotations .permission .Permission ;
13
- import dev .rollczi .litecommands .annotations .command .Command ;
14
- import org .bukkit .entity .Player ;
15
-
16
14
import java .time .Duration ;
17
15
import java .util .Optional ;
16
+ import java .util .UUID ;
17
+ import org .bukkit .entity .Player ;
18
18
19
- @ Command (name = "alert-queue" , aliases = { "alert-q" })
19
+ @ Command (name = "alert-queue" , aliases = {"alert-q" })
20
20
@ Permission ("eternalcore.alert.queue" )
21
21
class AlertQueueCommand {
22
22
@@ -35,11 +35,11 @@ class AlertQueueCommand {
35
35
@ Execute (name = "add" )
36
36
@ DescriptionDocs (description = "Adds alert to the queue with specified notice type and messages" , arguments = "<type> <message>" )
37
37
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 ());
43
43
44
44
this .noticeService .create ()
45
45
.player (sender .getUniqueId ())
@@ -54,7 +54,9 @@ void executeRemoveAll(@Sender Player sender, @Arg NoticeTextType type, @Literal(
54
54
55
55
this .noticeService .create ()
56
56
.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 ())
58
60
.send ();
59
61
}
60
62
@@ -65,13 +67,23 @@ void executeRemove(@Sender Player sender, @Arg NoticeTextType type, @Literal("la
65
67
66
68
this .noticeService .create ()
67
69
.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 ())
69
73
.send ();
70
74
}
71
75
72
76
@ Execute (name = "clear" )
73
77
@ DescriptionDocs (description = "Clears all alerts from the queue" )
74
78
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
+
75
87
this .alertService .clearBroadcasts (sender .getUniqueId ());
76
88
this .noticeService .create ()
77
89
.player (sender .getUniqueId ())
@@ -82,7 +94,17 @@ void executeClear(@Sender Player sender) {
82
94
@ Execute (name = "send" )
83
95
@ DescriptionDocs (description = "Sends all alerts from the queue" )
84
96
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 )));
86
108
this .noticeService .create ()
87
109
.player (sender .getUniqueId ())
88
110
.notice (translation -> translation .chat ().alertQueueSent ())
0 commit comments