Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package meteordevelopment.meteorclient.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.commands.Commands;
Expand Down Expand Up @@ -47,12 +49,6 @@ public abstract class ClientPlayNetworkHandlerMixin extends ClientCommonNetworkH
@Shadow
private ClientWorld world;

@Shadow
public abstract void sendChatMessage(String content);

@Unique
private boolean ignoreChatMessage;

@Unique
private boolean worldNotNull;

Expand Down Expand Up @@ -139,18 +135,16 @@ private void onItemPickupAnimation(ItemPickupAnimationS2CPacket packet, Callback
}

@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
private void onSendChatMessage(String message, CallbackInfo ci) {
if (ignoreChatMessage) return;

private void onSendChatMessage(String message, CallbackInfo ci, @Local(argsOnly = true) LocalRef<String> messageRef) {
if (!message.startsWith(Config.get().prefix.get()) && !(BaritoneUtils.IS_AVAILABLE && message.startsWith(BaritoneUtils.getPrefix()))) {
SendMessageEvent event = MeteorClient.EVENT_BUS.post(SendMessageEvent.get(message));

if (!event.isCancelled()) {
ignoreChatMessage = true;
sendChatMessage(event.message);
ignoreChatMessage = false;
messageRef.set(event.message);
} else {
ci.cancel();
}
ci.cancel();

return;
}

Expand Down