diff options
author | md_5 <git@md-5.net> | 2015-07-29 19:54:14 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2015-07-29 20:11:57 +1000 |
commit | 00c9da2167f25e85cdac960a1213f2a9e87d6b31 (patch) | |
tree | 78f4a779d65e00e3c6c3a551bbae37d0599db847 /src/main/java/org | |
parent | fdaa042d6b07403b4e031e7fa582d20962340a18 (diff) | |
download | buildtools-00c9da2167f25e85cdac960a1213f2a9e87d6b31.tar buildtools-00c9da2167f25e85cdac960a1213f2a9e87d6b31.tar.gz buildtools-00c9da2167f25e85cdac960a1213f2a9e87d6b31.tar.lz buildtools-00c9da2167f25e85cdac960a1213f2a9e87d6b31.tar.xz buildtools-00c9da2167f25e85cdac960a1213f2a9e87d6b31.zip |
Add option to check for hash of Vanilla server jar.
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/spigotmc/builder/Builder.java | 25 | ||||
-rw-r--r-- | src/main/java/org/spigotmc/builder/VersionInfo.java | 1 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/org/spigotmc/builder/Builder.java b/src/main/java/org/spigotmc/builder/Builder.java index 54da43d..dfdc551 100644 --- a/src/main/java/org/spigotmc/builder/Builder.java +++ b/src/main/java/org/spigotmc/builder/Builder.java @@ -173,7 +173,7 @@ public class Builder File maven; String m2Home = System.getenv( "M2_HOME" ); - if ( m2Home == null || !(maven = new File(m2Home)).exists() ) + if ( m2Home == null || !( maven = new File( m2Home ) ).exists() ) { maven = new File( "apache-maven-3.2.5" ); @@ -240,15 +240,20 @@ public class Builder // Default to 1.8 builds. if ( versionInfo == null ) { - versionInfo = new VersionInfo( "1.8", "bukkit-1.8.at", "bukkit-1.8-cl.csrg", "bukkit-1.8-members.csrg", "package.srg" ); + versionInfo = new VersionInfo( "1.8", "bukkit-1.8.at", "bukkit-1.8-cl.csrg", "bukkit-1.8-members.csrg", "package.srg", null ); } System.out.println( "Attempting to build Minecraft with details: " + versionInfo ); File vanillaJar = new File( workDir, "minecraft_server." + versionInfo.getMinecraftVersion() + ".jar" ); - if ( !vanillaJar.exists() ) + if ( !vanillaJar.exists() || !checkHash( vanillaJar, versionInfo ) ) { download( String.format( "https://s3.amazonaws.com/Minecraft.Download/versions/%1$s/minecraft_server.%1$s.jar", versionInfo.getMinecraftVersion() ), vanillaJar ); } + if ( !checkHash( vanillaJar, versionInfo ) ) + { + System.err.println( "**** Could not download clean Minecraft jar, giving up." ); + return; + } Iterable<RevCommit> mappings = buildGit.log() .addPath( "mappings/" + versionInfo.getAccessTransforms() ) @@ -420,6 +425,20 @@ public class Builder } } + private static boolean checkHash(File vanillaJar, VersionInfo versionInfo) throws IOException + { + String hash = Files.hash( vanillaJar, Hashing.md5() ).toString(); + if ( !dev && versionInfo.getMinecraftHash() != null && !hash.equals( versionInfo.getMinecraftHash() ) ) + { + System.err.println( "**** Warning, Minecraft jar hash of " + hash + " does not match stored hash of " + versionInfo.getMinecraftHash() ); + return false; + } else + { + System.out.println( "Found good Minecraft hash (" + hash + ")" ); + return true; + } + } + public static final String get(String url) throws IOException { URLConnection con = new URL( url ).openConnection(); diff --git a/src/main/java/org/spigotmc/builder/VersionInfo.java b/src/main/java/org/spigotmc/builder/VersionInfo.java index 9ab97f2..e3a4f34 100644 --- a/src/main/java/org/spigotmc/builder/VersionInfo.java +++ b/src/main/java/org/spigotmc/builder/VersionInfo.java @@ -13,4 +13,5 @@ public class VersionInfo private String classMappings; private String memberMappings; private String packageMappings; + private String minecraftHash; } |