Remove commons-codec dependency

This commit is contained in:
Articdive 2021-03-05 21:03:23 +01:00
parent eff0239258
commit dbfb3f7ff4
No known key found for this signature in database
GPG Key ID: B069585F0F7D90DE
3 changed files with 25 additions and 11 deletions

View File

@ -124,9 +124,6 @@ dependencies {
// https://mvnrepository.com/artifact/com.google.code.gson/gson
api 'com.google.code.gson:gson:2.8.6'
// https://mvnrepository.com/artifact/commons-codec/commons-codec
api 'commons-codec:commons-codec:1.15'
// Noise library for terrain generation
// https://jitpack.io/#Articdive/Jnoise
api 'com.github.Articdive:Jnoise:1.0.0'

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.metadata.animal;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.Metadata;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nullable;
import java.util.UUID;
public class FoxMeta extends AnimalMeta {

View File

@ -5,16 +5,27 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import it.unimi.dsi.fastutil.io.FastBufferedInputStream;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.net.URL;
import java.nio.file.*;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* Responsible for making sure Minestom has the necessary files to run (notably registry files)
@ -177,13 +188,19 @@ public class ResourceGatherer {
}
// Verify checksum
try (FileInputStream fis = new FileInputStream(target)) {
String sha1Target = DigestUtils.sha1Hex(fis);
MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
messageDigest.reset();
// This just converts the sha1 back into a readable string.
String sha1Target = new BigInteger(1, messageDigest.digest(fis.readAllBytes())).toString(16);
if (!sha1Target.equals(sha1Source)) {
LOGGER.debug("The checksum test failed after downloading the Minecraft server jar.");
LOGGER.debug("The expected checksum was: {}.", sha1Source);
LOGGER.debug("The calculated checksum was: {}.", sha1Target);
LOGGER.error("The checksum test failed after downloading the Minecraft server jar.");
LOGGER.error("The expected checksum was: {}.", sha1Source);
LOGGER.error("The calculated checksum was: {}.", sha1Target);
throw new IOException("Failed to download Minecraft server jar.");
}
} catch (NoSuchAlgorithmException e) {
LOGGER.error("Failed to find SHA-1 hashing algorithm in Java Environment.");
throw new IOException("Failed to download Minecraft server jar.");
}
return target;
}