55import io .github .techstreet .dfscript .event .system .EventManager ;
66import net .minecraft .client .network .ClientPlayerEntity ;
77import net .minecraft .text .Text ;
8+ import org .jetbrains .annotations .Nullable ;
89import org .spongepowered .asm .mixin .Mixin ;
910import org .spongepowered .asm .mixin .injection .At ;
1011import org .spongepowered .asm .mixin .injection .Inject ;
1112import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
13+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
1214
1315@ Mixin (ClientPlayerEntity .class )
1416public class MLocalPlayer {
@@ -22,6 +24,24 @@ private void chat(String message, Text preview, CallbackInfo ci) {
2224 }
2325 }
2426
27+ @ Inject (method = "sendCommand" , at = @ At ("HEAD" ), cancellable = true )
28+ private void command (String command , CallbackInfoReturnable <Boolean > ci ) {
29+ SendChatEvent event = new SendChatEvent (command );
30+ EventManager .getInstance ().dispatch (event );
31+ if (event .isCancelled ()) {
32+ ci .cancel ();
33+ }
34+ }
35+
36+ @ Inject (method = "sendCommandInternal" , at = @ At ("HEAD" ), cancellable = true )
37+ private void commandInterval (String command , @ Nullable Text preview , CallbackInfo ci ) {
38+ SendChatEvent event = new SendChatEvent (command );
39+ EventManager .getInstance ().dispatch (event );
40+ if (event .isCancelled ()) {
41+ ci .cancel ();
42+ }
43+ }
44+
2545 @ Inject (method = "tick" , at = @ At ("HEAD" ))
2646 private void tick (CallbackInfo ci ) {
2747 EventManager .getInstance ().dispatch (new TickEvent ());
0 commit comments