From 1b9b344a9eabf91ea15d4d58bc3c1004ebb7ba8f Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 29 Mar 2024 20:51:34 +0000 Subject: [PATCH] Fix crash while typing "/" in chat (#615) Co-authored-by: Andy --- .../clientcommands/mixin/MixinChatScreen.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/earthcomputer/clientcommands/mixin/MixinChatScreen.java b/src/main/java/net/earthcomputer/clientcommands/mixin/MixinChatScreen.java index f391aaf7b..aa8163c2f 100644 --- a/src/main/java/net/earthcomputer/clientcommands/mixin/MixinChatScreen.java +++ b/src/main/java/net/earthcomputer/clientcommands/mixin/MixinChatScreen.java @@ -34,7 +34,12 @@ private String onHandleChatInput(String message) { @Inject(method = "onEdited", at = @At("HEAD")) private void onEdited(String value, CallbackInfo ci) { - if (value.startsWith("/") && ClientCommands.isClientcommandsCommand(value.substring(1).split(" ")[0])) { + boolean isClientcommandsCommand = false; + if (value.startsWith("/")) { + String[] commandArgs = value.substring(1).split(" "); + isClientcommandsCommand = commandArgs.length > 0 && ClientCommands.isClientcommandsCommand(commandArgs[0]); + } + if (isClientcommandsCommand) { if (oldMaxLength == null) { oldMaxLength = input.maxLength; }