Skip to content

Commit

Permalink
Update to v0.1.0-rc2-hotfix1 (#62)
Browse files Browse the repository at this point in the history
* Check for empty URL before assigning GUID

Ensure GUIDs are only generated when texture URLs are successfully set. Prevents assigning GUIDs when URLs are empty, ensuring consistency in the texture application process.
  • Loading branch information
GamerVII-NET authored Oct 16, 2024
1 parent 5dcdda5 commit c477132
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Gml.Core.Interfaces/Launcher/IGameProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface IGameProfile : IDisposable
void AddServer(IProfileServer server);
void RemoveServer(IProfileServer server);
Task CreateModsFolder();
Task<IEnumerable<IFileInfo>> GetProfileFiles(string osName, string osArchitecture);
Task<ICollection<IFileInfo>> GetProfileFiles(string osName, string osArchitecture);
Task<IFileInfo[]> GetAllProfileFiles(bool needRestoreCache);
Task CreateUserSessionAsync(IUser user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ Task<Process> CreateProcess(IStartupOptions startupOptions, IUser user, bool nee
string[] jvmArguments, string[] gameArguments);
Task<IFileInfo[]> GetAllFiles(bool needRestoreCache);
bool GetLauncher(string launcherKey, out object launcher);
Task<IEnumerable<IFileInfo>> GetLauncherFiles(string osName, string osArchitecture);
Task<ICollection<IFileInfo>> GetLauncherFiles(string osName, string osArchitecture);
}
}
2 changes: 1 addition & 1 deletion src/Gml.Core.Interfaces/Procedures/IProfileProcedures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Task UpdateProfile(IGameProfile profile, string newProfileName, Stream? icon, St
Task<IGameProfileInfo?> GetCacheProfile(IGameProfile baseProfile);
Task SetCacheProfile(IGameProfileInfo profile);
Task CreateModsFolder(IGameProfile profile);
Task<IEnumerable<IFileInfo>> GetProfileFiles(IGameProfile profile, string osName, string osArchitecture);
Task<ICollection<IFileInfo>> GetProfileFiles(IGameProfile profile, string osName, string osArchitecture);
Task<IFileInfo[]> GetAllProfileFiles(IGameProfile baseProfile, bool needRestoreCache);
Task<IEnumerable<string>> GetAllowVersions(GameLoader result, string? minecraftVersion);
Task ChangeBootstrapProgram(IGameProfile testGameProfile, IBootstrapProgram version);
Expand Down
4 changes: 2 additions & 2 deletions src/Gml.Core/Core/Helpers/Game/GameDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public GameDownloader(IGameProfile profile, ILauncherInfo launcherInfo, INotific
var progressSubject = new Subject<string>();

progressSubject
.Buffer(TimeSpan.FromSeconds(2))
.Buffer(TimeSpan.FromMilliseconds(300))
.Select(items => string.Join(Environment.NewLine, items))
.Subscribe(combinedText =>
{
Expand All @@ -84,7 +84,7 @@ public GameDownloader(IGameProfile profile, ILauncherInfo launcherInfo, INotific

_fileProgress = new SyncProgress<InstallerProgressChangedEventArgs>(e =>
{
if (e.Name != null)
if (!string.IsNullOrEmpty(e.Name))
progressSubject.OnNext($"[{DateTime.Now:HH:m:ss:fff}] [INFO] {e.Name}");
});

Expand Down
2 changes: 1 addition & 1 deletion src/Gml.Core/Core/Helpers/Game/GameDownloaderProcedures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public bool GetLauncher(string launcherKey, out object launcher)
return _gameLoader.GetLauncher(launcherKey, out launcher);
}

public async Task<IEnumerable<IFileInfo>> GetLauncherFiles(string osName, string osArchitecture)
public async Task<ICollection<IFileInfo>> GetLauncherFiles(string osName, string osArchitecture)
{
if (!_gameLoader.GetLauncher($"{osName}/{osArchitecture}", out var dynamicLauncher)
|| dynamicLauncher is not MinecraftLauncher launcher)
Expand Down
17 changes: 11 additions & 6 deletions src/Gml.Core/Core/Helpers/Profiles/ProfileProcedures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public async Task<IEnumerable<IFileInfo>> GetProfileFiles(IGameProfile baseProfi
if (profile == null)
return null;

await profile.CreateUserSessionAsync(user);
_ = profile.CreateUserSessionAsync(user);

var profileDirectory = Path.Combine(profile.ClientPath, "platforms", startupOptions.OsName,
startupOptions.OsArch);
Expand Down Expand Up @@ -346,15 +346,15 @@ public async Task<IEnumerable<IFileInfo>> GetProfileFiles(IGameProfile baseProfi
ProfileName = profile.Name,
Description = profile.Description,
IconBase64 = profile.IconBase64,
JvmArguments = profile.JvmArguments,
GameArguments = profile.GameArguments,
JvmArguments = profile.JvmArguments ?? string.Empty,
GameArguments = profile.GameArguments ?? string.Empty,
HasUpdate = profile.State != ProfileState.Loading,
Arguments = arguments,
JavaPath = javaPath,
State = profile.State,
ClientVersion = profile.GameVersion,
MinecraftVersion = profile.GameVersion,
LaunchVersion = profile.LaunchVersion,
LaunchVersion = profile.LaunchVersion ?? string.Empty,
Files = files.OfType<LocalFileInfo>(),
WhiteListFolders = profile.FolderWhiteList?.OfType<LocalFolderInfo>().ToList() ?? [],
WhiteListFiles = profile.FileWhiteList?.OfType<LocalFileInfo>().ToList() ?? []
Expand All @@ -367,10 +367,15 @@ public async Task<IEnumerable<IFileInfo>> GetProfileFiles(IGameProfile baseProfi
Arguments = string.Empty,
JavaPath = string.Empty,
State = profile.State,
Files = files.OfType<LocalFileInfo>(),
IconBase64 = profile.IconBase64,
Description = profile.Description,
ClientVersion = profile.GameVersion,
LaunchVersion = profile.LaunchVersion,
JvmArguments = profile.JvmArguments ?? string.Empty,
GameArguments = profile.GameArguments ?? string.Empty,
LaunchVersion = profile.LaunchVersion ?? string.Empty,
WhiteListFolders = profile.FolderWhiteList?.OfType<LocalFolderInfo>().ToList() ?? [],
WhiteListFiles = profile.FileWhiteList?.OfType<LocalFileInfo>().ToList() ?? [],
HasUpdate = profile.State != ProfileState.Loading,
MinecraftVersion = profile.GameVersion
};
Expand Down Expand Up @@ -639,7 +644,7 @@ public Task CreateModsFolder(IGameProfile profile)
return Task.CompletedTask;
}

public Task<IEnumerable<IFileInfo>> GetProfileFiles(
public Task<ICollection<IFileInfo>> GetProfileFiles(
IGameProfile profile,
string osName,
string osArchitecture)
Expand Down
12 changes: 10 additions & 2 deletions src/Gml.Core/Core/User/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ public class User : IUser
public async Task DownloadAndInstallSkinAsync(string skinUrl)
{
TextureSkinUrl = await Manager.Integrations.TextureProvider.SetSkin(this, skinUrl);
TextureSkinGuid = Guid.NewGuid().ToString();

if (!string.IsNullOrEmpty(TextureSkinUrl))
TextureSkinGuid = Guid.NewGuid().ToString();
else
TextureSkinGuid = string.Empty;
}


public async Task DownloadAndInstallCloakAsync(string cloakUrl)
{
TextureCloakUrl = await Manager.Integrations.TextureProvider.SetCloak(this, cloakUrl);
TextureCloakGuid = Guid.NewGuid().ToString();

if (!string.IsNullOrEmpty(TextureCloakUrl))
TextureCloakGuid = Guid.NewGuid().ToString();
else
TextureSkinGuid = string.Empty;
}

public Task SaveUserAsync()
Expand Down
2 changes: 1 addition & 1 deletion src/Gml.Core/Models/BaseProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public Task CreateModsFolder()
return ProfileProcedures.CreateModsFolder(this);
}

public Task<IEnumerable<IFileInfo>> GetProfileFiles(string osName, string osArchitecture)
public Task<ICollection<IFileInfo>> GetProfileFiles(string osName, string osArchitecture)
{
return ProfileProcedures.GetProfileFiles(this, osName, osArchitecture);
}
Expand Down

0 comments on commit c477132

Please sign in to comment.