11using System . Collections . Concurrent ;
2+ using ColorMC . Core . GuiHandel ;
23using ColorMC . Core . Helpers ;
34using ColorMC . Core . LaunchPath ;
45using ColorMC . Core . Nbt ;
@@ -172,26 +173,22 @@ public static async Task BackupAsync(this SaveObj world)
172173 /// <param name="obj">游戏实例</param>
173174 /// <param name="arg">参数</param>
174175 /// <returns>是否成功还原</returns>
175- public static async Task < bool > UnzipBackupWorldAsync ( this GameSettingObj obj , UnzipBackupWorldArg arg )
176+ public static async Task < bool > UnzipBackupWorldAsync ( this GameSettingObj obj , string file , IZipGui ? gui )
176177 {
177- var local = Path . Combine ( obj . GetSavesPath ( ) , Path . GetFileName ( arg . File ) ) ;
178+ var local = Path . Combine ( obj . GetSavesPath ( ) , Path . GetFileName ( file ) ) ;
178179 if ( Directory . Exists ( local ) )
179180 {
180- await PathHelper . DeleteFilesAsync ( new DeleteFilesArg
181- {
182- Local = local ,
183- Request = arg . Request
184- } ) ;
181+ await PathHelper . MoveToTrashAsync ( local ) ;
185182 }
186183 try
187184 {
188- await new ZipProcess ( ) . UnzipAsync ( local , arg . File ,
189- PathHelper . OpenRead ( arg . File ) ! ) ;
185+ await new ZipProcess ( gui ) . UnzipAsync ( local , file ,
186+ PathHelper . OpenRead ( file ) ! ) ;
190187 return true ;
191188 }
192189 catch ( Exception e )
193190 {
194- ColorMCCore . OnError ( new GameSaveRestoreErrorEventArgs ( obj , arg . File , e ) ) ;
191+ ColorMCCore . OnError ( new GameSaveRestoreErrorEventArgs ( obj , file , e ) ) ;
195192 return false ;
196193 }
197194 }
@@ -226,16 +223,16 @@ await PathHelper.DeleteFilesAsync(new DeleteFilesArg
226223
227224 //读数据
228225 var tag1 = tag . TryGet < NbtCompound > ( "Data" ) ! ;
229- obj . LastPlayed = tag1 . TryGet < NbtLong > ( "LastPlayed" ) ! . Value ;
226+ obj . LastPlayed = tag1 . TryGet < NbtLong > ( "LastPlayed" ) ! . ValueLong ;
230227 if ( tag1 . TryGet < NbtLong > ( "RandomSeed" ) is { } seed )
231228 {
232- obj . RandomSeed = seed . Value ;
229+ obj . RandomSeed = seed . ValueLong ;
233230 }
234231 if ( tag1 . TryGet < NbtCompound > ( "WorldGenSettings" ) is { } setting )
235232 {
236233 if ( setting . TryGet < NbtLong > ( "seed" ) is { } seed1 )
237234 {
238- obj . RandomSeed = seed1 . Value ;
235+ obj . RandomSeed = seed1 . ValueLong ;
239236 }
240237 if ( setting . TryGet < NbtCompound > ( "dimensions" ) ?
241238 . TryGet < NbtCompound > ( "minecraft:overworld" ) ?
@@ -250,9 +247,9 @@ await PathHelper.DeleteFilesAsync(new DeleteFilesArg
250247 obj . GeneratorName = "minecraft:" + name1 . Value ;
251248 }
252249
253- obj . GameType = tag1 . TryGet < NbtInt > ( "GameType" ) ! . Value ;
254- obj . Hardcore = tag1 . TryGet < NbtByte > ( "hardcore" ) ! . Value ;
255- obj . Difficulty = tag1 . TryGet < NbtByte > ( "Difficulty" ) ! . Value ;
250+ obj . GameType = tag1 . TryGet < NbtInt > ( "GameType" ) ! . ValueInt ;
251+ obj . Hardcore = tag1 . TryGet < NbtByte > ( "hardcore" ) ! . ValueByte ;
252+ obj . Difficulty = tag1 . TryGet < NbtByte > ( "Difficulty" ) ! . ValueByte ;
256253 obj . LevelName = tag1 . TryGet < NbtString > ( "LevelName" ) ! . Value ;
257254
258255 var icon = dir . GetFiles ( ) . Where ( a => a . Name == Names . NameIconFile ) . FirstOrDefault ( ) ;
0 commit comments