Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Plain Craft Launcher 2/Application.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
// 初始化文件结构
Directory.CreateDirectory(ModBase.ExePath + @"PCL\Pictures");
Directory.CreateDirectory(ModBase.ExePath + @"PCL\Musics");
Directory.CreateDirectory(ModBase.PathTemp + "Cache");
Directory.CreateDirectory(ModBase.PathTemp + "Download");
Directory.CreateDirectory(Path.Combine(ModBase.PathTemp, "Cache"));
Directory.CreateDirectory(Path.Combine(ModBase.PathTemp, "Download"));
Directory.CreateDirectory(ModBase.PathAppdata);
// 设置 ToolTipService 默认值
ToolTipService.InitialShowDelayProperty.OverrideMetadata(typeof(DependencyObject),
Expand Down Expand Up @@ -195,12 +195,12 @@
// 自定义监听器类
public class BindingErrorTraceListener : TraceListener
{
public override void Write(string message)

Check warning on line 198 in Plain Craft Launcher 2/Application.xaml.cs

View workflow job for this annotation

GitHub Actions / build (CI, ARM64) / Build

Nullability of type of parameter 'message' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 198 in Plain Craft Launcher 2/Application.xaml.cs

View workflow job for this annotation

GitHub Actions / build (CI, x64) / Build

Nullability of type of parameter 'message' doesn't match overridden member (possibly because of nullability attributes).
{
ModBase.Log($"警告,检测到 Binding 失败:{message}");
}

public override void WriteLine(string message)

Check warning on line 203 in Plain Craft Launcher 2/Application.xaml.cs

View workflow job for this annotation

GitHub Actions / build (CI, ARM64) / Build

Nullability of type of parameter 'message' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 203 in Plain Craft Launcher 2/Application.xaml.cs

View workflow job for this annotation

GitHub Actions / build (CI, x64) / Build

Nullability of type of parameter 'message' doesn't match overridden member (possibly because of nullability attributes).
{
ModBase.Log($"警告,检测到 Binding 失败:{message}");
}
Expand Down
6 changes: 3 additions & 3 deletions Plain Craft Launcher 2/FormMain.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@ End If
ModBase.Log("[Start] 已移动离线自定义皮肤 (162)");
}

if (LastVersionCode <= 263 && File.Exists(ModBase.PathTemp + "CustomSkin.png") &&
!File.Exists(ModBase.PathAppdata + "CustomSkin.png"))
if (LastVersionCode <= 263 && File.Exists(Path.Combine(ModBase.PathTemp, "CustomSkin.png")) &&
!File.Exists(Path.Combine(ModBase.PathAppdata, "CustomSkin.png")))
{
ModBase.CopyFile(ModBase.PathTemp + "CustomSkin.png", ModBase.PathAppdata + "CustomSkin.png");
ModBase.CopyFile(Path.Combine(ModBase.PathTemp, "CustomSkin.png"), Path.Combine(ModBase.PathAppdata, "CustomSkin.png"));
ModBase.Log("[Start] 已移动离线自定义皮肤 (264)");
}

Expand Down
2 changes: 1 addition & 1 deletion Plain Craft Launcher 2/Modules/Base/ModBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static class ModBase
/// <summary>
/// AppData 中的 PCL 文件夹路径,以 \ 结尾。
/// </summary>
public static string PathAppdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PCL\";
public static string PathAppdata = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PCL") + @"\";

/// <summary>
/// AppData 中的 PCLCE 配置文件夹路径,以 \ 结尾。
Expand Down
26 changes: 13 additions & 13 deletions Plain Craft Launcher 2/Modules/Minecraft/ModCrash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public CrashAnalyzer(int UUID)
{
// 构建文件结构
TempFolder = ModMain.RequestTaskTempFolder();
Directory.CreateDirectory(TempFolder + @"Temp\");
Directory.CreateDirectory(TempFolder + @"Report\");
Directory.CreateDirectory(Path.Combine(TempFolder, "Temp"));
Directory.CreateDirectory(Path.Combine(TempFolder, "Report"));
ModBase.Log("[Crash] 崩溃分析暂存文件夹:" + TempFolder);
}

Expand Down Expand Up @@ -163,7 +163,7 @@ public void Import(string FilePath)
var Info = new FileInfo(FilePath);
if (Info.Exists && Info.Length > 0L && !FilePath.EndsWithF(".jar", true))
{
ModBase.ExtractFile(FilePath, TempFolder + @"Temp\");
ModBase.ExtractFile(FilePath, Path.Combine(TempFolder, "Temp"));
ModBase.Log("[Crash] 已解压导入的日志文件:" + FilePath);
goto Extracted;
}
Expand All @@ -173,13 +173,13 @@ public void Import(string FilePath)
}

// 并非压缩包
ModBase.CopyFile(FilePath, TempFolder + @"Temp\" + ModBase.GetFileNameFromPath(FilePath));
ModBase.CopyFile(FilePath, Path.Combine(TempFolder, "Temp", ModBase.GetFileNameFromPath(FilePath)));
ModBase.Log("[Crash] 已复制导入的日志文件:" + FilePath);
Extracted: ;


// 导入其中的日志文件
foreach (var TargetFile in new DirectoryInfo(TempFolder + @"Temp\").EnumerateFiles().ToList())
foreach (var TargetFile in new DirectoryInfo(Path.Combine(TempFolder, "Temp")).EnumerateFiles().ToList())
try
{
if (!TargetFile.Exists || TargetFile.Length == 0L)
Expand Down Expand Up @@ -1210,7 +1210,7 @@ public void Output(bool IsHandAnalyze, List<string> ExtraFiles = null)
}
else
{
var FilePath = ModBase.PathTemp + "Crash.txt";
var FilePath = Path.Combine(ModBase.PathTemp, "Crash.txt");
ModBase.WriteFile(FilePath, DirectFile.Value.Value.Join("\r\n"));
ModBase.ShellOnly(FilePath);
}
Expand Down Expand Up @@ -1277,17 +1277,17 @@ public void Output(bool IsHandAnalyze, List<string> ExtraFiles = null)
FileContent = ModMinecraft.FilterAccessToken(FileContent,
FileName == "启动脚本.bat" ? 'F' : '*');
FileContent = ModMinecraft.FilterUserName(FileContent, '*');
ModBase.WriteFile(TempFolder + @"Report\" + FileName, FileContent, Encoding: FileEncoding);
ModBase.WriteFile(Path.Combine(TempFolder, "Report", FileName), FileContent, Encoding: FileEncoding);
ModBase.Log($"[Crash] 导出文件:{FileName},编码:{FileEncoding.HeaderName}");
}
}

// 输出环境与启动信息
string EnvInfo = null;
string McLauncherLog = null;
McLauncherLog = ModBase.ReadFile(TempFolder + @"Report\PCL 启动器日志.txt")
McLauncherLog = ModBase.ReadFile(Path.Combine(TempFolder, "Report", "PCL 启动器日志.txt"))
.AfterLast("[Launch] ~ 基础参数 ~").BeforeFirst("开始 Minecraft 日志监控");
var LaunchScript = ModBase.ReadFile(TempFolder + @"Report\启动脚本.bat");
var LaunchScript = ModBase.ReadFile(Path.Combine(TempFolder, "Report", "启动脚本.bat"));
EnvInfo += $"PCL CE 版本:{ModBase.VersionBaseName} {"\r\n"}";
EnvInfo += $"识别码:{ModBase.UniqueAddress}{"\r\n"}";
EnvInfo += $"{"\r\n"}- 档案信息 -{"\r\n"}";
Expand All @@ -1312,11 +1312,11 @@ public void Output(bool IsHandAnalyze, List<string> ExtraFiles = null)
EnvInfo += "\r\n";
}

File.CreateText(TempFolder + @"Report\环境与启动信息.txt").Close();
ModBase.WriteFile(TempFolder + @"Report\环境与启动信息.txt", EnvInfo, Encoding: Encoding.UTF8);
File.CreateText(Path.Combine(TempFolder, "Report", "环境与启动信息.txt")).Close();
ModBase.WriteFile(Path.Combine(TempFolder, "Report", "环境与启动信息.txt"), EnvInfo, Encoding: Encoding.UTF8);
// 导出报告
ZipFile.CreateFromDirectory(TempFolder + @"Report\", FileAddress);
ModBase.DeleteDirectory(TempFolder + @"Report\");
ZipFile.CreateFromDirectory(Path.Combine(TempFolder, "Report"), FileAddress);
ModBase.DeleteDirectory(Path.Combine(TempFolder, "Report"));
ModMain.Hint("错误报告已导出!", ModMain.HintType.Finish);
}
catch (Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion Plain Craft Launcher 2/Modules/Minecraft/ModDownload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static DownloadFile DlClientAssetIndexGet(ModMinecraft.McInstance Version
Version = new ModMinecraft.McInstance(Version.InheritInstanceName);
// 获取信息
var IndexInfo = ModMinecraft.McAssetsGetIndex(Version, true, true);
var IndexAddress = ModMinecraft.McFolderSelected + @"assets\indexes\" + IndexInfo["id"] + ".json";
var IndexAddress = Path.Combine(ModMinecraft.McFolderSelected, "assets", "indexes", IndexInfo["id"] + ".json");
ModBase.Log("[Download] 实例 " + Version.Name + " 对应的资源文件索引为 " + IndexInfo["id"]);
var IndexUrl = (string)(IndexInfo["url"] ?? "");
if (string.IsNullOrEmpty(IndexUrl)) return null;
Expand Down
40 changes: 20 additions & 20 deletions Plain Craft Launcher 2/Modules/Minecraft/ModLaunch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2192,7 +2192,7 @@ public object HasArguments(string key)
/// </summary>
public static string ExtractJavaWrapper()
{
var WrapperPath = ModBase.PathPure + "JavaWrapper.jar";
var WrapperPath = Path.Combine(ModBase.PathPure, "JavaWrapper.jar");
ModBase.Log("[Java] 选定的 Java Wrapper 路径:" + WrapperPath);
lock (ExtractJavaWrapperLock) // 避免 OptiFine 和 Forge 安装时同时释放 Java Wrapper 导致冲突
{
Expand All @@ -2214,7 +2214,7 @@ public static string ExtractJavaWrapper()
catch (Exception ex2)
{
ModBase.Log(ex2, "Java Wrapper 文件重新释放失败,将尝试更换文件名重新生成", ModBase.LogLevel.Developer);
WrapperPath = ModBase.PathPure + "JavaWrapper2.jar";
WrapperPath = Path.Combine(ModBase.PathPure, "JavaWrapper2.jar");
try
{
WriteJavaWrapper(WrapperPath);
Expand Down Expand Up @@ -2247,7 +2247,7 @@ private static void WriteJavaWrapper(string Path)
/// </summary>
public static string ExtractLinkD()
{
var LinkDPath = ModBase.PathPure + "linkd.exe";
var LinkDPath = Path.Combine(ModBase.PathPure, "linkd.exe");
lock (ExtractLinkDLock) // 避免 OptiFine 和 Forge 安装时同时释放 Java Wrapper 导致冲突
{
try
Expand Down Expand Up @@ -2491,7 +2491,7 @@ private static string McLaunchArgumentsJvmOld(ModMinecraft.McInstance instance)
{
var Response = Requester.FetchString(Server);
DataList.Insert(0,
"-javaagent:\"" + ModBase.PathPure + "authlib-injector.jar\"=" + Server +
"-javaagent:\"" + Path.Combine(ModBase.PathPure, "authlib-injector.jar") + "\"=" + Server +
" -Dauthlibinjector.side=client" + " -Dauthlibinjector.yggdrasil.prefetched=" +
Convert.ToBase64String(Encoding.UTF8.GetBytes(Response)));
}
Expand Down Expand Up @@ -2526,7 +2526,7 @@ private static string McLaunchArgumentsJvmOld(ModMinecraft.McInstance instance)
Renderer = Conversions.ToInteger(Config.Launch.Renderer);
var MesaLoaderWindowsVersion = "25.3.5";
var MesaLoaderWindowsTargetFile =
ModBase.PathPure + @"\mesa-loader-windows\" + MesaLoaderWindowsVersion + @"\Loader.jar";
Path.Combine(ModBase.PathPure, "mesa-loader-windows", MesaLoaderWindowsVersion, "Loader.jar");

if (Renderer != 0)
DataList.Insert(0,
Expand Down Expand Up @@ -2614,7 +2614,7 @@ private static string McLaunchArgumentsJvmNew(ModMinecraft.McInstance instance)
{
var Response = Conversions.ToString(ModNet.NetGetCodeByRequestRetry(Server, Encoding.UTF8));
DataList.Insert(0,
"-javaagent:\"" + ModBase.PathPure + "authlib-injector.jar\"=" + Server +
"-javaagent:\"" + Path.Combine(ModBase.PathPure, "authlib-injector.jar") + "\"=" + Server +
" -Dauthlibinjector.side=client" + " -Dauthlibinjector.yggdrasil.prefetched=" +
Convert.ToBase64String(Encoding.UTF8.GetBytes(Response)));
}
Expand Down Expand Up @@ -2651,7 +2651,7 @@ private static string McLaunchArgumentsJvmNew(ModMinecraft.McInstance instance)
Renderer = Conversions.ToInteger(Config.Launch.Renderer);
var MesaLoaderWindowsVersion = "25.3.5";
var MesaLoaderWindowsTargetFile =
ModBase.PathPure + @"\mesa-loader-windows\" + MesaLoaderWindowsVersion + @"\Loader.jar";
Path.Combine(ModBase.PathPure, "mesa-loader-windows", MesaLoaderWindowsVersion, "Loader.jar");

if (Renderer != 0)
DataList.Insert(0,
Expand Down Expand Up @@ -2758,8 +2758,8 @@ private static string McLaunchArgumentsGameOld(ModMinecraft.McInstance Version)
" --tweakClass optifine.OptiFineForgeTweaker";
try
{
ModBase.WriteFile(Version.PathInstance + Version.Name + ".json",
ModBase.ReadFile(Version.PathInstance + Version.Name + ".json")
ModBase.WriteFile(Path.Combine(Version.PathInstance, Version.Name + ".json"),
ModBase.ReadFile(Path.Combine(Version.PathInstance, Version.Name + ".json"))
.Replace("optifine.OptiFineTweaker", "optifine.OptiFineForgeTweaker"));
}
catch (Exception ex)
Expand Down Expand Up @@ -2849,8 +2849,8 @@ private static string McLaunchArgumentsGameNew(ModMinecraft.McInstance instance)
" --tweakClass optifine.OptiFineForgeTweaker";
try
{
ModBase.WriteFile(instance.PathInstance + instance.Name + ".json",
ModBase.ReadFile(instance.PathInstance + instance.Name + ".json")
ModBase.WriteFile(Path.Combine(instance.PathInstance, instance.Name + ".json"),
ModBase.ReadFile(Path.Combine(instance.PathInstance, instance.Name + ".json"))
.Replace("optifine.OptiFineTweaker", "optifine.OptiFineForgeTweaker"));
}
catch (Exception ex)
Expand Down Expand Up @@ -2966,7 +2966,7 @@ private static Dictionary<string, string> McLaunchArgumentsReplace(ModMinecraft.
// LWJGL Unsafe Agent 释放
if (McLaunchUsesLwjglUnsafeAgent(instance))
{
string AgentPath = ModBase.PathPure + "lwjgl-unsafe-agent.jar";
string AgentPath = Path.Combine(ModBase.PathPure, "lwjgl-unsafe-agent.jar");
try
{
ModBase.WriteFile(AgentPath, ModBase.GetResourceStream("Resources/lwjgl-unsafe-agent.jar"));
Expand Down Expand Up @@ -3102,13 +3102,13 @@ private static void McLaunchNatives(ModLoader.LoaderTask<List<ModMinecraft.McLib
/// </summary>
private static string GetNativesFolder()
{
var Result = ModMinecraft.McInstanceSelected.PathInstance + ModMinecraft.McInstanceSelected.Name + "-natives";
var Result = Path.Combine(ModMinecraft.McInstanceSelected.PathInstance, ModMinecraft.McInstanceSelected.Name + "-natives");
if (ModBase.IsGBKEncoding || Result.IsASCII())
return Result;
Result = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\bin\natives";
Result = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".minecraft", "bin", "natives");
if (Result.IsASCII())
return Result;
return ModBase.OsDrive + @"ProgramData\PCL\natives";
return Path.Combine(ModBase.OsDrive, "ProgramData", "PCL", "natives");
}

#endregion
Expand Down Expand Up @@ -3230,15 +3230,15 @@ private static void McLaunchPrerun()
} while (false);

// 更新 options.txt
var SetupFileAddress = ModMinecraft.McInstanceSelected.PathIndie + "options.txt";
var SetupFileAddress = Path.Combine(ModMinecraft.McInstanceSelected.PathIndie, "options.txt");

// 辅助切换游戏语言
if (Config.Tool.AutoChangeLanguage)
{
if (!File.Exists(SetupFileAddress))
{
// Yosbr Mod 兼容(#2385):https://www.curseforge.com/minecraft/mc-mods/yosbr
var YosbrFileAddress = ModMinecraft.McInstanceSelected.PathIndie + @"config\yosbr\options.txt";
var YosbrFileAddress = Path.Combine(ModMinecraft.McInstanceSelected.PathIndie, "config", "yosbr", "options.txt");
if (File.Exists(YosbrFileAddress))
{
McLaunchLog("将修改 Yosbr Mod 中的 options.txt");
Expand All @@ -3257,7 +3257,7 @@ private static void McLaunchPrerun()
// 1.13+ :zh_cn 时正常,zh_CN 时自动切换为英文
var CurrentLang = ModBase.ReadIni(SetupFileAddress, "lang", "none");
string RequiredLang; // 需要的语言
var hasExistingSaves = Directory.Exists(ModMinecraft.McInstanceSelected.PathIndie + "saves");
var hasExistingSaves = Directory.Exists(Path.Combine(ModMinecraft.McInstanceSelected.PathIndie, "saves"));
var shouldUseDefault = CurrentLang == "none" || !hasExistingSaves;

// 获取 Minecraft 版本信息
Expand Down Expand Up @@ -3306,7 +3306,7 @@ private static void McLaunchPrerun()
}

// 如果是初次设置,一并修改 forceUnicodeFont,确保中文能正常显示
if (CurrentLang == "none" || !Directory.Exists(ModMinecraft.McInstanceSelected.PathIndie + "saves"))
if (CurrentLang == "none" || !Directory.Exists(Path.Combine(ModMinecraft.McInstanceSelected.PathIndie, "saves")))
{
ModBase.WriteIni(SetupFileAddress, "forceUnicodeFont", "true");
McLaunchLog("已开启 forceUnicodeFont,确保中文字体正常显示");
Expand Down Expand Up @@ -3547,7 +3547,7 @@ private static void McLaunchWait(ModLoader.LoaderTask<Process, int> Loader)
WindowTitle = ArgumentReplace(WindowTitle, false);

// JStack 路径
var JStackPath = McLaunchJavaSelected.Installation.JavaFolder + @"\jstack.exe";
var JStackPath = Path.Combine(McLaunchJavaSelected.Installation.JavaFolder, "jstack.exe");

// 初始化等待
var Watcher = new ModWatcher.Watcher(Loader, ModMinecraft.McInstanceSelected, WindowTitle,
Expand Down
4 changes: 2 additions & 2 deletions Plain Craft Launcher 2/Modules/Minecraft/ModLocalComp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,7 @@ private static void CompResourceListLoad(LoaderTask<CompLocalLoaderData, List<Lo
{
var DirInfo = new DirectoryInfo(SearchPath);
foreach (var Dir in DirInfo.EnumerateDirectories("*", SearchOption.AllDirectories))
ModList.Add(new LocalCompFile(Dir.FullName + @"\__FOLDER__"));
ModList.Add(new LocalCompFile(Path.Combine(Dir.FullName, "__FOLDER__")));
foreach (var File in DirInfo.EnumerateFiles("*", SearchOption.AllDirectories))
try
{
Expand Down Expand Up @@ -2313,7 +2313,7 @@ private static void CompUpdateDetailLoad(LoaderTask<CompLocalLoaderData, int> Lo
Cache[Entry.ModrinthHash + McInstance + string.Join("", ModLoaders)] = Entry.ToJson();
}

ModBase.WriteFile(ModBase.PathTemp + "Cache\\LocalComp.json",
ModBase.WriteFile(Path.Combine(ModBase.PathTemp, "Cache", "LocalComp.json"),
Cache.ToString(ModBase.ModeDebug ? Formatting.Indented : Formatting.None));

// 刷新 UI
Expand Down
Loading
Loading