fix: make .say .something actually make the player say .something in chat instead of running a command

This commit is contained in:
Chayapak Supasakul 2025-08-19 20:23:10 +07:00
parent e13b035b10
commit cf428682a2
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA
2 changed files with 6 additions and 7 deletions

View file

@ -2,6 +2,7 @@ package land.chipmunk.chipmunkmod.mixin;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import land.chipmunk.chipmunkmod.ChipmunkMod; import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.command.CommandManager;
import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand; import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions; import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
import land.chipmunk.chipmunkmod.util.BotValidationUtilities; import land.chipmunk.chipmunkmod.util.BotValidationUtilities;
@ -38,6 +39,7 @@ public abstract class ChatScreenMixin {
@Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true) @Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true)
private void sendMessage (final String chatText, final boolean addToHistory, final CallbackInfo ci) { private void sendMessage (final String chatText, final boolean addToHistory, final CallbackInfo ci) {
final CommandManager commandManager = CommandManager.INSTANCE;
final MinecraftClient client = MinecraftClient.getInstance(); final MinecraftClient client = MinecraftClient.getInstance();
if (addToHistory) { if (addToHistory) {
@ -101,6 +103,10 @@ public abstract class ChatScreenMixin {
} catch (final Exception ignored) { } catch (final Exception ignored) {
} }
} }
} else if (chatText.startsWith(commandManager.prefix)) {
commandManager.executeCommand(chatText.substring(commandManager.prefix.length()));
ci.cancel();
return;
} }
if (client.player == null) return; if (client.player == null) return;

View file

@ -126,13 +126,6 @@ public abstract class ClientPlayNetworkHandlerMixin {
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true) @Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
private void sendChatMessage (final String content, final CallbackInfo ci) { private void sendChatMessage (final String content, final CallbackInfo ci) {
final CommandManager commandManager = CommandManager.INSTANCE;
if (content.startsWith(commandManager.prefix)) {
commandManager.executeCommand(content.substring(commandManager.prefix.length()));
ci.cancel();
return;
}
if (Chat.NEXT_CHAT_PLAYER.get()) { if (Chat.NEXT_CHAT_PLAYER.get()) {
Chat.NEXT_CHAT_PLAYER.set(false); Chat.NEXT_CHAT_PLAYER.set(false);
return; return;