package land.chipmunk.chipmunkmod.modules;

import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;

public class Chat {
    public static final ThreadLocal<Boolean> NEXT_CHAT_PLAYER = ThreadLocal.withInitial(() -> false);

    public static void sendChatMessage (final String message) { sendChatMessage(message, false); }

    public static void sendChatMessage (final String message, final boolean usePlayerChat) {
        if (message == null) return;

        if (usePlayerChat) NEXT_CHAT_PLAYER.set(true);

        final ClientPacketListener networkHandler = Minecraft.getInstance().getConnection();
        if (networkHandler == null) return;
        networkHandler.sendChat(message);
    }
}
