1
1
package com .eternalcode .core .feature .teleport .request ;
2
2
3
3
import com .eternalcode .annotations .scan .command .DescriptionDocs ;
4
+ import com .eternalcode .core .feature .ignore .IgnoreService ;
4
5
import com .eternalcode .core .injector .annotations .Inject ;
5
6
import com .eternalcode .core .notice .NoticeService ;
6
7
import dev .rollczi .litecommands .argument .Arg ;
7
8
import dev .rollczi .litecommands .command .execute .Execute ;
8
9
import dev .rollczi .litecommands .command .permission .Permission ;
9
10
import dev .rollczi .litecommands .command .route .Route ;
10
11
import org .bukkit .entity .Player ;
12
+ import panda .std .reactive .Completable ;
11
13
12
14
@ Route (name = "tpa" )
13
15
@ Permission ("eternalcore.tpa" )
14
16
class TpaCommand {
15
17
16
18
private final TeleportRequestService requestService ;
19
+ private final IgnoreService ignoreService ;
17
20
private final NoticeService noticeService ;
18
21
19
22
@ Inject
20
- TpaCommand (TeleportRequestService requestService , NoticeService noticeService ) {
23
+ TpaCommand (TeleportRequestService requestService , IgnoreService ignoreService , NoticeService noticeService ) {
21
24
this .requestService = requestService ;
25
+ this .ignoreService = ignoreService ;
22
26
this .noticeService = noticeService ;
23
27
}
24
28
25
29
@ Execute (required = 1 )
26
30
@ DescriptionDocs (description = "Send teleport request to player" , arguments = "<player>" )
27
31
void execute (Player player , @ Arg Player target ) {
28
32
if (player .equals (target )) {
29
-
30
33
this .noticeService .player (player .getUniqueId (), translation -> translation .tpa ().tpaSelfMessage ());
31
34
32
35
return ;
33
36
}
34
37
35
38
if (this .requestService .hasRequest (player .getUniqueId (), target .getUniqueId ())) {
36
-
37
39
this .noticeService .player (player .getUniqueId (), translation -> translation .tpa ().tpaAlreadySentMessage ());
38
40
39
41
return ;
@@ -46,14 +48,24 @@ void execute(Player player, @Arg Player target) {
46
48
.placeholder ("{PLAYER}" , target .getName ())
47
49
.send ();
48
50
49
- this .noticeService
50
- .create ()
51
- .player (target .getUniqueId ())
52
- .notice (translation -> translation .tpa ().tpaReceivedMessage ())
53
- .placeholder ("{PLAYER}" , player .getName ())
54
- .send ();
51
+ this .isIgnoring (target , player ).then ((isIgnoring ) -> {
52
+ if (isIgnoring ) {
53
+ return ;
54
+ }
55
+
56
+ this .noticeService
57
+ .create ()
58
+ .player (target .getUniqueId ())
59
+ .notice (translation -> translation .tpa ().tpaReceivedMessage ())
60
+ .placeholder ("{PLAYER}" , player .getName ())
61
+ .send ();
62
+ });
55
63
56
64
this .requestService .createRequest (player .getUniqueId (), target .getUniqueId ());
57
65
}
66
+
67
+ Completable <Boolean > isIgnoring (Player target , Player sender ) {
68
+ return this .ignoreService .isIgnored (target .getUniqueId (), sender .getUniqueId ());
69
+ }
58
70
}
59
71
0 commit comments