BungeeMain / src / main / java / com / lifeknight / relaymcbungeemain / utilities / ChatMessage.java
ChatMessage.java
Raw
package com.lifeknight.relaymcbungeemain.utilities;

import com.lifeknight.relaymcbungeemain.player.ChatType;
import com.lifeknight.relayutils.basic.Text;
import com.lifeknight.relayutils.utilities.ComponentBuilder;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;

import java.awt.*;

public class ChatMessage {
    protected final String message;
    protected final ChatType chatType;
    protected final long time;

    public ChatMessage(String message, ChatType chatType) {
        this.message = message;
        this.chatType = chatType;
        this.time = System.currentTimeMillis();
    }

    public long getTime() {
        return this.time;
    }

    public String getMessage() {
        return this.message;
    }

    public ChatType getChatType() {
        return this.chatType;
    }

    public BaseComponent getComponent(boolean indiscriminate) {
        ComponentBuilder componentBuilder = new ComponentBuilder();

        if (indiscriminate) {
            componentBuilder.append(ChatColor.GRAY).append("[").color(this.chatType.getColor()).append(this.chatType.name()).append(ChatColor.GRAY).append("]").append(" ");
        }

        componentBuilder.append(ChatColor.GRAY).append("[").color(Color.PINK).append(Text.getTimeString(this.time)).color(ChatColor.GRAY).append("]").append(" ");

        componentBuilder.color(Color.WHITE).append(this.message);

        return componentBuilder.getResult();
    }
}