From 0ce11aca74a43ed6d539b5bab66de0c3e034a2c3 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 20 Feb 2023 15:20:49 +0100 Subject: [PATCH] Update circular dependencies warning, properly crash Also fixes logging errors --- patches/server/Paper-Plugins.patch | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/patches/server/Paper-Plugins.patch b/patches/server/Paper-Plugins.patch index bdfc1f2ca0..2e8d9e85bb 100644 --- a/patches/server/Paper-Plugins.patch +++ b/patches/server/Paper-Plugins.patch @@ -5654,6 +5654,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; ++import java.util.stream.Collectors; + +public abstract class ConfiguredProviderStorage extends SimpleProviderStorage { + @@ -5670,20 +5671,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + protected void handleCycle(PluginGraphCycleException exception) { + List logMessages = new ArrayList<>(); + for (List list : exception.getCycles()) { -+ // CoolPlugin depends on Dependency depends on CoolPlugin... -+ logMessages.add(String.join(" depends on ", list) + " depends on " + list.get(0) + "..."); ++ logMessages.add(String.join(" -> ", list) + " -> " + list.get(0)); + } + -+ LOGGER.log(Level.SEVERE, "Circular dependencies detected!"); -+ 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, "Circular dependencies detected! This happens when"); ++ 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:"); -+ for (String message : logMessages) { -+ LOGGER.log(Level.SEVERE, message); ++ for (String logMessage : logMessages) { ++ 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"); + + 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(", "))); + } + } +