Commits

Epic Ebic authored and md_5 committed 37ddb930802
#72: Replace launcher Mojang API with piston-data and use updated version meta api
No tags

src/main/java/org/spigotmc/builder/Builder.java

Modified
376 376 System.err.println( "**** Your BuildTools is out of date and will not build the requested version. Please grab a new copy from https://www.spigotmc.org/go/buildtools-dl" );
377 377 System.exit( 1 );
378 378 }
379 379
380 380 File vanillaJar = new File( workDir, "minecraft_server." + versionInfo.getMinecraftVersion() + ".jar" );
381 381 File embeddedVanillaJar = new File( workDir, "server-" + versionInfo.getMinecraftVersion() + ".jar" );
382 382 if ( !checkHash( vanillaJar, versionInfo ) )
383 383 {
384 384 if ( versionInfo.getServerUrl() != null )
385 385 {
386 - download( versionInfo.getServerUrl(), vanillaJar, HashFormat.MD5, versionInfo.getMinecraftHash() );
386 + download( versionInfo.getServerUrl().replace("launcher.mojang", "piston-data.mojang"), vanillaJar, HashFormat.MD5, versionInfo.getMinecraftHash() );
387 387 } else
388 388 {
389 389 download( getServerVanillaUrl( versionInfo.getMinecraftVersion() ), vanillaJar, HashFormat.MD5, versionInfo.getMinecraftHash() );
390 390 }
391 391 }
392 392
393 393 try ( JarFile jar = new JarFile( vanillaJar ) )
394 394 {
395 395 ZipEntry entry = jar.getEntry( "META-INF/versions/" + versionInfo.getMinecraftVersion() + "/server-" + versionInfo.getMinecraftVersion() + ".jar" );
396 396 if ( entry != null )
444 444 System.out.println( "Final mapped jar: " + finalMappedJar + " does not exist, creating (please wait)!" );
445 445
446 446 File classMappings = new File( "BuildData/mappings/" + versionInfo.getClassMappings() );
447 447 File memberMappings = new File( "BuildData/mappings/" + versionInfo.getMemberMappings() );
448 448 File fieldMappings = new File( workDir, "bukkit-" + mappingsVersion + "-fields.csrg" );
449 449 if ( versionInfo.getMappingsUrl() != null )
450 450 {
451 451 File mojangMappings = new File( workDir, "minecraft_server." + versionInfo.getMinecraftVersion() + ".txt" );
452 452 if ( !mojangMappings.exists() )
453 453 {
454 - download( versionInfo.getMappingsUrl(), mojangMappings );
454 + download( versionInfo.getMappingsUrl().replace("launcher.mojang.com", "piston-data.mojang.com"), mojangMappings );
455 455 }
456 456
457 457 MapUtil mapUtil = new MapUtil();
458 458 mapUtil.loadBuk( classMappings );
459 459 if ( !memberMappings.exists() )
460 460 {
461 461 memberMappings = new File( workDir, "bukkit-" + mappingsVersion + "-members.csrg" );
462 462 mapUtil.makeFieldMaps( mojangMappings, memberMappings, true );
463 463 } else if ( !fieldMappings.exists() )
464 464 {
1161 1161
1162 1162 Files.write( bytes, target );
1163 1163
1164 1164 return target;
1165 1165 }
1166 1166
1167 1167 public static String getServerVanillaUrl(String version) throws Exception
1168 1168 {
1169 1169 Gson gson = new Gson();
1170 1170
1171 - String responseManifest = get( "https://launchermeta.mojang.com/mc/game/version_manifest.json" );
1171 + String responseManifest = get( "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json" );
1172 1172 JsonObject manifest = gson.fromJson( responseManifest, JsonObject.class );
1173 1173
1174 1174 JsonArray manifestVersions = manifest.getAsJsonArray( "versions" );
1175 1175 for ( JsonElement manifestVersionElement : manifestVersions )
1176 1176 {
1177 1177 if ( manifestVersionElement.isJsonObject() )
1178 1178 {
1179 1179 JsonObject manifestVersion = manifestVersionElement.getAsJsonObject();
1180 1180 if ( manifestVersion.get( "id" ).getAsString().equals( version ) )
1181 1181 {

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut