Skip to content

Commit b443d20

Browse files
Merge pull request #27 from XTerPL/XTer-4-1
fixed the SendChatEvent not triggering when using a registered command with arguments...
2 parents c2cd1ef + a36adaf commit b443d20

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

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

Lines changed: 4 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,7 +25,7 @@ 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) {
2930
SendChatEvent event = new SendChatEvent("/"+command);
3031
EventManager.getInstance().dispatch(event);
@@ -33,8 +34,8 @@ private void command(String command, CallbackInfoReturnable<Boolean> ci) {
3334
}
3435
}
3536

36-
@Inject(method = "sendCommandInternal", at = @At("HEAD"), cancellable = true)
37-
private void commandInterval(String command, @Nullable Text preview, CallbackInfo ci) {
37+
@Inject(method = "sendCommand(Ljava/lang/String;Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true)
38+
private void command2(String command, Text preview, CallbackInfo ci) {
3839
SendChatEvent event = new SendChatEvent("/"+command);
3940
EventManager.getInstance().dispatch(event);
4041
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)