@@ -996,6 +996,29 @@ impl Conn {
996996 let version = val. get ( "version" ) . ok_or ( invalid_status ( ) ) ?;
997997 let players = val. get ( "players" ) . ok_or ( invalid_status ( ) ) ?;
998998
999+ // TODO: Option<> to distinguish non-modded, vs no mods?
1000+ let mut forge_mods: std:: vec:: Vec < crate :: server:: plugin_messages:: ForgeMod > = vec ! [ ] ;
1001+ if let Some ( modinfo) = val. get ( "modinfo" ) {
1002+ if let Some ( modinfo_type) = modinfo. get ( "type" ) {
1003+ if modinfo_type == "FML" {
1004+ if let Some ( modlist) = modinfo. get ( "modList" ) {
1005+ if let Value :: Array ( items) = modlist {
1006+ for item in items {
1007+ if let Value :: Object ( obj) = item {
1008+ let modid = obj. get ( "modid" ) . unwrap ( ) . as_str ( ) . unwrap ( ) . to_string ( ) ;
1009+ let version = obj. get ( "version" ) . unwrap ( ) . as_str ( ) . unwrap ( ) . to_string ( ) ;
1010+
1011+ forge_mods. push ( crate :: server:: plugin_messages:: ForgeMod { modid, version } ) ;
1012+ }
1013+ }
1014+ }
1015+ }
1016+ } else {
1017+ panic ! ( "Unrecognized modinfo type in server ping response: {} in {}" , modinfo_type, modinfo) ;
1018+ }
1019+ }
1020+ }
1021+
9991022 Ok ( ( Status {
10001023 version : StatusVersion {
10011024 name : version. get ( "name" ) . and_then ( Value :: as_str) . ok_or ( invalid_status ( ) ) ?
@@ -1016,6 +1039,7 @@ impl Conn {
10161039 description : format:: Component :: from_value ( val. get ( "description" )
10171040 . ok_or ( invalid_status ( ) ) ?) ,
10181041 favicon : val. get ( "favicon" ) . and_then ( Value :: as_str) . map ( |v| v. to_owned ( ) ) ,
1042+ forge_mods,
10191043 } ,
10201044 ping) )
10211045 }
@@ -1027,6 +1051,7 @@ pub struct Status {
10271051 pub players : StatusPlayers ,
10281052 pub description : format:: Component ,
10291053 pub favicon : Option < String > ,
1054+ pub forge_mods : Vec < crate :: server:: plugin_messages:: ForgeMod > ,
10301055}
10311056
10321057#[ derive( Debug ) ]
0 commit comments