mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 12:42:05 -07:00
Small paper plugin fixes (#8866)
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
This commit is contained in:
@@ -11,11 +11,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
||||
// In case the bad access occurs on construction
|
||||
loader.server.getLogger().log(Level.WARNING, "[{0}] Loaded class {1} from {2} which is not a depend or softdepend of this plugin.", new Object[]{description.getName(), name, provider.getFullName()});
|
||||
org.bukkit.Bukkit.getLogger().log(Level.WARNING, "[{0}] Loaded class {1} from {2} which is not a depend or softdepend of this plugin.", new Object[]{description.getName(), name, provider.getFullName()}); // Paper
|
||||
}
|
||||
+ // Paper start
|
||||
+ if (Boolean.getBoolean("Paper.printStacktraceOnBadPluginClassAccess")) {
|
||||
+ (plugin != null ? plugin.getLogger() : loader.server.getLogger()).log(Level.WARNING, "Stacktrace", new Exception());
|
||||
+ (plugin != null ? plugin.getLogger() : org.bukkit.Bukkit.getLogger()).log(Level.WARNING, "Stacktrace", new Exception());
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
@@ -1218,72 +1218,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ boolean hasDependency(@NotNull String pluginIdentifier);
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/provider/util/DummyBukkitPluginLoader.java b/src/main/java/io/papermc/paper/plugin/provider/util/DummyBukkitPluginLoader.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/provider/util/DummyBukkitPluginLoader.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.plugin.provider.util;
|
||||
+
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.Listener;
|
||||
+import org.bukkit.plugin.InvalidDescriptionException;
|
||||
+import org.bukkit.plugin.InvalidPluginException;
|
||||
+import org.bukkit.plugin.Plugin;
|
||||
+import org.bukkit.plugin.PluginDescriptionFile;
|
||||
+import org.bukkit.plugin.PluginLoader;
|
||||
+import org.bukkit.plugin.RegisteredListener;
|
||||
+import org.bukkit.plugin.UnknownDependencyException;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.util.Map;
|
||||
+import java.util.Set;
|
||||
+import java.util.regex.Pattern;
|
||||
+
|
||||
+/**
|
||||
+ * A purely internal type that implements the now deprecated {@link PluginLoader} after the implementation
|
||||
+ * of papers new plugin system.
|
||||
+ *
|
||||
+ * @param plugin the loaded plugin that should be wrapped by this NOOP implementation
|
||||
+ */
|
||||
+@ApiStatus.Internal
|
||||
+public record DummyBukkitPluginLoader(Plugin plugin) implements PluginLoader {
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Plugin loadPlugin(@NotNull File file) throws InvalidPluginException, UnknownDependencyException {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull PluginDescriptionFile getPluginDescription(@NotNull File file) throws InvalidDescriptionException {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Pattern[] getPluginFileFilters() {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Map<Class<? extends Event>, Set<RegisteredListener>> createRegisteredListeners(@NotNull Listener listener, @NotNull Plugin plugin) {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void enablePlugin(@NotNull Plugin plugin) {
|
||||
+ Bukkit.getPluginManager().enablePlugin(plugin);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void disablePlugin(@NotNull Plugin plugin) {
|
||||
+ Bukkit.getPluginManager().disablePlugin(plugin);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/provider/util/ProviderUtil.java b/src/main/java/io/papermc/paper/plugin/provider/util/ProviderUtil.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
@@ -1985,13 +1919,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- final void init(@NotNull PluginLoader loader, @NotNull Server server, @NotNull PluginDescriptionFile description, @NotNull File dataFolder, @NotNull File file, @NotNull ClassLoader classLoader) {
|
||||
- this.loader = loader;
|
||||
+ // Paper start
|
||||
+ private static class DummyPluginLoaderImplHolder {
|
||||
+ private static final PluginLoader INSTANCE = net.kyori.adventure.util.Services.service(PluginLoader.class)
|
||||
+ .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);
|
||||
+ 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) {
|
||||
+ // Paper end
|
||||
+ this.loader = new io.papermc.paper.plugin.provider.util.DummyBukkitPluginLoader(this);
|
||||
+ this.loader = DummyPluginLoaderImplHolder.INSTANCE; // Paper
|
||||
this.server = server;
|
||||
this.file = file;
|
||||
this.description = description;
|
||||
@@ -2143,6 +2081,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
seenIllegalAccess.add(provider.getName());
|
||||
if (plugin != null) {
|
||||
plugin.getLogger().log(Level.WARNING, "Loaded class {0} from {1} which is not a depend or softdepend of this plugin.", new Object[]{name, provider.getFullName()});
|
||||
} else {
|
||||
// In case the bad access occurs on construction
|
||||
- loader.server.getLogger().log(Level.WARNING, "[{0}] Loaded class {1} from {2} which is not a depend or softdepend of this plugin.", new Object[]{description.getName(), name, provider.getFullName()});
|
||||
+ org.bukkit.Bukkit.getLogger().log(Level.WARNING, "[{0}] Loaded class {1} from {2} which is not a depend or softdepend of this plugin.", new Object[]{description.getName(), name, provider.getFullName()}); // Paper
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +0,0 @@ final class PluginClassLoader extends URLClassLoader {
|
||||
throw new ClassNotFoundException(name, ex);
|
||||
}
|
||||
|
Reference in New Issue
Block a user