1
- package com .eternalcode .core .feature .essentials . mob ;
1
+ package com .eternalcode .core .feature .butcher ;
2
2
3
3
import com .eternalcode .annotations .scan .command .DescriptionDocs ;
4
- import com .eternalcode .core .configuration . implementation . PluginConfiguration ;
4
+ import com .eternalcode .core .event . EventCaller ;
5
5
import com .eternalcode .core .injector .annotations .Inject ;
6
6
import com .eternalcode .core .notice .NoticeService ;
7
7
import dev .rollczi .litecommands .annotations .argument .Arg ;
25
25
class ButcherCommand {
26
26
27
27
private final NoticeService noticeService ;
28
+ private final EventCaller eventCaller ;
28
29
29
30
@ Inject
30
- ButcherCommand (NoticeService noticeService , PluginConfiguration pluginConfiguration ) {
31
+ ButcherCommand (NoticeService noticeService , EventCaller eventCaller ) {
31
32
this .noticeService = noticeService ;
33
+ this .eventCaller = eventCaller ;
32
34
}
33
35
34
36
@ Execute
@@ -51,16 +53,21 @@ void execute(@Context Player player, @Arg(ButcherArgument.KEY) int chunks, @Arg(
51
53
52
54
private void killMobs (Player player , int chunksNumber , MobFilter mobFilter ) {
53
55
Collection <Chunk > chunks = this .getChunksNearPlayer (player , chunksNumber );
54
-
55
56
int killedMobs = 0 ;
56
57
57
58
for (Chunk chunk : chunks ) {
58
59
for (Entity entity : chunk .getEntities ()) {
59
-
60
60
if (!mobFilter .filterMob (entity )) {
61
61
continue ;
62
62
}
63
63
64
+ ButcherEntityRemoveEvent event = new ButcherEntityRemoveEvent (entity );
65
+ this .eventCaller .callEvent (event );
66
+
67
+ if (event .isCancelled ()) {
68
+ continue ;
69
+ }
70
+
64
71
entity .remove ();
65
72
killedMobs ++;
66
73
}
0 commit comments