Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50:07 +01:00
Refactor Jars to ThirdPartyManager
Dieser Commit ist enthalten in:
Ursprung
781c1e943b
Commit
b728989355
@ -21,7 +21,7 @@ import com.boydti.fawe.bukkit.util.ItemUtil;
|
|||||||
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.regions.FaweMaskManager;
|
import com.boydti.fawe.regions.FaweMaskManager;
|
||||||
import com.boydti.fawe.util.Jars;
|
import com.boydti.fawe.util.ThirdPartyManager;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.boydti.fawe.util.WEManager;
|
import com.boydti.fawe.util.WEManager;
|
||||||
import com.boydti.fawe.util.image.ImageViewer;
|
import com.boydti.fawe.util.image.ImageViewer;
|
||||||
@ -123,7 +123,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
if (manager.getPlugin("PacketListenerApi") == null) {
|
if (manager.getPlugin("PacketListenerApi") == null) {
|
||||||
File output = new File(plugin.getDataFolder().getParentFile(),
|
File output = new File(plugin.getDataFolder().getParentFile(),
|
||||||
"PacketListenerAPI_v3.7.6-SNAPSHOT.jar");
|
"PacketListenerAPI_v3.7.6-SNAPSHOT.jar");
|
||||||
byte[] jarData = Jars.PL_v3_7_6.download();
|
byte[] jarData = ThirdPartyManager.PacketListenerAPI.download();
|
||||||
try (FileOutputStream fos = new FileOutputStream(output)) {
|
try (FileOutputStream fos = new FileOutputStream(output)) {
|
||||||
fos.write(jarData);
|
fos.write(jarData);
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
if (manager.getPlugin("MapManager") == null) {
|
if (manager.getPlugin("MapManager") == null) {
|
||||||
File output = new File(plugin.getDataFolder().getParentFile(),
|
File output = new File(plugin.getDataFolder().getParentFile(),
|
||||||
"MapManager_v1.7.8-SNAPSHOT.jar");
|
"MapManager_v1.7.8-SNAPSHOT.jar");
|
||||||
byte[] jarData = Jars.MM_v1_7_8.download();
|
byte[] jarData = ThirdPartyManager.MapManager.download();
|
||||||
try (FileOutputStream fos = new FileOutputStream(output)) {
|
try (FileOutputStream fos = new FileOutputStream(output)) {
|
||||||
fos.write(jarData);
|
fos.write(jarData);
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,14 @@ import java.util.Base64;
|
|||||||
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
//TODO: Look into renaming this class or moving to a new package.
|
|
||||||
/** An internal FAWE class not meant for public use. **/
|
/** An internal FAWE class not meant for public use. **/
|
||||||
public enum Jars {
|
public enum ThirdPartyManager {
|
||||||
|
|
||||||
MM_v1_7_8(
|
MapManager(
|
||||||
"https://github.com/InventivetalentDev/MapManager/releases/download/1.7.8-SNAPSHOT/MapManager_v1.7.8-SNAPSHOT.jar",
|
"https://github.com/InventivetalentDev/MapManager/releases/download/1.7.8-SNAPSHOT/MapManager_v1.7.8-SNAPSHOT.jar",
|
||||||
"m3YLUqZz66k2DmvdcYLeu38u3zKRKhrAXqGGpVKfO6g=", 544000),
|
"m3YLUqZz66k2DmvdcYLeu38u3zKRKhrAXqGGpVKfO6g=", 544000),
|
||||||
|
|
||||||
PL_v3_7_6(
|
PacketListenerAPI(
|
||||||
"https://github.com/InventivetalentDev/PacketListenerAPI/releases/download/3.7.6-SNAPSHOT/PacketListenerAPI_v3.7.6-SNAPSHOT.jar",
|
"https://github.com/InventivetalentDev/PacketListenerAPI/releases/download/3.7.6-SNAPSHOT/PacketListenerAPI_v3.7.6-SNAPSHOT.jar",
|
||||||
"etdBRzLn5pRVDfr/mSQdPm6Jjer3wQOKhcn8fUxo5zM=", 143000),
|
"etdBRzLn5pRVDfr/mSQdPm6Jjer3wQOKhcn8fUxo5zM=", 143000),
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ public enum Jars {
|
|||||||
* @param digest The Base64-encoded SHA-256 digest
|
* @param digest The Base64-encoded SHA-256 digest
|
||||||
* @param fileSize Size of this jar in bytes
|
* @param fileSize Size of this jar in bytes
|
||||||
*/
|
*/
|
||||||
Jars(String url, String digest, int fileSize) {
|
ThirdPartyManager(String url, String digest, int fileSize) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.digest = digest;
|
this.digest = digest;
|
||||||
this.fileSize = fileSize;
|
this.fileSize = fileSize;
|
||||||
@ -47,7 +46,7 @@ public enum Jars {
|
|||||||
try (DataInputStream dis = new DataInputStream(url.openConnection().getInputStream())) {
|
try (DataInputStream dis = new DataInputStream(url.openConnection().getInputStream())) {
|
||||||
dis.readFully(jarBytes);
|
dis.readFully(jarBytes);
|
||||||
if (dis.read() != -1) { // assert that we've read everything
|
if (dis.read() != -1) { // assert that we've read everything
|
||||||
throw new IllegalStateException("downloaded jar is longer than expected");
|
throw new IllegalStateException("Downloaded jar is longer than expected");
|
||||||
}
|
}
|
||||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||||
byte[] jarDigestBytes = md.digest(jarBytes);
|
byte[] jarDigestBytes = md.digest(jarBytes);
|
||||||
@ -55,12 +54,12 @@ public enum Jars {
|
|||||||
String jarDigest = Base64.getEncoder().encodeToString(jarDigestBytes);
|
String jarDigest = Base64.getEncoder().encodeToString(jarDigestBytes);
|
||||||
|
|
||||||
if (this.digest.equals(jarDigest)) {
|
if (this.digest.equals(jarDigest)) {
|
||||||
getLogger(Jars.class).debug("++++ HASH CHECK ++++");
|
getLogger(ThirdPartyManager.class).debug("++++ HASH CHECK ++++");
|
||||||
getLogger(Jars.class).debug(this.url);
|
getLogger(ThirdPartyManager.class).debug(this.url);
|
||||||
getLogger(Jars.class).debug(this.digest);
|
getLogger(ThirdPartyManager.class).debug(this.digest);
|
||||||
return jarBytes;
|
return jarBytes;
|
||||||
} else {
|
} else {
|
||||||
getLogger(Jars.class).debug(jarDigest + " | " + url);
|
getLogger(ThirdPartyManager.class).debug(jarDigest + " | " + url);
|
||||||
throw new IllegalStateException("The downloaded jar does not match the hash");
|
throw new IllegalStateException("The downloaded jar does not match the hash");
|
||||||
}
|
}
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren