6
6
import com .eternalcode .core .injector .annotations .Inject ;
7
7
import com .eternalcode .core .notice .NoticeService ;
8
8
import com .eternalcode .multification .notice .NoticeBroadcast ;
9
+ import dev .rollczi .litecommands .annotations .command .Command ;
9
10
import dev .rollczi .litecommands .annotations .context .Context ;
10
- import dev .rollczi .litecommands .annotations .join .Join ;
11
11
import dev .rollczi .litecommands .annotations .execute .Execute ;
12
+ import dev .rollczi .litecommands .annotations .join .Join ;
12
13
import dev .rollczi .litecommands .annotations .permission .Permission ;
13
- import dev .rollczi .litecommands .annotations .command .Command ;
14
14
import org .bukkit .Server ;
15
15
import org .bukkit .command .CommandSender ;
16
- import org .bukkit .entity .Player ;
17
16
18
17
@ Command (name = "adminchat" , aliases = "ac" )
19
18
@ Permission ("eternalcore.adminchat" )
20
19
class AdminChatCommand {
21
20
21
+ private static final String ADMIN_CHAT_SPY_PERMISSION = "eternalcore.adminchat.spy" ;
22
+
22
23
private final NoticeService noticeService ;
23
24
private final EventCaller eventCaller ;
24
25
private final Server server ;
@@ -39,21 +40,18 @@ void execute(@Context CommandSender sender, @Join String message) {
39
40
return ;
40
41
}
41
42
43
+ String eventMessage = event .getContent ();
44
+
42
45
NoticeBroadcast notice = this .noticeService .create ()
43
46
.console ()
44
47
.notice (translation -> translation .adminChat ().format ())
45
48
.placeholder ("{PLAYER}" , sender .getName ())
46
- .placeholder ("{TEXT}" , message );
49
+ .placeholder ("{TEXT}" , eventMessage );
47
50
48
- for (Player player : this .server .getOnlinePlayers ()) {
49
- if (!player .hasPermission ("eternalcore.adminchat.spy" )) {
50
- continue ;
51
- }
52
-
53
- notice = notice .player (player .getUniqueId ());
54
- }
51
+ this .server .getOnlinePlayers ().stream ()
52
+ .filter (player -> player .hasPermission (ADMIN_CHAT_SPY_PERMISSION ))
53
+ .forEach (player -> notice .player (player .getUniqueId ()));
55
54
56
55
notice .send ();
57
56
}
58
-
59
57
}
0 commit comments