mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
23
patches/api/0047-Spark-Profiler.patch
Normal file
23
patches/api/0047-Spark-Profiler.patch
Normal file
@@ -0,0 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: granny <granny@pl3x.net>
|
||||
Date: Thu, 30 Jun 2022 02:32:52 -0700
|
||||
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
|
||||
--- 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 {
|
||||
server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + file.getParentFile().getPath() + "'", ex); // Paper
|
||||
continue;
|
||||
}
|
||||
+ // Purpur start
|
||||
+ if (plugins.containsKey(description.getName()) && description.getName().equalsIgnoreCase("spark")) {
|
||||
+ server.getLogger().log(Level.INFO, "Purpur: Using user-provided spark plugin instead of our own.");
|
||||
+ continue;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
|
||||
File replacedFile = plugins.put(description.getName(), file);
|
||||
if (replacedFile != null) {
|
||||
@@ -5,32 +5,16 @@ 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..a376045e94d1811645f84b3e4963726fe12545a4 100644
|
||||
index 7960433f8278e3bd0ec43db3d3820ff2740a7c13..b2dd88730e775dbe694cbb2c17d45ceabfbbf033 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -410,6 +410,7 @@ public final class CraftServer implements Server {
|
||||
this.pluginManager.registerInterface(JavaPluginLoader.class);
|
||||
|
||||
File pluginFolder = this.getPluginsFolder(); // Paper
|
||||
+ boolean sparkLoaded = false; // Purpur
|
||||
|
||||
// Paper start
|
||||
if (true || pluginFolder.exists()) {
|
||||
@@ -423,6 +424,7 @@ public final class CraftServer implements Server {
|
||||
String message = String.format("Loading %s", plugin.getDescription().getFullName());
|
||||
plugin.getLogger().info(message);
|
||||
plugin.onLoad();
|
||||
+ sparkLoaded = sparkLoaded || plugin.getDescription().getName().equalsIgnoreCase("spark"); // Purpur
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, ex.getMessage() + " initializing " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
||||
}
|
||||
@@ -430,6 +432,40 @@ public final class CraftServer implements Server {
|
||||
} else {
|
||||
pluginFolder.mkdir();
|
||||
}
|
||||
+
|
||||
+ // Purpur start
|
||||
+ if (!sparkLoaded) {
|
||||
@@ -416,7 +416,36 @@ 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();
|
||||
@@ -52,16 +36,13 @@ index 7960433f8278e3bd0ec43db3d3820ff2740a7c13..a376045e94d1811645f84b3e4963726f
|
||||
+ java.nio.file.Files.copy(new java.net.URL("https://sparkapi.lucko.me/download/bukkit").openStream(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
+ }
|
||||
+
|
||||
+ Plugin spark = this.pluginManager.loadPlugin(file);
|
||||
+ String message = String.format("Loading %s", spark.getDescription().getFullName());
|
||||
+ spark.getLogger().info(message);
|
||||
+ spark.onLoad();
|
||||
+ extraJars.add(file);
|
||||
+ } catch (Exception e) {
|
||||
+ getLogger().severe("Failed to download and load spark plugin");
|
||||
+ getLogger().severe("Purpur: Failed to download and install spark plugin");
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end
|
||||
}
|
||||
|
||||
// Paper start
|
||||
+ Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder, extraJars);
|
||||
+ // Purpur end
|
||||
// Paper end
|
||||
for (Plugin plugin : plugins) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user