Finish converting all events to jspecify annotations
This commit is contained in:
@@ -21,26 +21,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+package com.destroystokyo.paper.utils;
|
||||
+
|
||||
+import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||
+import org.bukkit.plugin.PluginDescriptionFile;
|
||||
+
|
||||
+import java.util.logging.Level;
|
||||
+import java.util.logging.LogManager;
|
||||
+import java.util.logging.Logger;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.bukkit.plugin.PluginDescriptionFile;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Prevents plugins (e.g. Essentials) from changing the parent of the plugin logger.
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class PaperPluginLogger extends Logger {
|
||||
+
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ @NotNull
|
||||
+ public static Logger getLogger(@NotNull PluginDescriptionFile description) {
|
||||
+ public static Logger getLogger(final PluginDescriptionFile description) {
|
||||
+ return getLogger((PluginMeta) description);
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static Logger getLogger(@NotNull PluginMeta meta) {
|
||||
+ public static Logger getLogger(final PluginMeta meta) {
|
||||
+ Logger logger = new PaperPluginLogger(meta);
|
||||
+ if (!LogManager.getLogManager().addLogger(logger)) {
|
||||
+ // Disable this if it's going to happen across reloads anyways...
|
||||
@@ -51,14 +49,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return logger;
|
||||
+ }
|
||||
+
|
||||
+ private PaperPluginLogger(@NotNull PluginMeta meta) {
|
||||
+ private PaperPluginLogger(final PluginMeta meta) {
|
||||
+ super(meta.getLoggerPrefix() != null ? meta.getLoggerPrefix() : meta.getName(), null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setParent(@NotNull Logger parent) {
|
||||
+ if (getParent() != null) {
|
||||
+ warning("Ignoring attempt to change parent of plugin logger");
|
||||
+ public void setParent(final Logger parent) {
|
||||
+ if (this.getParent() != null) {
|
||||
+ this.warning("Ignoring attempt to change parent of plugin logger");
|
||||
+ } else {
|
||||
+ this.log(Level.FINE, "Setting plugin logger parent to {0}", parent);
|
||||
+ super.setParent(parent);
|
||||
|
||||
Reference in New Issue
Block a user