From 992e145a168b50ccaccd95b57a8dc81d8a4dd0bb Mon Sep 17 00:00:00 2001 From: Emily Date: Wed, 19 Apr 2023 12:46:09 -0300 Subject: [PATCH] Undo making JavaPlugin#logger field public (#9125) --- LICENSE.md | 1 + ...or-plugins-modifying-the-parent-of-t.patch | 31 ++++++++++--------- patches/server/Paper-Plugins.patch | 3 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 7fbc5930bb..c3d1668aca 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -57,4 +57,5 @@ Denery Jakubk15 Redned Luke Chambers +Emily ``` diff --git a/patches/api/Add-workaround-for-plugins-modifying-the-parent-of-t.patch b/patches/api/Add-workaround-for-plugins-modifying-the-parent-of-t.patch index d5b98339aa..0e31b4a10c 100644 --- a/patches/api/Add-workaround-for-plugins-modifying-the-parent-of-t.patch +++ b/patches/api/Add-workaround-for-plugins-modifying-the-parent-of-t.patch @@ -71,24 +71,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- 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 { - private boolean naggable = true; - private FileConfiguration newConfig = null; - private File configFile = null; -- private Logger logger = null; // Paper - PluginLogger -> Logger -+ public Logger logger = null; // Paper - PluginLogger -> Logger, public - - public JavaPlugin() { - // Paper start + .orElseThrow(); + } + public final void init(@NotNull PluginLoader loader, @NotNull Server server, @NotNull PluginDescriptionFile description, @NotNull File dataFolder, @NotNull File file, @NotNull ClassLoader classLoader) { +- init(server, description, dataFolder, file, classLoader, description); ++ init(server, description, dataFolder, file, classLoader, description, com.destroystokyo.paper.utils.PaperPluginLogger.getLogger(description)); + this.pluginMeta = description; + } +- public final void init(@NotNull Server server, @NotNull PluginDescriptionFile description, @NotNull File dataFolder, @NotNull File file, @NotNull ClassLoader classLoader, @Nullable io.papermc.paper.plugin.configuration.PluginMeta configuration) { ++ public final void init(@NotNull Server server, @NotNull PluginDescriptionFile description, @NotNull File dataFolder, @NotNull File file, @NotNull ClassLoader classLoader, @Nullable io.papermc.paper.plugin.configuration.PluginMeta configuration, @NotNull Logger logger) { + // Paper end + this.loader = DummyPluginLoaderImplHolder.INSTANCE; // Paper + this.server = server; @@ -0,0 +0,0 @@ public abstract class JavaPlugin extends PluginBase { this.classLoader = classLoader; this.configFile = new File(dataFolder, "config.yml"); this.pluginMeta = configuration; // Paper - this.logger = Logger.getLogger(description.getPrefix() != null ? description.getPrefix() : description.getName()); // Paper - Handle plugin prefix in implementation -+ // Paper start -+ if (this.logger == null) { -+ this.logger = com.destroystokyo.paper.utils.PaperPluginLogger.getLogger(this.description); -+ } -+ // Paper end ++ this.logger = logger; // Paper } /** @@ -109,7 +109,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 pluginState = new IllegalStateException("Initial initialization"); this.pluginInit = javaPlugin; -+ javaPlugin.logger = this.logger; // Paper - set logger - javaPlugin.init(null, org.bukkit.Bukkit.getServer(), description, dataFolder, file, this); // Paper +- javaPlugin.init(null, org.bukkit.Bukkit.getServer(), description, dataFolder, file, this); // Paper ++ javaPlugin.init(org.bukkit.Bukkit.getServer(), description, dataFolder, file, this, description, this.logger); // Paper } + // Paper start diff --git a/patches/server/Paper-Plugins.patch b/patches/server/Paper-Plugins.patch index dbca093827..dd0d6902df 100644 --- a/patches/server/Paper-Plugins.patch +++ b/patches/server/Paper-Plugins.patch @@ -990,8 +990,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + File dataFolder = new File(Bukkit.getPluginsFolder(), pluginDescriptionFile.getName()); + -+ plugin.init(Bukkit.getServer(), pluginDescriptionFile, dataFolder, this.source.toFile(), this, config); -+ plugin.logger = this.logger; ++ plugin.init(Bukkit.getServer(), pluginDescriptionFile, dataFolder, this.source.toFile(), this, config, this.logger); + + this.loadedJavaPlugin = plugin; + }