package com.gmail.nossr50.chat.message;

import com.gmail.nossr50.chat.author.Author;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.TextComponent;
import org.jetbrains.annotations.NotNull;

public interface ChatMessage {
    /**
     * The original message from the {@link Author}
     * This is formatted and styled before being sent out to players by mcMMO
     *
     * @return the original message without any formatting or alterations
     * @see #getChatMessage()
     */
    @NotNull String rawMessage();

    /**
     * The {@link Author} from which this payload originated
     *
     * @see #getChatMessage()
     * @return the source of the chat message
     */
    @NotNull Author getAuthor();

    /**
     * The authors display name which is used in the initial creation of the message payload, it is provided for convenience.
     *
     * This is a name generated by mcMMO during the creation of the {@link ChatMessage}
     *
     * This is used by mcMMO when generating the message payload
     *
     * This method provides the display name for the convenience of plugins constructing their own {@link TextComponent payloads}
     *
     * @see #getChatMessage()
     * @return the author display name as generated by mcMMO
     */
    @NotNull String getAuthorDisplayName();

    /**
     * The target audience of this chat message
     * Unless modified, this will include the {@link Author}
     *
     * @return target audience
     */
    @NotNull Audience getAudience();

    /**
     * The {@link TextComponent message} being sent to the audience
     *
     * @return the {@link TextComponent message} that will be sent to the audience
     */
    @NotNull TextComponent getChatMessage();

    /**
     * Change the value of the {@link TextComponent message}
     *
     * @param textComponent new message value
     */
    void setChatMessage(@NotNull TextComponent textComponent);

    /**
     * Changes the audience
     *
     * @param newAudience the replacement audience
     */
    void setAudience(@NotNull Audience newAudience);

    /**
     * Deliver the message to the audience
     */
    void sendMessage();
}
