package land.chipmunk.chipmunkmod.modules;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;

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 ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
        if (networkHandler == null) return;
        networkHandler.sendChatMessage(message);
    }
}
