geforkt von Mirrors/Paper
Allow logger instances to be used across reloads
Dieser Commit ist enthalten in:
Ursprung
0ed67b50a3
Commit
72bd990d87
@ -14,7 +14,7 @@ parent of the plugin logger to avoid this.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java b/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java
|
||||
new file mode 100644
|
||||
index 00000000..6fcc4f2c
|
||||
index 00000000..d052b2f5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java
|
||||
@@ -0,0 +0,0 @@
|
||||
@ -31,11 +31,19 @@ index 00000000..6fcc4f2c
|
||||
+ */
|
||||
+public class PaperPluginLogger extends Logger {
|
||||
+
|
||||
+ public PaperPluginLogger(PluginDescriptionFile description) {
|
||||
+ super(description.getPrefix() != null ? description.getPrefix() : description.getName(), null);
|
||||
+ if (!LogManager.getLogManager().addLogger(this)) {
|
||||
+ this.log(Level.WARNING, "Could not insert plugin logger - one was already found: {}", LogManager.getLogManager().getLogger(this.getName()));
|
||||
+ public static Logger getLogger(PluginDescriptionFile description) {
|
||||
+ Logger logger = new PaperPluginLogger(description);
|
||||
+ if (!LogManager.getLogManager().addLogger(logger)) {
|
||||
+ // Disable this if it's going to happen across reloads anyways...
|
||||
+ //logger.log(Level.WARNING, "Could not insert plugin logger - one was already found: {}", LogManager.getLogManager().getLogger(this.getName()));
|
||||
+ logger = LogManager.getLogManager().getLogger(description.getPrefix() != null ? description.getPrefix() : description.getName());
|
||||
+ }
|
||||
+
|
||||
+ return logger;
|
||||
+ }
|
||||
+
|
||||
+ private PaperPluginLogger(PluginDescriptionFile description) {
|
||||
+ super(description.getPrefix() != null ? description.getPrefix() : description.getName(), null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@ -50,7 +58,7 @@ index 00000000..6fcc4f2c
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
|
||||
index 0abad9ad..14dda205 100644
|
||||
index 0abad9ad..93fa3493 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
|
||||
@@ -0,0 +0,0 @@ public abstract class JavaPlugin extends PluginBase {
|
||||
@ -70,14 +78,14 @@ index 0abad9ad..14dda205 100644
|
||||
- this.logger = Logger.getLogger(description.getPrefix() != null ? description.getPrefix() : description.getName());
|
||||
+ // Paper start
|
||||
+ if (this.logger == null) {
|
||||
+ this.logger = new com.destroystokyo.paper.utils.PaperPluginLogger(this.description);
|
||||
+ this.logger = com.destroystokyo.paper.utils.PaperPluginLogger.getLogger(this.description);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
index ca9c7796..a7d87d2d 100644
|
||||
index ca9c7796..bd936d9f 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
|
||||
@ -92,7 +100,7 @@ index ca9c7796..a7d87d2d 100644
|
||||
this.manifest = jar.getManifest();
|
||||
this.url = file.toURI().toURL();
|
||||
|
||||
+ this.logger = new com.destroystokyo.paper.utils.PaperPluginLogger(description); // Paper - Register logger early
|
||||
+ this.logger = com.destroystokyo.paper.utils.PaperPluginLogger.getLogger(description); // Paper - Register logger early
|
||||
+
|
||||
try {
|
||||
Class<?> jarClass;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren