Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
Coloryr committed Jan 20, 2025
1 parent 1196be9 commit ec0aa64
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 37 deletions.
3 changes: 3 additions & 0 deletions log.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
## 已知问题

## 已完成 Done
### 2025.1.20
- 修复neoforge1.21.4无法启动问题

### 2025.1.17
- 修复日志倒序问题
- 暂时禁用DNS覆盖
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Core/CoreMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class ColorMCCore
{
public const int VersionNum = 34;
public const string TopVersion = "A34";
public const string DateVersion = "20250117";
public const string DateVersion = "20250120";

/// <summary>
/// 版本号
Expand Down
37 changes: 29 additions & 8 deletions src/ColorMC.Core/Helpers/CheckHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ public static bool IsGameVersionV2(this GameArgObj version)
/// <returns>是否为1.17以上版本</returns>
public static bool IsGameVersion117(string version)
{
var version1 = new Version(version);
return version1.Minor >= 17;
try
{
var version1 = new Version(version);
return version1.Minor >= 17;
}
catch
{
return false;
}
}

/// <summary>
Expand All @@ -143,8 +150,15 @@ public static bool IsGameVersion117(string version)
/// <returns>是否是1.20以上版本</returns>
public static bool IsGameVersion120(string version)
{
var version1 = new Version(version);
return version1.Minor >= 20;
try
{
var version1 = new Version(version);
return version1.Minor >= 20;
}
catch
{
return false;
}
}

/// <summary>
Expand All @@ -154,12 +168,19 @@ public static bool IsGameVersion120(string version)
/// <returns>是否是1.20.2以上版本</returns>
public static bool IsGameVersion1202(string version)
{
Version version1 = new(version);
if (version1.Minor > 20)
try
{
return true;
var version1 = new Version(version);
if (version1.Minor > 20)
{
return true;
}
return version1.Minor >= 20 && version1.Build >= 2;
}
catch
{
return false;
}
return version1.Minor >= 20 && version1.Build >= 2;
}

/// <summary>
Expand Down
65 changes: 37 additions & 28 deletions src/ColorMC.Core/Helpers/DownloadItemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ namespace ColorMC.Core.Helpers;
/// </summary>
public static class DownloadItemHelper
{
public const string Name1 = "installer";
public const string Name2 = "universal";
public const string Name3 = "client";
public const string Name4 = "launcher";

/// <summary>
/// 检测下载源
/// </summary>
Expand All @@ -39,9 +44,9 @@ public static DownloadItemObj BuildMcaselectorItem()
{
return new()
{
Name = "mcaselector-2.4.1",
Local = Path.GetFullPath($"{ToolPath.BaseDir}/mcaselector-2.4.1.jar"),
Url = "https://github.com/Querz/mcaselector/releases/download/2.4.1/mcaselector-2.4.1.jar"
Name = "mcaselector-2.4.2",
Local = Path.GetFullPath($"{ToolPath.BaseDir}/mcaselector-2.4.2.jar"),
Url = "https://github.com/Querz/mcaselector/releases/download/2.4.2/mcaselector-2.4.2.jar"
};
}
/// <summary>
Expand Down Expand Up @@ -149,7 +154,7 @@ private static DownloadItemObj BuildNeoForgeItem(string mc, string version, stri
/// <returns>下载项目</returns>
public static DownloadItemObj BuildForgeInstaller(string mc, string version)
{
return BuildForgeItem(mc, version, "installer");
return BuildForgeItem(mc, version, Name1);
}

/// <summary>
Expand All @@ -160,7 +165,7 @@ public static DownloadItemObj BuildForgeInstaller(string mc, string version)
/// <returns>下载项目</returns>
public static DownloadItemObj BuildNeoForgeInstaller(string mc, string version)
{
return BuildNeoForgeItem(mc, version, "installer");
return BuildNeoForgeItem(mc, version, Name1);
}

/// <summary>
Expand All @@ -171,7 +176,7 @@ public static DownloadItemObj BuildNeoForgeInstaller(string mc, string version)
/// <returns>下载项目</returns>
public static DownloadItemObj BuildForgeUniversal(string mc, string version)
{
return BuildForgeItem(mc, version, "universal");
return BuildForgeItem(mc, version, Name2);
}

/// <summary>
Expand All @@ -182,7 +187,7 @@ public static DownloadItemObj BuildForgeUniversal(string mc, string version)
/// <returns>下载项目</returns>
public static DownloadItemObj BuildNeoForgeClient(string mc, string version)
{
return BuildNeoForgeItem(mc, version, "client");
return BuildNeoForgeItem(mc, version, Name3);
}

/// <summary>
Expand All @@ -193,7 +198,7 @@ public static DownloadItemObj BuildNeoForgeClient(string mc, string version)
/// <returns>下载项目</returns>
public static DownloadItemObj BuildForgeClient(string mc, string version)
{
return BuildForgeItem(mc, version, "client");
return BuildForgeItem(mc, version, Name3);
}

/// <summary>
Expand All @@ -204,7 +209,7 @@ public static DownloadItemObj BuildForgeClient(string mc, string version)
/// <returns>下载项目</returns>
public static DownloadItemObj BuildNeoForgeUniversal(string mc, string version)
{
return BuildNeoForgeItem(mc, version, "universal");
return BuildNeoForgeItem(mc, version, Name2);
}
/// <summary>
/// 创建NeoForge下载项目
Expand All @@ -214,22 +219,23 @@ public static DownloadItemObj BuildNeoForgeUniversal(string mc, string version)
/// <returns>下载项目</returns>
public static DownloadItemObj BuildForgeLauncher(string mc, string version)
{
var item = BuildForgeItem(mc, version, "launcher");
var name = $"forge-{mc}-{version}-launcher";
var item = BuildForgeItem(mc, version, Name4);
var name = $"forge-{mc}-{version}-{Name4}";
item.Url = UrlHelper.DownloadForgeJar(mc, version, SourceLocal.Offical) + name + ".jar";

return item;
}

/// <summary>
/// 创建NeoForge下载项目
/// </summary>
/// <param name="mc">游戏版本</param>
/// <param name="version">forge版本</param>
/// <returns>下载项目</returns>
public static DownloadItemObj BuildNeoForgeLauncher(string mc, string version)
{
return BuildNeoForgeItem(mc, version, "launcher");
}
//public static DownloadItemObj BuildNeoForgeLauncher(string mc, string version)
//{
// return BuildNeoForgeItem(mc, version, "launcher");
//}

/// <summary>
/// 构建Forge运行库下载项目列表
Expand Down Expand Up @@ -291,39 +297,42 @@ public static ICollection<DownloadItemObj> BuildForgeLibs(List<ForgeLaunchObj.Li
}
}

if (item1.Name.EndsWith("universal"))
if (item1.Name.EndsWith(Name2))
{
universal = true;
}
else if (item1.Name.EndsWith("installer"))
else if (item1.Name.EndsWith(Name1))
{
installer = true;
}
else if (item1.Name.EndsWith("launcher"))
else if (item1.Name.EndsWith(Name4))
{
launcher = true;
}
}

if (!installer && install)
{
list.Add("installer", neo ?
list.Add(Name1, neo ?
BuildNeoForgeInstaller(mc, version) :
BuildForgeInstaller(mc, version));
}
if (!universal && !neo)
if (!universal)
{
//list.Add("universal", neo ?
// BuildNeoForgeUniversal(mc, version) :
// BuildForgeUniversal(mc, version));

list.Add("universal", BuildForgeUniversal(mc, version));
if (!neo || !CheckHelpers.IsGameVersion1202(mc))
{
list.Add(Name2, neo ?
BuildNeoForgeUniversal(mc, version) :
BuildForgeUniversal(mc, version));
}
}
if (v2 && !CheckHelpers.IsGameVersion117(mc) && !launcher)
{
list.Add("launcher", neo ?
BuildNeoForgeLauncher(mc, version) :
BuildForgeLauncher(mc, version));
//list.Add(Name4, neo ?
// BuildNeoForgeLauncher(mc, version) :
// BuildForgeLauncher(mc, version));

list.Add(Name4, BuildForgeLauncher(mc, version));
}

return list.Values;
Expand Down

0 comments on commit ec0aa64

Please sign in to comment.