@@ -353,38 +353,55 @@ pub struct OldSnapshotIndex {
353
353
pub struct LegacyOverrideEntry {
354
354
main_class : Option < String > ,
355
355
applet_class : Option < String > ,
356
- release_time : Option < String > ,
356
+ #[ serde( with = "time::serde::iso8601::option" ) ]
357
+ pub release_time : Option < time:: OffsetDateTime > ,
357
358
#[ serde( rename = "+traits" ) ]
358
359
additional_traits : Option < Vec < String > > ,
359
360
#[ serde( rename = "+jvmArgs" ) ]
360
361
additional_jvm_args : Option < Vec < String > > ,
361
362
}
362
363
363
364
impl LegacyOverrideEntry {
364
- pub fn apply_onto_meta_version ( self , meta_version : & MetaVersion , legacy : bool ) {
365
+ pub fn apply_onto_meta_version ( self , meta_version : & mut MetaVersion , legacy : bool ) {
365
366
// simply hard override classes
366
- // meta_version.main_class = self.main_class
367
- // meta_version.applet_class = self.applet_class
368
- // # if we have an updated release time (more correct than Mojang), use it
369
- // if self.release_time:
370
- // meta_version.release_time = self.release_time
371
-
372
- // # add traits, if any
373
- // if self.additional_traits:
374
- // if not meta_version.additional_traits:
375
- // meta_version.additional_traits = []
376
- // meta_version.additional_traits += self.additional_traits
377
-
378
- // if self.additional_jvm_args:
379
- // if not meta_version.additional_jvm_args:
380
- // meta_version.additional_jvm_args = []
381
- // meta_version.additional_jvm_args += self.additional_jvm_args
382
-
383
- // if legacy:
384
- // # remove all libraries - they are not needed for legacy
385
- // meta_version.libraries = None
386
- // # remove minecraft arguments - we use our own hardcoded ones
387
- // meta_version.minecraft_arguments = None
367
+
368
+ meta_version. main_class = self . main_class . clone ( ) ;
369
+ meta_version. applet_class = self . applet_class . clone ( ) ;
370
+
371
+ // if we have an updated release time (more correct than Mojang), use it
372
+ if let Some ( release_time) = & self . release_time {
373
+ meta_version. release_time = Some ( * release_time) ;
374
+ }
375
+
376
+ // add traits, if any
377
+ if let Some ( mut additional_traits) = self . additional_traits {
378
+ if !meta_version. additional_traits . is_some ( ) {
379
+ meta_version. additional_traits = Some ( vec ! [ ] ) ;
380
+ }
381
+ meta_version
382
+ . additional_traits
383
+ . as_mut ( )
384
+ . unwrap ( )
385
+ . append ( & mut additional_traits) ;
386
+ }
387
+
388
+ if let Some ( mut additional_jvm_args) = self . additional_jvm_args {
389
+ if !meta_version. additional_jvm_args . is_some ( ) {
390
+ meta_version. additional_jvm_args = Some ( vec ! [ ] ) ;
391
+ }
392
+ meta_version
393
+ . additional_jvm_args
394
+ . as_mut ( )
395
+ . unwrap ( )
396
+ . append ( & mut additional_jvm_args) ;
397
+ }
398
+
399
+ if legacy {
400
+ // remove all libraries - they are not needed for legacy
401
+ meta_version. libraries = None ;
402
+ // remove minecraft arguments - we use our own hardcoded ones
403
+ meta_version. minecraft_arguments = None ;
404
+ }
388
405
}
389
406
}
390
407
@@ -394,14 +411,15 @@ pub struct LegacyOverrideIndex {
394
411
}
395
412
396
413
#[ derive( Deserialize , Serialize , Debug , Clone , Validate ) ]
414
+ #[ serde( rename_all = "camelCase" , deny_unknown_fields) ]
397
415
pub struct LibraryPatch {
398
416
#[ serde( rename = "match" ) ]
399
417
pub patch_match : Vec < GradleSpecifier > ,
400
418
#[ serde( rename = "override" ) ]
401
419
pub patch_override : Option < Library > ,
402
- pub additionalLibraries : Option < Vec < Library > > ,
420
+ pub additional_libraries : Option < Vec < Library > > ,
403
421
#[ serde( default = "default_library_patch_patch_additional_libraries" ) ]
404
- pub patchAdditionalLibraries : bool ,
422
+ pub patch_additional_libraries : bool ,
405
423
}
406
424
407
425
fn default_library_patch_patch_additional_libraries ( ) -> bool {
@@ -435,6 +453,7 @@ impl Deref for LibraryPatches {
435
453
pub struct MojangArgumentObject { }
436
454
437
455
#[ derive( Deserialize , Serialize , Debug , Clone , Validate ) ]
456
+ #[ serde( untagged) ]
438
457
pub enum MojangArgument {
439
458
String ( String ) ,
440
459
Object ( MojangArgumentObject ) ,
@@ -477,6 +496,8 @@ fn mojang_logging_validate_type(
477
496
#[ derive( Deserialize , Serialize , Debug , Clone , Validate ) ]
478
497
#[ serde( rename_all = "camelCase" , deny_unknown_fields) ]
479
498
pub struct MojangVersion {
499
+ #[ serde( rename = "_comment_" ) ]
500
+ pub comment : Option < Vec < String > > ,
480
501
pub id : String , // TODO: optional?
481
502
pub arguments : Option < MojangArguments > ,
482
503
pub asset_index : Option < MojangAssets > ,
@@ -489,8 +510,10 @@ pub struct MojangVersion {
489
510
pub minecraft_arguments : Option < String > ,
490
511
#[ validate( custom( mojang_version_validate_minimum_launcher_version) ) ]
491
512
pub minimum_launcher_version : Option < i32 > ,
492
- pub release_time : Option < String > ,
493
- pub time : Option < String > ,
513
+ #[ serde( with = "time::serde::iso8601::option" ) ]
514
+ pub release_time : Option < time:: OffsetDateTime > ,
515
+ #[ serde( with = "time::serde::iso8601::option" ) ]
516
+ pub time : Option < time:: OffsetDateTime > ,
494
517
#[ serde( rename = "type" ) ]
495
518
pub version_type : Option < String > ,
496
519
pub inherits_from : Option < String > ,
@@ -533,7 +556,7 @@ impl MojangVersion {
533
556
let mut main_jar = None ;
534
557
let mut addn_traits = None ;
535
558
let mut new_type = self . version_type . clone ( ) ;
536
- let mut compatible_java_majors = None ;
559
+ let mut compatible_java_majors;
537
560
if !self . id . is_empty ( ) {
538
561
let downloads = self . downloads . clone ( ) . expect ( "Missing downloads" ) ;
539
562
let client_download = downloads
0 commit comments