Skip to content

Commit 3ba586f

Browse files
committed
fixed the SendChatEvent not triggering when using a registered command with arguments...
1 parent c6e1a01 commit 3ba586f

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/main/java/io/github/techstreet/dfscript/mixin/player/MLocalPlayer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.github.techstreet.dfscript.event.SendChatEvent;
44
import io.github.techstreet.dfscript.event.TickEvent;
55
import io.github.techstreet.dfscript.event.system.EventManager;
6+
import io.github.techstreet.dfscript.util.chat.ChatUtil;
67
import net.minecraft.client.network.ClientPlayerEntity;
78
import net.minecraft.text.Text;
89
import org.jetbrains.annotations.Nullable;
@@ -24,17 +25,19 @@ private void chat(String message, Text preview, CallbackInfo ci) {
2425
}
2526
}
2627

27-
@Inject(method = "sendCommand", at = @At("HEAD"), cancellable = true)
28+
@Inject(method = "sendCommand(Ljava/lang/String;)Z", at = @At("HEAD"), cancellable = true)
2829
private void command(String command, CallbackInfoReturnable<Boolean> ci) {
30+
ChatUtil.info("sendCommand: "+command);
2931
SendChatEvent event = new SendChatEvent("/"+command);
3032
EventManager.getInstance().dispatch(event);
3133
if (event.isCancelled()) {
3234
ci.cancel();
3335
}
3436
}
3537

36-
@Inject(method = "sendCommandInternal", at = @At("HEAD"), cancellable = true)
37-
private void commandInterval(String command, @Nullable Text preview, CallbackInfo ci) {
38+
@Inject(method = "sendCommand(Ljava/lang/String;Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true)
39+
private void command2(String command, Text preview, CallbackInfo ci) {
40+
ChatUtil.info("sendCommandInternal: "+command);
3841
SendChatEvent event = new SendChatEvent("/"+command);
3942
EventManager.getInstance().dispatch(event);
4043
if (event.isCancelled()) {

src/main/java/io/github/techstreet/dfscript/script/action/ScriptActionType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,10 +1041,10 @@ public enum ScriptActionType {
10411041
}
10421042
}
10431043

1044-
/*ClientPlayNetworkHandler nh = DFScript.MC.getNetworkHandler();
1044+
ClientPlayNetworkHandler nh = DFScript.MC.getNetworkHandler();
10451045
if (nh != null) {
10461046
nh.onCommandTree(new CommandTreeS2CPacket(nh.getCommandDispatcher().getRoot()));
1047-
}*/
1047+
}
10481048
}
10491049
catch(Exception e){
10501050
ChatUtil.error("Cannot register command '" + cmd.asText() + "': " + e.getMessage());

src/main/resources/dfscript.mixins.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
],
1818
"injectors": {
1919
"defaultRequire": 1
20-
}
20+
},
21+
"priority": 0
2122
}

0 commit comments

Comments
 (0)