Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
Coloryr committed Jun 19, 2024
1 parent bc83b96 commit 73bd86e
Show file tree
Hide file tree
Showing 50 changed files with 105 additions and 139 deletions.
2 changes: 1 addition & 1 deletion src/ColorMC.Core/Asm/NettyServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public async Task<int> RunServerAsync()

return port;
}
catch(Exception e)
catch (Exception e)
{
Logs.Crash("netty error", e);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Core/Downloader/DownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private static async Task<bool> StartAsync(ICollection<DownloadItemObj> list, Do
}
else
{
arg.Update?.Invoke(s_threads.Count, State,
arg.Update?.Invoke(s_threads.Count, State,
s_tasks.Count + (s_nowTask != null ? 1 : 0));
}

Expand Down
7 changes: 1 addition & 6 deletions src/ColorMC.Core/Downloader/DownloadTask.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using ColorMC.Core.Config;
using ColorMC.Core.Helpers;
using ColorMC.Core.Objs;
Expand Down
6 changes: 3 additions & 3 deletions src/ColorMC.Core/Game/GameAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static async Task<LoginRes> LoginOAuthAsync(ColorMCCore.LoginOAuthCode lo
if (res2.State != LoginState.Done)
{
return new LoginRes
{
{
AuthState = AuthState.OAuth,
LoginState = res2.State,
Message = LanguageHelper.Get("Core.Login.Error1")
Expand Down Expand Up @@ -250,7 +250,7 @@ public static async Task<LoginRes> LoginNide8Async(string server, string user, s
return new LoginRes
{
AuthState = AuthState.Token,
LoginState= res1.State,
LoginState = res1.State,
Message = string.Format(LanguageHelper.Get("Core.Login.Error9"), res1.Message)
};
}
Expand Down Expand Up @@ -301,7 +301,7 @@ public static async Task<LoginRes> RefreshNide8Async(LoginObj obj)
};
}
return new LoginRes
{
{
AuthState = AuthState.Profile,
LoginState = LoginState.Done,
Auth = res1.Auth
Expand Down
4 changes: 2 additions & 2 deletions src/ColorMC.Core/Game/GameLang.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ public static Dictionary<string, string> GetLangs(this AssetsObj? obj)
{
foreach (var item in obj.objects)
{
if (item.Key.StartsWith(Name1) && item.Key.Contains(temp)
if (item.Key.StartsWith(Name1) && item.Key.Contains(temp)
&& AssetsPath.ReadAsset(item.Value.hash) is { } str)
{
try
{
var data = JsonConvert.DeserializeObject<LangObj>(str)!;
return new LangRes
return new LangRes
{
Key = (item.Key.Replace(Name1, "").Replace(".json", "")),
Name = data.Name + "-" + data.Region
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Core/Game/GameLaunch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ private static async Task<List<string>> MakeArgAsync(this GameSettingObj obj, Ga
{
if (larg.Request == null)
{
throw new LaunchException(LaunchState.VersionError,
throw new LaunchException(LaunchState.VersionError,
string.Format(LanguageHelper.Get("Core.Launch.Info16"), obj.Name));
}
var res2 = await larg.Request(string.Format(LanguageHelper.Get("Core.Launch.Info15"), obj.Name));
Expand Down
6 changes: 3 additions & 3 deletions src/ColorMC.Core/Game/ServerPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ public static GetServerPackRes GetServerPack(this GameSettingObj obj)
}

return new GetServerPackRes
{
{
Pack = obj1,
Sha1 = sha1,
Sha1 = sha1,
};
}

Expand Down Expand Up @@ -283,7 +283,7 @@ public static async Task<bool> GenServerPackAsync(this ServerPackObj obj, Server

await PathHelper.DeleteFilesAsync(new DeleteFilesArg
{
Local = arg.Local,
Local = arg.Local,
Request = arg.Request
});
Directory.CreateDirectory(arg.Local);
Expand Down
9 changes: 4 additions & 5 deletions src/ColorMC.Core/Helpers/AddGameHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using ColorMC.Core.LaunchPath;
using ColorMC.Core.Objs;
using ColorMC.Core.Objs.CurseForge;
using ColorMC.Core.Objs.Modrinth;
using ColorMC.Core.Objs.OtherLaunch;
using ColorMC.Core.Utils;
using ICSharpCode.SharpZipLib.Zip;
Expand Down Expand Up @@ -163,9 +162,9 @@ public static async Task<GameRes> InstallZip(InstallZipArg arg)
break;

game = await InstancesPath.CreateGame(new CreateGameArg
{
Game = game,
Request = arg.Request,
{
Game = game,
Request = arg.Request,
Overwirte = arg.Overwirte
});

Expand Down Expand Up @@ -548,5 +547,5 @@ public static async Task<GameRes> InstallCurseForge(DownloadCurseForgeArg arg)
return res2;
}


}
2 changes: 1 addition & 1 deletion src/ColorMC.Core/Helpers/CheckHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public static async Task<ConcurrentBag<DownloadItemObj>> CheckGameFileAsync(this
{
//不存在游戏
var var = await VersionPath.GetVersionsAsync();
var version = var?.versions.Where(a => a.id == obj.Version).FirstOrDefault()
var version = var?.versions.Where(a => a.id == obj.Version).FirstOrDefault()
?? throw new LaunchException(LaunchState.VersionError, LanguageHelper.Get("Core.Launch.Error1"));
var res1 = await DownloadItemHelper.BuildVersionDownloadAsync(version)
?? throw new LaunchException(LaunchState.VersionError, LanguageHelper.Get("Core.Launch.Error1"));
Expand Down
3 changes: 1 addition & 2 deletions src/ColorMC.Core/Helpers/GameHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using ColorMC.Core.Objs.Minecraft;
using ColorMC.Core.Objs.OtherLaunch;
using ICSharpCode.SharpZipLib.Zip;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace ColorMC.Core.Helpers;
Expand Down Expand Up @@ -699,7 +698,7 @@ public static GameSettingObj ToColorMC(this HMCLObj obj)
}
}
}

return game;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Core/Helpers/JavaHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private static List<string> GetOracleJavaInstallPath(string javaKeyPath)
}
catch
{

}
return [];
}
Expand Down
8 changes: 1 addition & 7 deletions src/ColorMC.Core/Helpers/LanGameHelper.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ColorMC.Core.Helpers;
namespace ColorMC.Core.Helpers;

public static class LanGameHelper
{
Expand Down
37 changes: 18 additions & 19 deletions src/ColorMC.Core/Helpers/ModPackHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Concurrent;
using System.Text;
using ColorMC.Core.Downloader;
using ColorMC.Core.LaunchPath;
Expand Down Expand Up @@ -78,10 +77,10 @@ public static async Task<bool> UpdateModPack(UpdateModrinthModPackArg arg)
return false;

res = await UpdateModrinthModPackAsync(new UpdateModPackArg
{
{
Game = arg.Game,
Zip = item.Local,
Update = arg.Update,
Zip = item.Local,
Update = arg.Update,
Update2 = arg.Update2
});
if (res)
Expand Down Expand Up @@ -265,10 +264,10 @@ public static async Task<bool> UpdateCurseForgeModPackAsync(UpdateModPackArg arg
obj1.Mods.Clear();

var list = await CurseForgeHelper.GetModInfo(new GetCurseForgeModInfoArg
{
Game = obj1,
Info = info,
Update = arg.Update
{
Game = obj1,
Info = info,
Update = arg.Update
});
if (!list.State)
{
Expand Down Expand Up @@ -432,10 +431,10 @@ public static async Task<GameRes> InstallCurseForgeModPackAsync(InstallModPackZi
};

game = await InstancesPath.CreateGame(new CreateGameArg
{
{
Game = game,
Request = arg.Request,
Overwirte = arg.Overwirte
Overwirte = arg.Overwirte
});

if (game == null)
Expand Down Expand Up @@ -591,10 +590,10 @@ public static async Task<bool> UpdateModrinthModPackAsync(UpdateModPackArg arg)

//获取Mod信息
var list = ModrinthHelper.GetModrinthModInfo(new GetModrinthModInfoArg
{
Game = obj1,
Info = info,
Update = arg.Update
{
Game = obj1,
Info = info,
Update = arg.Update
});
var list1 = new List<DownloadItemObj>();

Expand Down Expand Up @@ -860,11 +859,11 @@ public static async Task<GameRes> InstallModrinthModPackAsync(InstallModPackZipA

//获取Mod信息

var list = ModrinthHelper.GetModrinthModInfo(new GetModrinthModInfoArg
{
Game = game,
Info = info,
Update = arg.Update
var list = ModrinthHelper.GetModrinthModInfo(new GetModrinthModInfoArg
{
Game = game,
Info = info,
Update = arg.Update
});

game.SaveModInfo();
Expand Down
1 change: 0 additions & 1 deletion src/ColorMC.Core/Helpers/PathHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Diagnostics;
using System.Text;
using ColorMC.Core.Objs;
using ColorMC.Core.Utils;
Expand Down
4 changes: 2 additions & 2 deletions src/ColorMC.Core/LaunchPath/InstancesPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,10 @@ public static void CopyObj(this GameSettingObj obj, GameSettingObj now)
var obj1 = obj.CopyObj();
obj1.Name = name;
obj1 = await CreateGame(new CreateGameArg
{
{
Game = obj1,
Request = request,
Overwirte = overwirte
Overwirte = overwirte
});
if (obj1 != null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/ColorMC.Core/Net/Login/AuthlibInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public static async Task<LegacyLoginRes> RefreshAsync(LoginObj obj)
{
return new LegacyLoginRes
{
State = LoginState.Done,
Auth = obj
State = LoginState.Done,
Auth = obj
};
}
return await LegacyLogin.RefreshAsync(obj.Text1, obj);
Expand Down
4 changes: 2 additions & 2 deletions src/ColorMC.Core/Net/Login/LegacyLogin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static async Task<LegacyLoginRes> RefreshAsync(string server, LoginObj ob
var data = await res.Content.ReadAsStringAsync();
if (string.IsNullOrWhiteSpace(data))
return new LegacyLoginRes
{
{
State = LoginState.Error,
Message = LanguageHelper.Get("Core.Login.Error24")
};
Expand All @@ -151,7 +151,7 @@ public static async Task<LegacyLoginRes> RefreshAsync(string server, LoginObj ob
{
State = LoginState.Error,
Message = msg
};;
}; ;
}
return new LegacyLoginRes
{
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Core/Net/Login/Nide8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static async Task<LegacyLoginRes> RefreshAsync(LoginObj obj)
if (await LegacyLogin.ValidateAsync(server + "/authserver/validate", obj))
{
return new LegacyLoginRes
{
{
State = LoginState.Done,
Auth = obj
};
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Core/Objs/Args.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ColorMC.Core.Objs.CurseForge;
using ColorMC.Core.Objs.CurseForge;
using ColorMC.Core.Objs.Login;
using ColorMC.Core.Objs.Minecraft;
using ColorMC.Core.Objs.Modrinth;
Expand Down
14 changes: 4 additions & 10 deletions src/ColorMC.Core/Objs/OtherLaunch/OfficialObj.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ColorMC.Core.Objs.OtherLaunch;
namespace ColorMC.Core.Objs.OtherLaunch;

public record OfficialObj
{
public record PatchObj
{
{
public string id { get; set; }
public string version { get; set; }
}
public record LibrarieObj
{
{
public string name { get; set; }
}
public record ArgumentsObj
{
{
public List<object> game { get; set; }
}
public string id { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/ColorMC.Core/Objs/Results.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Concurrent;
using System.Collections.Concurrent;
using ColorMC.Core.Objs.Login;
using ColorMC.Core.Objs.ServerPack;

Expand Down Expand Up @@ -70,7 +70,7 @@ public record OAuthGetTokenRes
/// </summary>
public record OAuthRefreshTokenRes : OAuthGetTokenRes
{

}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Core/Utils/ZipUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace ColorMC.Core.Utils;
/// <summary>
/// 压缩包处理
/// </summary>
public class ZipUtils(ColorMCCore.ZipUpdate? ZipUpdate = null,
public class ZipUtils(ColorMCCore.ZipUpdate? ZipUpdate = null,
ColorMCCore.Request? GameRequest = null)
{
private int Size = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Gui/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public static void ShowAddJava(int version)
else
{
AddJavaWindow = new()
{
{
NeedJava = version
};
AWindow(AddJavaWindow);
Expand Down
4 changes: 2 additions & 2 deletions src/ColorMC.Gui/ColorMCGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace ColorMC.Gui;
public static class ColorMCGui
{
public static readonly CoreInitArg Arg = new()
{
{
CurseForgeKey = "$2a$10$6L8AkVsaGMcZR36i8XvCr.O4INa2zvDwMhooYdLZU0bb/E78AsT0m",
OAuthKey = "aa0dd576-d717-4950-b257-a478d2c20968"
};
Expand Down Expand Up @@ -219,7 +219,7 @@ public static AppBuilder BuildAvaloniaApp()
}
else if (config1.SoftwareRender == true)
{
opt1.RenderingMode = [X11RenderingMode.Software];
opt1.RenderingMode = [X11RenderingMode.Software];
}

var opt2 = new MacOSPlatformOptions()
Expand Down
Loading

0 comments on commit 73bd86e

Please sign in to comment.