package top.leisuretimedock.dglabgame.datagen.value;

import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Unmodifiable;
import top.leisuretimedock.dglabgame.DGLabGame;
import top.r3944realms.lib39.datagen.value.ILangKeyValue;
import top.r3944realms.lib39.datagen.value.ILangKeyValueCollection;
import top.r3944realms.lib39.datagen.value.LangKeyValue;
import top.r3944realms.lib39.datagen.value.ModPartEnum;

import java.util.ArrayList;
import java.util.List;

public enum DLGLangKey implements ILangKeyValueCollection {
    INSTANCE;
    /**
     * The Lang key values.
     */
    final List<LangKeyValue> langKeyValues = new ArrayList<>();

    DLGLangKey () {
        initLangKeyValues();
    }

    public void initLangKeyValues() {
        initKey();
    }
    private void initKey() {
        LangKeyValue mod = LangKeyValue.ofKey(DGLabGame.MOD_ID + ".name", ModPartEnum.DEFAULT,
                "DG Lab Game", "郊狼游戏", "郊狼游戲", "郊狼戯"
        );
        addLang(
                mod
        );
        addLang(
                LangKeyValue.copyOf("key.categories.dglabgame", ModPartEnum.NAME,
                    mod
                )
        );
        addLang(
                LangKeyValue.ofKey("key.dglabgame.test", ModPartEnum.NAME,
                        "Test", "测试", "测试", "式"
                )
        );
// 用户协议相关翻译
        addLang(
                LangKeyValue.ofKey("dglabgame.user_agreement.refuse", ModPartEnum.NAME,
                        "§4§lRefuse",
                        "§4§l拒绝",
                        "§4§l拒絕",
                        "§4§l否"
                )
        );

        addLang(
                LangKeyValue.ofKey("dglabgame.user_agreement.accept", ModPartEnum.NAME,
                        "§2§lAccept",
                        "§2§l接受",
                        "§2§l接受",
                        "§2§l認"
                )
        );

        addLang(
                LangKeyValue.ofKey("dglabgame.user_agreement.reject_use", ModPartEnum.NAME,
                        "Not agreed to user guidelines, usage rejected",
                        "未同意用户使用准则，拒绝使用",
                        "未同意使用者準則，拒絕使用",
                        "未允用戶之約，拒用"
                )
        );

        addLang(
                LangKeyValue.ofKey("dglabgame.user_agreement.line1", ModPartEnum.NAME,
                        "1. This mod is developed by §e§lR3944Realms §r, completely free and open source.",
                        "1. 本模组由 §e§lR3944Realms §r开发，完全免费开源。",
                        "1. 本模組由 §e§lR3944Realms §r 開發，完全免費開源。",
                        "1. 本模組乃 §e§lR3944Realms §r 所製，全然免費而開源。"
                )
        );

        addLang(
                LangKeyValue.ofKey("dglabgame.user_agreement.line2", ModPartEnum.NAME,
                        "2. Only supports DG Lab 3.0 host (WebSocket protocol compatible)",
                        "2. 仅支持 DG Lab 3.0 主机（支持 WebSocket 协议）",
                        "2. 僅支援 DG Lab 3.0 主機（支援 WebSocket 協定）",
                        "2. 惟 DG Lab 3.0 主機可相容，WebSocket 協定亦得支援。"
                )
        );

        addLang(
                LangKeyValue.ofKey("dglabgame.user_agreement.line3", ModPartEnum.NAME,
                        "3. §e§lWARNING:§4 Using electro-stimulation devices carries risks!",
                        "3. §e§l警告：§4使用释放电的设备存在风险！",
                        "3. §e§l警告：§4使用釋放電設備存在風險！",
                        "3. §e§l警之！§4釋電之器，用者有險！"
                )
        );

        addLang(
                LangKeyValue.ofKey("dglabgame.user_agreement.line4", ModPartEnum.NAME,
                        "4. §4Users must be at least 18 years old and assume all risks of use.",
                        "4. §4使用者需年满 18 周岁，并自行承担所有使用风险。",
                        "4. §4使用者需年滿 18 歲，並自行承擔所有使用風險。",
                        "4. §4用者須年滿十八，自負其責。"
                )
        );

        addLang(
                LangKeyValue.ofKey("dglabgame.user_agreement.line5", ModPartEnum.NAME,
                        "5. §4Prohibited for any illegal or immoral activities.",
                        "5. §4禁止用于任何违法或不道德的活动。",
                        "5. §4禁止用於任何違法或不道德之活動。",
                        "5. §4禁作非法不德之事。"
                )
        );

        addLang(
                LangKeyValue.ofKey("dglabgame.user_agreement.line6", ModPartEnum.NAME,
                        "6. §4Developers are not responsible for any personal injury or property damage.",
                        "6. §4开发者不对任何人身伤害或财产损失负责。",
                        "6. §4開發者不對任何人身份害或財產損失負責。",
                        "6. §4凡人身之傷、財物之損，開發者概不負責。"
                )
        );
        //dglabgame.user_agreement.refuse
        // Refuse
        // 拒绝
        //dglabgame.user_agreement.accept
        // accept
        // 同意
        //dglabgame.user_agreement.1 - 6
        // 1. 本模组由 R3944Realms 开发，完全免费开源。
        // 1. This mod is developed by R3944Realms, completely free and open source.
        //
        // 2. 仅支持 DG Lab 3.0 主机（支持 WebSocket 协议）
        // 2. Only supports DG Lab 3.0 host (WebSocket protocol compatible)
        //
        // 3. 警告：使用释放电的设备存在风险！
        // 3. WARNING: Using electro-stimulation devices carries risks!
        //
        // 4. 使用者需年满 18 周岁，并自行承担所有使用风险。
        // 4. Users must be at least 18 years old and assume all risks of use.
        //
        // 5. 禁止用于任何违法或不道德的活动。
        // 5. Prohibited for any illegal or immoral activities.
        //
        // 6. 开发者不对任何人身伤害或财产损失负责。
        // 6. Developers are not responsible for any personal injury or property damage.

        initCommandKeys();
    }

    private void initCommandKeys() {
        // Server commands
        addLang(LangKeyValue.ofKey("dglabgame.command.server.started", ModPartEnum.NAME,
                "DGLab WebSocket server started on port %s",
                "DGLab WebSocket 服务器已在端口 %s 启动",
                "DGLab WebSocket 伺服器已在連接埠 %s 啟動",
                "DGLab WebSocket 伺服器已於埠 %s 啟"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.server.already_running", ModPartEnum.NAME,
                "DGLab server is already running",
                "DGLab 服务器已在运行中",
                "DGLab 伺服器已在執行中",
                "DGLab 伺服器已在運作中"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.server.stopped", ModPartEnum.NAME,
                "DGLab server stopped",
                "DGLab 服务器已关闭",
                "DGLab 伺服器已關閉",
                "DGLab 伺服器已停"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.server.not_running", ModPartEnum.NAME,
                "DGLab server is not running",
                "DGLab 服务器未在运行",
                "DGLab 伺服器未在執行",
                "DGLab 伺服器未啟"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.server.not_created", ModPartEnum.NAME,
                "DGLab server has not been created yet",
                "DGLab 服务器尚未创建",
                "DGLab 伺服器尚未創建",
                "DGLab 伺服器尚未建"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.server.status", ModPartEnum.NAME,
                "Server status: %s, connected apps: %s",
                "服务器状态: %s, 已连接应用: %s",
                "伺服器狀態: %s, 已連線應用: %s",
                "伺服器態: %s, 已連應用: %s"
        ));

        // Client commands
        addLang(LangKeyValue.ofKey("dglabgame.command.client.created", ModPartEnum.NAME,
                "DGLab client \"%s\" created (%s:%s)",
                "DGLab 客户端 \"%s\" 已创建 (%s:%s)",
                "DGLab 客戶端 \"%s\" 已創建 (%s:%s)",
                "DGLab 客戶 \"%s\" 已建 (%s:%s)"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.client.removed", ModPartEnum.NAME,
                "DGLab client \"%s\" removed",
                "DGLab 客户端 \"%s\" 已移除",
                "DGLab 客戶端 \"%s\" 已移除",
                "DGLab 客戶 \"%s\" 已除"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.client.started", ModPartEnum.NAME,
                "DGLab client \"%s\" started",
                "DGLab 客户端 \"%s\" 已启动",
                "DGLab 客戶端 \"%s\" 已啟動",
                "DGLab 客戶 \"%s\" 已啟"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.client.stopped", ModPartEnum.NAME,
                "DGLab client \"%s\" stopped",
                "DGLab 客户端 \"%s\" 已关闭",
                "DGLab 客戶端 \"%s\" 已關閉",
                "DGLab 客戶 \"%s\" 已停"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.client.not_found", ModPartEnum.NAME,
                "Client \"%s\" not found",
                "未找到客户端 \"%s\"",
                "未找到客戶端 \"%s\"",
                "未見客戶 \"%s\""
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.client.none", ModPartEnum.NAME,
                "No DGLab clients registered",
                "没有已注册的 DGLab 客户端",
                "沒有已註冊的 DGLab 客戶端",
                "無已註之 DGLab 客戶"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.client.list", ModPartEnum.NAME,
                "Registered clients: %s",
                "已注册的客户端: %s",
                "已註冊的客戶端: %s",
                "已註客戶: %s"
        ));

        // Device commands
        addLang(LangKeyValue.ofKey("dglabgame.command.invalid_channel", ModPartEnum.NAME,
                "Invalid channel. Use A or B.",
                "无效的通道。请使用 A 或 B。",
                "無效的通道。請使用 A 或 B。",
                "通道有誤，當用 A 或 B。"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.invalid_policy", ModPartEnum.NAME,
                "Invalid policy. Use goto/set, increase/inc, or decrease/dec.",
                "无效的策略。请使用 goto/set, increase/inc 或 decrease/dec。",
                "無效的策略。請使用 goto/set, increase/inc 或 decrease/dec。",
                "策略有誤，當用 goto/set、increase/inc 或 decrease/dec。"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.no_output", ModPartEnum.NAME,
                "No active DGLab output available. Start the server or a client first.",
                "没有可用的 DGLab 输出。请先启动服务器或客户端。",
                "沒有可用的 DGLab 輸出。請先啟動伺服器或客戶端。",
                "無可用之 DGLab 輸出。請先啟伺服器或客戶。"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.strength.sent", ModPartEnum.NAME,
                "Strength [%s %s %s] sent to %s target(s)",
                "强度 [%s %s %s] 已发送至 %s 个目标",
                "強度 [%s %s %s] 已傳送至 %s 個目標",
                "強度 [%s %s %s] 已送至 %s 標的"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.pulse.sent", ModPartEnum.NAME,
                "Pulse waveform sent to channel %s (%s target(s))",
                "脉冲波形已发送至通道 %s (%s 个目标)",
                "脈衝波形已傳送至通道 %s (%s 個目標)",
                "脈衝波形已送至通道 %s (%s 標的)"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.clear.sent", ModPartEnum.NAME,
                "Clear command sent for channel %s (%s target(s))",
                "清除指令已发送至通道 %s (%s 个目标)",
                "清除指令已傳送至通道 %s (%s 個目標)",
                "清除之令已送至通道 %s (%s 標的)"
        ));
        addLang(LangKeyValue.ofKey("dglabgame.command.feedback.sent", ModPartEnum.NAME,
                "Feedback value %s sent to %s target(s)",
                "反馈值 %s 已发送至 %s 个目标",
                "回饋值 %s 已傳送至 %s 個目標",
                "回應值 %s 已送至 %s 標的"
        ));

        // Management GUI
        addLang(LangKeyValue.ofKey("key.dglabgame.management", ModPartEnum.NAME,
                "Open Management", "打开管理", "開啟管理", "啟管理"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.tab.qrcode", ModPartEnum.NAME,
                "QR Code", "二维码", "QR碼", "二維碼"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.tab.strength", ModPartEnum.NAME,
                "Strength", "强度", "強度", "強度"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.tab.waveform", ModPartEnum.NAME,
                "Waveform", "波形", "波形", "波形"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.tab.feedback", ModPartEnum.NAME,
                "Feedback", "反馈", "回饋", "回應"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.tab.server", ModPartEnum.NAME,
                "Server", "服务器", "伺服器", "伺服器"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.qrcode.copy", ModPartEnum.NAME,
                "Copy QR URL to clipboard", "复制QR URL到剪贴板", "複製QR URL到剪貼板", "複QR URL"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.strength.channel_a", ModPartEnum.NAME,
                "Channel A", "通道A", "通道A", "通道甲"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.strength.channel_b", ModPartEnum.NAME,
                "Channel B", "通道B", "通道B", "通道乙"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.waveform.channel", ModPartEnum.NAME,
                "Channel:", "通道:", "通道:", "通道:"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.feedback.send", ModPartEnum.NAME,
                "Send Feedback:", "发送反馈:", "發送回饋:", "發回應:"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.server.port", ModPartEnum.NAME,
                "Port:", "端口:", "連接埠:", "埠:"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.server.max_conn", ModPartEnum.NAME,
                "Max:", "最大:", "最大:", "至多:"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.server.status", ModPartEnum.NAME,
                "Status: %s", "状态: %s", "狀態: %s", "態: %s"
        ));
        addLang(LangKeyValue.ofKey("gui.dglabgame.client.label", ModPartEnum.NAME,
                "Client:", "客户端:", "客戶端:", "客戶:"
        ));

    }
    @Contract(pure = true)
    @Override
    public @Unmodifiable List<? extends ILangKeyValue> getValues() {
        return List.copyOf(langKeyValues);
    }

    /**
     * Add lang.
     *
     * @param keyValue the key value
     */
    public void addLang(LangKeyValue keyValue) {
        langKeyValues.add(keyValue);
    }

    /**
     * Clear.
     */
    public void clear() {
        langKeyValues.clear();
    }
}
