babalae/better-genshin-impact · error · Exception

当前任务暂不支持使用json策略,请使用txt策略

Error message

当前任务暂不支持使用json策略,请使用txt策略

What it means

Error "当前任务暂不支持使用json策略,请使用txt策略" thrown in babalae/better-genshin-impact.

Source

Thrown at BetterGenshinImpact/GameTask/AutoFight/Script/CombatScriptParser.cs:23

using System.IO;
using System.Linq;
using static BetterGenshinImpact.GameTask.Common.TaskControl;

namespace BetterGenshinImpact.GameTask.AutoFight.Script;

public class CombatScriptParser
{
    public static string CurrentAvatarName = "当前角色";
    
    public static CombatScriptBag ReadAndParse(string path)
    {
        if (File.Exists(path))
        {
            // 防护性代码:防止 .json 策略文件被错误传入旧的 .txt 解析器
            if (path.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
            {
                Logger.LogError("当前任务暂不支持使用json策略,请使用txt策略");
                throw new Exception("当前任务暂不支持使用json策略,请使用txt策略");
            }

            return new CombatScriptBag(Parse(path));
        }
        else if (Directory.Exists(path))
        {
            var files = Directory.GetFiles(path, "*.txt", SearchOption.AllDirectories);
            if (files.Length == 0)
            {
                Logger.LogError("战斗脚本文件不存在:{Path}", path);
                throw new Exception("战斗脚本文件不存在");
            }

            var combatScripts = new List<CombatScript>();
            foreach (var file in files)
            {
                try
                {

View on GitHub (pinned to a7cb36712d)

Solutions

  1. 将战斗策略文件改为 .txt 格式
  2. 使用支持 JSON 策略的任务类型(如自动战斗)
  3. 将 JSON 策略内容改写为文本指令格式

Example fix

改用txt格式战斗脚本;需要json策略时使用支持json策略的任务入口。

When it happens

Trigger: CombatScriptParser.ReadAndParse 收到 .json 后缀的路径,该解析器只支持txt策略,防护性地抛出。

Common situations: 在只支持txt策略的旧任务(如部分自动战斗入口)里选择了json格式的战斗策略文件。


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/6889ab923f6bbb0a. Report an issue: GitHub.