11using System ;
22using System . Collections . Generic ;
33using System . IO ;
4- using System . Runtime . Serialization . Json ;
54using System . Security . Cryptography ;
65using System . Threading . Tasks ;
76using Flarial . Launcher . Runtime . Game ;
@@ -15,20 +14,20 @@ namespace Flarial.Launcher.Runtime.Client;
1514sealed class FlarialClientRelease : FlarialClient
1615{
1716 protected override string Build => nameof ( Release ) ;
18- protected override string Uri => "https://cdn.flarial.xyz/dll/latest.dll" ;
19- protected override string Name => $ "Flarial.Client.{ nameof ( Release ) } .dll";
17+ protected override string FileName => $ "Flarial.Client.{ nameof ( Release ) } .dll";
2018 protected override string Identifer => "34F45015-6EB6-4213-ABEF-F2967818E628" ;
19+ protected override string DownloadUri => "https://cdn.flarial.xyz/dll/latest.dll" ;
2120}
2221
2322public abstract class FlarialClient
2423{
2524 internal FlarialClient ( ) { }
2625 static readonly JsonService < Dictionary < string , string > > s_json = JsonService < Dictionary < string , string > > . GetJson ( ) ;
2726
28- protected abstract string Uri { get ; }
29- protected abstract string Name { get ; }
3027 protected abstract string Build { get ; }
28+ protected abstract string FileName { get ; }
3129 protected abstract string Identifer { get ; }
30+ protected abstract string DownloadUri { get ; }
3231
3332 public static readonly FlarialClient Release = new FlarialClientRelease ( ) ;
3433
@@ -42,15 +41,15 @@ static FlarialClient? Current
4241 }
4342 }
4443
45- public bool Launch ( bool initialized )
44+ public bool Launch ( bool ? initialized )
4645 {
4746 if ( Current is { } client )
4847 {
4948 if ( ! ReferenceEquals ( this , client ) ) return false ;
50- return Minecraft . Current . Launch ( false ) is { } ;
49+ return Minecraft . Current . Launch ( null ) is { } ;
5150 }
5251
53- if ( Injector . Launch ( initialized , new ( Name ) ) is not { } processId )
52+ if ( Injector . Launch ( initialized , new ( FileName ) ) is not { } processId )
5453 return false ;
5554
5655 using NativeMutex mutex = new ( Identifer ) ;
@@ -75,7 +74,7 @@ async Task<string> GetLocalHashAsync() => await Task.Run(() =>
7574 {
7675 lock ( _lock )
7776 {
78- using var stream = File . OpenRead ( Name ) ;
77+ using var stream = File . OpenRead ( FileName ) ;
7978 var value = _algorithm . ComputeHash ( stream ) ;
8079 var @string = BitConverter . ToString ( value ) ;
8180 return @string . Replace ( "-" , string . Empty ) ;
@@ -93,10 +92,10 @@ public async Task<bool> DownloadAsync(Action<int> callback)
9392 if ( ( await localHashTask ) . Equals ( await remoteHashTask , OrdinalIgnoreCase ) )
9493 return true ;
9594
96- try { File . Delete ( Name ) ; }
95+ try { File . Delete ( FileName ) ; }
9796 catch { return false ; }
9897
99- await HttpService . DownloadAsync ( Uri , Name , callback ) ;
98+ await HttpService . DownloadAsync ( DownloadUri , FileName , callback ) ;
10099 return true ;
101100 }
102101}
0 commit comments