Update circular dependencies warning, properly crash

Also fixes logging errors
This commit is contained in:
Nassim Jahnke 2023-02-20 15:20:49 +01:00
parent 7baf427e90
commit 8c4e81184b
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B

View File

@ -5639,10 +5639,10 @@ index 0000000000000000000000000000000000000000..7af995b941ce83265a93cdc6b5a2de8a
+} +}
diff --git a/src/main/java/io/papermc/paper/plugin/storage/ConfiguredProviderStorage.java b/src/main/java/io/papermc/paper/plugin/storage/ConfiguredProviderStorage.java diff --git a/src/main/java/io/papermc/paper/plugin/storage/ConfiguredProviderStorage.java b/src/main/java/io/papermc/paper/plugin/storage/ConfiguredProviderStorage.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..93575a996933b4923e3bdc7dd88ffeb736c42e69 index 0000000000000000000000000000000000000000..eb4a7e1fbd9f0e853ebf965c6b4f9e0e6061ad74
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/storage/ConfiguredProviderStorage.java +++ b/src/main/java/io/papermc/paper/plugin/storage/ConfiguredProviderStorage.java
@@ -0,0 +1,49 @@ @@ -0,0 +1,51 @@
+package io.papermc.paper.plugin.storage; +package io.papermc.paper.plugin.storage;
+ +
+import io.papermc.paper.plugin.entrypoint.strategy.LegacyPluginLoadingStrategy; +import io.papermc.paper.plugin.entrypoint.strategy.LegacyPluginLoadingStrategy;
@ -5654,6 +5654,7 @@ index 0000000000000000000000000000000000000000..93575a996933b4923e3bdc7dd88ffeb7
+import java.util.List; +import java.util.List;
+import java.util.logging.Level; +import java.util.logging.Level;
+import java.util.logging.Logger; +import java.util.logging.Logger;
+import java.util.stream.Collectors;
+ +
+public abstract class ConfiguredProviderStorage<T> extends SimpleProviderStorage<T> { +public abstract class ConfiguredProviderStorage<T> extends SimpleProviderStorage<T> {
+ +
@ -5670,20 +5671,21 @@ index 0000000000000000000000000000000000000000..93575a996933b4923e3bdc7dd88ffeb7
+ protected void handleCycle(PluginGraphCycleException exception) { + protected void handleCycle(PluginGraphCycleException exception) {
+ List<String> logMessages = new ArrayList<>(); + List<String> logMessages = new ArrayList<>();
+ for (List<String> list : exception.getCycles()) { + for (List<String> list : exception.getCycles()) {
+ // CoolPlugin depends on Dependency depends on CoolPlugin... + logMessages.add(String.join(" -> ", list) + " -> " + list.get(0));
+ logMessages.add(String.join(" depends on ", list) + " depends on " + list.get(0) + "...");
+ } + }
+ +
+ LOGGER.log(Level.SEVERE, "Circular dependencies detected!"); + LOGGER.log(Level.SEVERE, "Circular dependencies detected! This happens when");
+ LOGGER.log(Level.SEVERE, "You have a plugin that is depending on a plugin which refers back to that plugin. Your server will shut down until these are resolved, or the strategy is changed."); + LOGGER.log(Level.SEVERE, " i) plugin A has a plugin B in its (soft)depend list, and plugin B has plugin A in its (soft)depend list, or");
+ LOGGER.log(Level.SEVERE, " ii) plugin A has plugin B both in its (soft)depend list and its loadbefore list.");
+ LOGGER.log(Level.SEVERE, "Circular dependencies:"); + LOGGER.log(Level.SEVERE, "Circular dependencies:");
+ for (String message : logMessages) { + for (String logMessage : logMessages) {
+ LOGGER.log(Level.SEVERE, message); + LOGGER.log(Level.SEVERE, " " + logMessage);
+ } + }
+ LOGGER.log(Level.SEVERE, "Please report this to the plugin authors of the first plugin of each loop or join the PaperMC Discord server for further help.");
+ LOGGER.log(Level.SEVERE, "If you would like to still load these plugins, acknowledging that there may be unexpected plugin loading issues, run the server with -Dpaper.useLegacyPluginLoading=true"); + LOGGER.log(Level.SEVERE, "If you would like to still load these plugins, acknowledging that there may be unexpected plugin loading issues, run the server with -Dpaper.useLegacyPluginLoading=true");
+ +
+ if (this.exitOnCycleDependencies()) { + if (this.exitOnCycleDependencies()) {
+ System.exit(-1); + throw new IllegalStateException("Circular plugin dependencies from plugins " + exception.getCycles().stream().map(cycle -> cycle.get(0)).collect(Collectors.joining(", ")));
+ } + }
+ } + }
+ +