-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use MD5 hash checker as temporary version check because I'm tired of …
…looking at it.
- Loading branch information
FarlanderCraft
committed
Feb 2, 2022
1 parent
d2233ca
commit 7c08a74
Showing
3 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/main/java/io/github/pseudodistant/provider/services/GetMD5FromJar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.github.pseudodistant.provider.services; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.InputStream; | ||
import java.security.MessageDigest; | ||
|
||
public class GetMD5FromJar { | ||
public static byte[] createChecksum(String filename) throws Exception { | ||
InputStream fis = new FileInputStream(filename); | ||
|
||
byte[] buffer = new byte[1024]; | ||
MessageDigest complete = MessageDigest.getInstance("MD5"); | ||
int numRead; | ||
|
||
do { | ||
numRead = fis.read(buffer); | ||
if (numRead > 0) { | ||
complete.update(buffer, 0, numRead); | ||
} | ||
} while (numRead != -1); | ||
|
||
fis.close(); | ||
return complete.digest(); | ||
} | ||
|
||
public static String getMD5Checksum(String filename) throws Exception { | ||
byte[] b = createChecksum(filename); | ||
String result = ""; | ||
for (int i=0; i < b.length; i++) { | ||
result += Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 ); | ||
} | ||
return result; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/io/github/pseudodistant/provider/services/GetVersionFromHash.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.github.pseudodistant.provider.services; | ||
|
||
import net.fabricmc.loader.impl.util.version.StringVersion; | ||
|
||
public class GetVersionFromHash { | ||
public static StringVersion getVersionFromHash(String hash) { | ||
String gameVersion = switch(hash) { | ||
case "f211b7cbfb31584af3cdce35f874fe0a" -> "1.9.1"; | ||
case "999940dbb17877e6bc6231476494dc26" -> "1.9.2"; | ||
case "53e7b293fdc5cd77340fea4373b8faaa" -> "1.9.3"; | ||
case "8f9f93761df1fb7caca44a79653f0f1a" -> "1.9.4"; | ||
case "f756156871a2d0cb615936a3eb5c7b93" -> "2.0.0"; | ||
case "3a324f65eaf17704030a009976cb9201" -> "2.0.1"; | ||
case "b5f4ebec06729f662321f53e0954c9e8" -> "2.0.2"; | ||
case "ba70baf0f36e06339709a49d09a56d86" -> "2.0.3"; | ||
case "b8a93275922008cb526c305b3854c432" -> "2.0.4"; | ||
case "e16893e756ef1b63c8b8dc98d3e1c77d" -> "2.0.5"; | ||
case "b49c32739d7266f8147e47ea09754f8d" -> "2.0.6"; | ||
case "5b283ce4e1f0bc41205c11eedf5610d0" -> "2.0.7"; | ||
case "e96d6ca22a402d69b8e35e4a80cd2582" -> "2.1.0-dev1"; | ||
default -> "0.0.0"; | ||
}; | ||
return new StringVersion(gameVersion); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters