2
2
3
3
import com .eternalcode .annotations .scan .command .DescriptionDocs ;
4
4
import com .eternalcode .core .configuration .implementation .PluginConfiguration ;
5
+ import com .eternalcode .core .event .EventCaller ;
5
6
import com .eternalcode .core .feature .teleport .TeleportTaskService ;
7
+ import com .eternalcode .core .feature .warp .event .WarpTeleportEvent ;
6
8
import com .eternalcode .core .injector .annotations .Inject ;
7
9
import com .eternalcode .core .notice .NoticeService ;
8
10
import com .eternalcode .core .shared .PositionAdapter ;
@@ -25,14 +27,16 @@ class WarpCommand {
25
27
private final WarpInventory warpInventory ;
26
28
private final NoticeService noticeService ;
27
29
private final WarpManager warpManager ;
30
+ private final EventCaller eventCaller ;
28
31
29
32
@ Inject
30
- WarpCommand (NoticeService noticeService , WarpManager warpManager , TeleportTaskService teleportTaskService , PluginConfiguration config , WarpInventory warpInventory ) {
33
+ WarpCommand (NoticeService noticeService , WarpManager warpManager , TeleportTaskService teleportTaskService , PluginConfiguration config , WarpInventory warpInventory , EventCaller eventCaller ) {
31
34
this .noticeService = noticeService ;
32
35
this .warpManager = warpManager ;
33
36
this .teleportTaskService = teleportTaskService ;
34
37
this .config = config ;
35
38
this .warpInventory = warpInventory ;
39
+ this .eventCaller = eventCaller ;
36
40
}
37
41
38
42
@ Execute (name = "warp" )
@@ -54,12 +58,16 @@ void warp(@Context Player player, @Context User user) {
54
58
@ Execute (name = "warp" )
55
59
@ DescriptionDocs (description = "Teleport to warp, if player has permission eternalcore.warp.bypass teleport will be instant" , arguments = "<warp>" )
56
60
void warp (@ Context Player player , @ Arg Warp warp ) {
57
- if ( player . hasPermission ( "eternalcore. warp.bypass" )) {
58
- this . teleportTaskService . createTeleport ( player . getUniqueId (), PositionAdapter . convert ( player . getLocation ()), warp . getPosition (), Duration . ZERO );
61
+ WarpTeleportEvent event = this . eventCaller . callEvent ( new WarpTeleportEvent ( player , warp ));
62
+ if ( event . isCancelled ()) {
59
63
return ;
60
64
}
61
65
62
- this .teleportTaskService .createTeleport (player .getUniqueId (), PositionAdapter .convert (player .getLocation ()), warp .getPosition (), Duration .ofSeconds (5 ));
66
+ if (player .hasPermission ("eternalcore.warp.bypass" )) {
67
+ this .teleportTaskService .createTeleport (player .getUniqueId (), PositionAdapter .convert (player .getLocation ()), PositionAdapter .convert (warp .getLocation ()), Duration .ZERO );
68
+ return ;
69
+ }
70
+ this .teleportTaskService .createTeleport (player .getUniqueId (), PositionAdapter .convert (player .getLocation ()), PositionAdapter .convert (warp .getLocation ()), Duration .ofSeconds (5 ));
63
71
}
64
72
65
73
@ Execute (name = "setwarp" )
@@ -76,7 +84,7 @@ void add(@Context Player player, @Arg String warp) {
76
84
return ;
77
85
}
78
86
79
- this .warpManager .createWarp (warp , PositionAdapter . convert ( player .getLocation () ));
87
+ this .warpManager .createWarp (warp , player .getLocation ());
80
88
81
89
this .noticeService .create ()
82
90
.player (player .getUniqueId ())
0 commit comments