mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Add system property to prevent downloading and loading Spark
This commit is contained in:
@@ -5,7 +5,7 @@ Subject: [PATCH] Spark Profiler
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
index aed2209b66f11a0d03473cf19437f3da0e9e573a..353bed51cf7a5be0e7a75c72290976348631381e 100644
|
||||
index aed2209b66f11a0d03473cf19437f3da0e9e573a..e46c3cb737d644d167b4426b29bb4ade0c24e74e 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
@@ -164,6 +164,12 @@ public final class SimplePluginManager implements PluginManager {
|
||||
@@ -13,7 +13,7 @@ index aed2209b66f11a0d03473cf19437f3da0e9e573a..353bed51cf7a5be0e7a75c7229097634
|
||||
continue;
|
||||
}
|
||||
+ // Purpur start
|
||||
+ if (plugins.containsKey(description.getName()) && description.getName().equalsIgnoreCase("spark")) {
|
||||
+ if (!Boolean.getBoolean("Purpur.IReallyDontWantSpark") && plugins.containsKey(description.getName()) && description.getName().equalsIgnoreCase("spark")) {
|
||||
+ server.getLogger().log(Level.INFO, "Purpur: Using user-provided spark plugin instead of our own.");
|
||||
+ continue;
|
||||
+ }
|
||||
|
||||
@@ -5,41 +5,43 @@ Subject: [PATCH] Spark Profiler
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 7960433f8278e3bd0ec43db3d3820ff2740a7c13..b2dd88730e775dbe694cbb2c17d45ceabfbbf033 100644
|
||||
index 0b45cfd7158af615df3f9477a8891e495c69a4fb..9b5e29d0d43f9c6ab2b06d3d49334b8429a55a41 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -416,7 +416,36 @@ public final class CraftServer implements Server {
|
||||
@@ -416,7 +416,38 @@ public final class CraftServer implements Server {
|
||||
if (!pluginFolder.exists()) {
|
||||
pluginFolder.mkdirs();
|
||||
}
|
||||
- Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder, this.extraPluginJars());
|
||||
+ // Purpur start
|
||||
+ List<File> extraJars = this.extraPluginJars();
|
||||
+ try {
|
||||
+ File file = new File("cache", "spark.jar");
|
||||
+ file.getParentFile().mkdirs();
|
||||
+ if (!Boolean.getBoolean("Purpur.IReallyDontWantSpark")) {
|
||||
+ try {
|
||||
+ File file = new File("cache", "spark.jar");
|
||||
+ file.getParentFile().mkdirs();
|
||||
+
|
||||
+ boolean shouldDownload = true;
|
||||
+ if (file.exists()) {
|
||||
+ String fileSha1 = String.format("%040x", new java.math.BigInteger(1, java.security.MessageDigest.getInstance("SHA-1").digest(java.nio.file.Files.readAllBytes(file.toPath()))));
|
||||
+ String sparkSha1;
|
||||
+ try (java.io.BufferedReader reader = new java.io.BufferedReader(new InputStreamReader(new java.net.URL("https://sparkapi.lucko.me/download/bukkit/sha1").openStream()))) {
|
||||
+ sparkSha1 = reader.lines().collect(Collectors.joining(""));
|
||||
+ boolean shouldDownload = true;
|
||||
+ if (file.exists()) {
|
||||
+ String fileSha1 = String.format("%040x", new java.math.BigInteger(1, java.security.MessageDigest.getInstance("SHA-1").digest(java.nio.file.Files.readAllBytes(file.toPath()))));
|
||||
+ String sparkSha1;
|
||||
+ try (java.io.BufferedReader reader = new java.io.BufferedReader(new InputStreamReader(new java.net.URL("https://sparkapi.lucko.me/download/bukkit/sha1").openStream()))) {
|
||||
+ sparkSha1 = reader.lines().collect(Collectors.joining(""));
|
||||
+ }
|
||||
+
|
||||
+ if (fileSha1.equals(sparkSha1)) {
|
||||
+ shouldDownload = false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (fileSha1.equals(sparkSha1)) {
|
||||
+ shouldDownload = false;
|
||||
+ if (shouldDownload) {
|
||||
+ java.nio.file.Files.copy(new java.net.URL("https://sparkapi.lucko.me/download/bukkit").openStream(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (shouldDownload) {
|
||||
+ java.nio.file.Files.copy(new java.net.URL("https://sparkapi.lucko.me/download/bukkit").openStream(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
+ extraJars.add(file);
|
||||
+ } catch (Exception e) {
|
||||
+ getLogger().severe("Purpur: Failed to download and install spark plugin");
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+
|
||||
+ extraJars.add(file);
|
||||
+ } catch (Exception e) {
|
||||
+ getLogger().severe("Purpur: Failed to download and install spark plugin");
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder, extraJars);
|
||||
+ // Purpur end
|
||||
|
||||
Reference in New Issue
Block a user