3636import com .fox2code .foxloader .patching .mixin .MixinModLoader ;
3737import com .fox2code .foxloader .updater .FoxLoaderUpdater ;
3838import com .fox2code .foxloader .utils .Platform ;
39+ import com .fox2code .foxloader .utils .io .IOUtils ;
3940import com .google .gson .Gson ;
4041import com .google .gson .GsonBuilder ;
4142import net .minecraft .client .Minecraft ;
4647
4748import java .io .File ;
4849import java .io .IOException ;
50+ import java .io .InputStream ;
51+ import java .math .BigInteger ;
4952import java .util .*;
5053import java .util .jar .JarEntry ;
5154import java .util .jar .JarFile ;
@@ -65,6 +68,8 @@ public final class ModLoaderInit {
6568 static final File config = new File (FoxLauncher .getGameDir (), "config" );
6669 static final ModContainer FOX_LOADER_CONTAINER = new ModContainer (
6770 JavaLoadingPlugin .JAVA_LOADING_PLUGIN , JavaModInfo .FOX_LOADER_MOD_INFO );
71+ // When extracting the server jar, the FoxLoader SHA-256 is altered.
72+ public static final String FOXLOADER_TRUE_SHA_256 ;
6873 static final LinkedHashMap <String , ModContainer > modContainers = new LinkedHashMap <>();
6974 private static final Collection <ModContainer > modContainnersCollection =
7075 Collections .unmodifiableCollection (modContainers .values ());
@@ -75,6 +80,16 @@ public final class ModLoaderInit {
7580 ((LoadingPlugin ) JavaLoadingPlugin .JAVA_LOADING_PLUGIN ).javaModInfo = JavaModInfo .FOX_LOADER_MOD_INFO ;
7681 FoxLauncher .getFoxClassLoader ().injectMissingFileInfo (JavaModInfo .FOX_LOADER_MOD_INFO );
7782 assertValidModInfo (JavaModInfo .FOX_LOADER_MOD_INFO , true );
83+ String trueSha256 = JavaModInfo .FOX_LOADER_MOD_INFO .sha256 ;
84+ try (InputStream inputStream = FoxLauncher .class .getClassLoader ().getResourceAsStream ("META-INF/FL-SHA-256" )) {
85+ if (inputStream != null ) {
86+ if (FoxLauncher .isClient ()) {
87+ throw new RuntimeException ("This jar file has been erroneously tampered with." );
88+ }
89+ trueSha256 = new BigInteger (1 , IOUtils .readAllBytes (inputStream )).toString (16 );
90+ }
91+ } catch (IOException ignored ) {}
92+ FOXLOADER_TRUE_SHA_256 = trueSha256 ;
7893 }
7994
8095 public static @ NotNull Logger getModLoaderLogger () {
0 commit comments