Archiviert
13
0

Merge remote-tracking branch 'upstream/master' into upstream

Dieser Commit ist enthalten in:
Lixfel 2023-02-23 17:03:26 +01:00
Commit 8569456349
10 geänderte Dateien mit 151 neuen und 87 gelöschten Zeilen

Datei anzeigen

@ -54,4 +54,5 @@ vytskalt <vytskalt@protonmail.com>
TheFruxz <cedricspitzer@outlook.de>
Kieran Wallbanks <kieran.wallbanks@gmail.com>
Denery <dorofeevij@gmail.com>
Jakubk15 <jakubk15@protonmail.com>
```

Datei anzeigen

@ -913,10 +913,10 @@ index 0000000000000000000000000000000000000000..64e46fdfa4d404cb08c67a456e5990b7
+}
diff --git a/src/main/java/io/papermc/paper/plugin/provider/classloader/ConfiguredPluginClassLoader.java b/src/main/java/io/papermc/paper/plugin/provider/classloader/ConfiguredPluginClassLoader.java
new file mode 100644
index 0000000000000000000000000000000000000000..a15e7474eb8eb1196f69070b7cf7fd5af6100f68
index 0000000000000000000000000000000000000000..ab1fb50912e411e708ba1e40303b1c08dabb086d
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/provider/classloader/ConfiguredPluginClassLoader.java
@@ -0,0 +1,55 @@
@@ -0,0 +1,63 @@
+package io.papermc.paper.plugin.provider.classloader;
+
+import io.papermc.paper.plugin.configuration.PluginMeta;
@ -925,6 +925,7 @@ index 0000000000000000000000000000000000000000..a15e7474eb8eb1196f69070b7cf7fd5a
+import org.jetbrains.annotations.NotNull;
+
+import java.io.Closeable;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * The configured plugin class loader represents an <b>internal</b> abstraction over the classloaders used by the server
@ -971,6 +972,13 @@ index 0000000000000000000000000000000000000000..a15e7474eb8eb1196f69070b7cf7fd5a
+ * @param plugin the {@link JavaPlugin} that should be interlinked with this class loader.
+ */
+ void init(JavaPlugin plugin);
+
+ /**
+ * Gets the plugin held by this class loader.
+ *
+ * @return the plugin or null if it doesn't exist yet
+ */
+ @Nullable JavaPlugin getPlugin();
+}
diff --git a/src/main/java/io/papermc/paper/plugin/provider/classloader/PaperClassLoaderStorage.java b/src/main/java/io/papermc/paper/plugin/provider/classloader/PaperClassLoaderStorage.java
new file mode 100644
@ -1835,7 +1843,7 @@ index a80251eff75430863b37db1c131e22593f3fcd5e..310c4041963a3f1e0a26e39a6da12a9b
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
index 669a70faa95d0d6525a731d73499ed6fb0b48320..6175b04327b12e74140a0885f7326546dfaf269a 100644
index 669a70faa95d0d6525a731d73499ed6fb0b48320..c9cf9d361a1289aba383718733a2098b5eafb38f 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
@@ -38,6 +38,7 @@ public abstract class JavaPlugin extends PluginBase {
@ -1941,6 +1949,34 @@ index 669a70faa95d0d6525a731d73499ed6fb0b48320..6175b04327b12e74140a0885f7326546
}
/**
@@ -394,10 +419,10 @@ public abstract class JavaPlugin extends PluginBase {
throw new IllegalArgumentException(clazz + " does not extend " + JavaPlugin.class);
}
final ClassLoader cl = clazz.getClassLoader();
- if (!(cl instanceof PluginClassLoader)) {
- throw new IllegalArgumentException(clazz + " is not initialized by " + PluginClassLoader.class);
+ if (!(cl instanceof io.papermc.paper.plugin.provider.classloader.ConfiguredPluginClassLoader configuredPluginClassLoader)) { // Paper
+ throw new IllegalArgumentException(clazz + " is not initialized by a " + io.papermc.paper.plugin.provider.classloader.ConfiguredPluginClassLoader.class); // Paper
}
- JavaPlugin plugin = ((PluginClassLoader) cl).plugin;
+ JavaPlugin plugin = configuredPluginClassLoader.getPlugin(); // Paper
if (plugin == null) {
throw new IllegalStateException("Cannot get plugin for " + clazz + " from a static initializer");
}
@@ -420,10 +445,10 @@ public abstract class JavaPlugin extends PluginBase {
public static JavaPlugin getProvidingPlugin(@NotNull Class<?> clazz) {
Preconditions.checkArgument(clazz != null, "Null class cannot have a plugin");
final ClassLoader cl = clazz.getClassLoader();
- if (!(cl instanceof PluginClassLoader)) {
- throw new IllegalArgumentException(clazz + " is not provided by " + PluginClassLoader.class);
+ if (!(cl instanceof io.papermc.paper.plugin.provider.classloader.ConfiguredPluginClassLoader configuredPluginClassLoader)) { // Paper
+ throw new IllegalArgumentException(clazz + " is not provided by a " + io.papermc.paper.plugin.provider.classloader.ConfiguredPluginClassLoader.class); // Paper
}
- JavaPlugin plugin = ((PluginClassLoader) cl).plugin;
+ JavaPlugin plugin = configuredPluginClassLoader.getPlugin(); // Paper
if (plugin == null) {
throw new IllegalStateException("Cannot get plugin for " + clazz + " from a static initializer");
}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
index 047c0304fd617cec990f80815b43916c6ef5a94c..fa39c93d76ebb9eecce1f4b5203cb361e4778b4f 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@ -1987,7 +2023,7 @@ index 6d634b0ea813ccb19f1562a7d0e5a59cea4eab21..f9e67e20133d349e43d126dbb48b34d4
private final Logger logger;
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index 2f74ec96ece706de23156ebabfe493211bc05391..f92071617712a0f410475fae291fb85f668e8e8a 100644
index 2f74ec96ece706de23156ebabfe493211bc05391..dd569f2fc6098650d202e834b343b1bff2d42284 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -29,7 +29,8 @@ import org.jetbrains.annotations.Nullable;
@ -2000,12 +2036,7 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..f92071617712a0f410475fae291fb85f
private final JavaPluginLoader loader;
private final Map<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
private final PluginDescriptionFile description;
@@ -39,20 +40,22 @@ final class PluginClassLoader extends URLClassLoader {
private final Manifest manifest;
private final URL url;
private final ClassLoader libraryLoader;
- final JavaPlugin plugin;
+ public final JavaPlugin plugin; // Paper
@@ -43,16 +44,18 @@ final class PluginClassLoader extends URLClassLoader {
private JavaPlugin pluginInit;
private IllegalStateException pluginState;
private final Set<String> seenIllegalAccess = Collections.newSetFromMap(new ConcurrentHashMap<>());
@ -2038,7 +2069,7 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..f92071617712a0f410475fae291fb85f
try {
Class<?> jarClass;
try {
@@ -94,6 +101,22 @@ final class PluginClassLoader extends URLClassLoader {
@@ -94,6 +101,27 @@ final class PluginClassLoader extends URLClassLoader {
return findResources(name);
}
@ -2056,12 +2087,17 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..f92071617712a0f410475fae291fb85f
+ public void init(JavaPlugin plugin) {
+ this.initialize(plugin);
+ }
+
+ @Override
+ public JavaPlugin getPlugin() {
+ return this.plugin;
+ }
+ // Paper end
+
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
return loadClass0(name, resolve, true, true);
@@ -119,26 +142,11 @@ final class PluginClassLoader extends URLClassLoader {
@@ -119,26 +147,11 @@ final class PluginClassLoader extends URLClassLoader {
if (checkGlobal) {
// This ignores the libraries of other plugins, unless they are transitive dependencies.
@ -2090,7 +2126,7 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..f92071617712a0f410475fae291fb85f
return result;
}
@@ -167,7 +175,7 @@ final class PluginClassLoader extends URLClassLoader {
@@ -167,7 +180,7 @@ final class PluginClassLoader extends URLClassLoader {
throw new ClassNotFoundException(name, ex);
}
@ -2099,7 +2135,7 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..f92071617712a0f410475fae291fb85f
int dot = name.lastIndexOf('.');
if (dot != -1) {
@@ -197,8 +205,8 @@ final class PluginClassLoader extends URLClassLoader {
@@ -197,8 +210,8 @@ final class PluginClassLoader extends URLClassLoader {
result = super.findClass(name);
}
@ -2109,7 +2145,7 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..f92071617712a0f410475fae291fb85f
}
return result;
@@ -207,6 +215,12 @@ final class PluginClassLoader extends URLClassLoader {
@@ -207,6 +220,12 @@ final class PluginClassLoader extends URLClassLoader {
@Override
public void close() throws IOException {
try {
@ -2122,7 +2158,7 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..f92071617712a0f410475fae291fb85f
super.close();
} finally {
jar.close();
@@ -218,7 +232,7 @@ final class PluginClassLoader extends URLClassLoader {
@@ -218,7 +237,7 @@ final class PluginClassLoader extends URLClassLoader {
return classes.values();
}
@ -2131,7 +2167,7 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..f92071617712a0f410475fae291fb85f
Preconditions.checkArgument(javaPlugin != null, "Initializing plugin cannot be null");
Preconditions.checkArgument(javaPlugin.getClass().getClassLoader() == this, "Cannot initialize plugin outside of this class loader");
if (this.plugin != null || this.pluginInit != null) {
@@ -228,6 +242,32 @@ final class PluginClassLoader extends URLClassLoader {
@@ -228,6 +247,32 @@ final class PluginClassLoader extends URLClassLoader {
pluginState = new IllegalStateException("Initial initialization");
this.pluginInit = javaPlugin;

Datei anzeigen

@ -3472,7 +3472,7 @@ index f64a90241ce7f73e111e6b5ac6ff87cd93583c0e..f13dcbe448111b24b36105d25527ba87
// Paper start
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
index d0ad072c832b8fc8a1cfdcafdd42c724531a2e29..02062284dbc1a6c923ceffa5e4d6a3be8c7429d3 100644
index fa39c93d76ebb9eecce1f4b5203cb361e4778b4f..aa6ce50ff2d0318bfcc328daa4fd9f2e50d34d01 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@@ -55,7 +55,6 @@ public final class JavaPluginLoader implements PluginLoader {
@ -3514,18 +3514,6 @@ index d0ad072c832b8fc8a1cfdcafdd42c724531a2e29..02062284dbc1a6c923ceffa5e4d6a3be
if (false) { // Spigot - RL handles useTimings check now
eventSet.add(new TimedRegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled()));
} else {
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index e721c58eafee2180d4ba1a73002cf850355a366e..39c9253d03bae99f8b5b19d22295f6172606d57b 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -31,6 +31,7 @@ import org.jetbrains.annotations.Nullable;
*/
@org.jetbrains.annotations.ApiStatus.Internal // Paper
public final class PluginClassLoader extends URLClassLoader implements io.papermc.paper.plugin.provider.classloader.ConfiguredPluginClassLoader { // Paper
+ public JavaPlugin getPlugin() { return plugin; } // Spigot
private final JavaPluginLoader loader;
private final Map<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
private final PluginDescriptionFile description;
diff --git a/src/main/java/org/bukkit/util/CachedServerIcon.java b/src/main/java/org/bukkit/util/CachedServerIcon.java
index 5ca863b3692b2e1b58e7fb4d82f554a92cc4f01e..612958a331575d1da2715531ebdf6b1168f2e860 100644
--- a/src/main/java/org/bukkit/util/CachedServerIcon.java

Datei anzeigen

@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..087ee57fe5485bc760fadd45a176d4d9
+
+}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
index 79df67daf2fe8193fd83dd6a7bfc78b3f6e524c2..0e4cedc005466c600ff6b9d500febf338b12a842 100644
index 71c8d2345eef6895edb8d210553ec3cddd9c76d0..6d31f3a2569ae9c522a5e6cddd38ac8f252f1bfe 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
@@ -44,7 +44,7 @@ public abstract class JavaPlugin extends PluginBase {
@ -93,10 +93,10 @@ index 79df67daf2fe8193fd83dd6a7bfc78b3f6e524c2..0e4cedc005466c600ff6b9d500febf33
/**
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index 845b3f8a7dedf801d45489e807ab971dcfe2382e..666f182e5cf2f07a2cf6a17b0d28a100b3f0b891 100644
index dd569f2fc6098650d202e834b343b1bff2d42284..fade45ef475ae20922f5abea49a0f035d19b7819 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -65,7 +65,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
@@ -64,7 +64,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
this.url = file.toURI().toURL();
this.libraryLoader = libraryLoader;
@ -105,7 +105,7 @@ index 845b3f8a7dedf801d45489e807ab971dcfe2382e..666f182e5cf2f07a2cf6a17b0d28a100
// Paper start
this.classLoaderGroup = io.papermc.paper.plugin.provider.classloader.PaperClassLoaderStorage.instance().registerSpigotGroup(this); // Paper
// Paper end
@@ -243,6 +243,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
@@ -247,6 +247,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
pluginState = new IllegalStateException("Initial initialization");
this.pluginInit = javaPlugin;

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Enable multi-release plugin jars
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index 666f182e5cf2f07a2cf6a17b0d28a100b3f0b891..14cdd833bb56186e7cb83e035348f4dc942e4740 100644
index fade45ef475ae20922f5abea49a0f035d19b7819..264d712d3399d24cb01b85fc2d055d9fbf11b23a 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -60,7 +60,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
@@ -59,7 +59,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
this.description = description;
this.dataFolder = dataFolder;
this.file = file;

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Rewrite LogEvents to contain the source jars in stack traces
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index 14cdd833bb56186e7cb83e035348f4dc942e4740..9b4b81f70624cd3906c94cbab99aabe7f9a4223e 100644
index 264d712d3399d24cb01b85fc2d055d9fbf11b23a..327ff03fa1978881fa6f6ba20e33e3c049c2e3cd 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -54,7 +54,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
@@ -53,7 +53,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
@org.jetbrains.annotations.ApiStatus.Internal // Paper
public PluginClassLoader(@Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader) throws IOException, InvalidPluginException, MalformedURLException { // Paper

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Also load resources from LibraryLoader
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index 9b4b81f70624cd3906c94cbab99aabe7f9a4223e..4666d29d27e6247422a94e99511a190ce9484f76 100644
index 327ff03fa1978881fa6f6ba20e33e3c049c2e3cd..7d300a539ac2ef1c773cfa90cecc8655490a8686 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -94,14 +94,35 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
@@ -93,14 +93,35 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
@Override
public URL getResource(String name) {

Datei anzeigen

@ -2362,7 +2362,7 @@ index be097f13dba5d408f58d6fada893bed2638d4219..3d7d1ba148dbc3591d8c76b99a2ee7d9
@Override
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 25227822aa0e1dd7fbbe98a0925ccd023af8d0dc..8c1937ff71b8b4dad85e20b55dcf2a0cc06ce2df 100644
index 25227822aa0e1dd7fbbe98a0925ccd023af8d0dc..dfd2f3ba256edc64e0016e7816ccefff9e7b1b7a 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -8,6 +8,7 @@ import com.mojang.logging.LogUtils;
@ -2500,7 +2500,7 @@ index 25227822aa0e1dd7fbbe98a0925ccd023af8d0dc..8c1937ff71b8b4dad85e20b55dcf2a0c
boolean flag = this.verifyChatTrusted(message);
- this.server.logChatMessage(message.decoratedContent(), params, flag ? null : "Not Secure");
+ this.server.logChatMessage((unsignedFunction == null ? Component.literal(message.signedContent()) : unsignedFunction.apply(this.server.console)), params, flag ? null : "Not Secure"); // Paper
+ this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), params, flag ? null : "Not Secure"); // Paper
OutgoingChatMessage outgoingchatmessage = OutgoingChatMessage.create(message);
boolean flag1 = false;

Datei anzeigen

@ -37,10 +37,10 @@ index 6a00f3d38da8107825ab1d405f337fd077b09f72..d44d0074446c1c54e87dc8078dff7fef
}
diff --git a/src/main/java/io/papermc/paper/command/PaperPluginsCommand.java b/src/main/java/io/papermc/paper/command/PaperPluginsCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..72096a66a4046633de73a12f5a043ac6dff169b1
index 0000000000000000000000000000000000000000..f0fce4113fb07c64adbec029d177c236cbdcbae8
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/PaperPluginsCommand.java
@@ -0,0 +1,207 @@
@@ -0,0 +1,215 @@
+package io.papermc.paper.command;
+
+import com.google.common.collect.Lists;
@ -229,11 +229,19 @@ index 0000000000000000000000000000000000000000..72096a66a4046633de73a12f5a043ac6
+ //.append(INFO_ICON_START.hoverEvent(SERVER_PLUGIN_INFO)); TODO: Add docs
+
+ sender.sendMessage(infoMessage);
+ sender.sendMessage(PAPER_HEADER);
+
+ if (!paperPlugins.isEmpty()) {
+ sender.sendMessage(PAPER_HEADER);
+ }
+
+ for (Component component : formatProviders(paperPlugins)) {
+ sender.sendMessage(component);
+ }
+ sender.sendMessage(BUKKIT_HEADER);
+
+ if (!spigotPlugins.isEmpty()) {
+ sender.sendMessage(BUKKIT_HEADER);
+ }
+
+ for (Component component : formatProviders(spigotPlugins)) {
+ sender.sendMessage(component);
+ }
@ -443,10 +451,10 @@ index 0000000000000000000000000000000000000000..4ecd00b32c7abc15d655dd3c999b6fec
+}
diff --git a/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java b/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..9926eb59b83abffffb578356f148f045edc027cb
index 0000000000000000000000000000000000000000..21e43223d7942b0e5e3c6b63aa2c455ec17ffde9
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java
@@ -0,0 +1,88 @@
@@ -0,0 +1,90 @@
+package io.papermc.paper.plugin;
+
+import com.mojang.logging.LogUtils;
@ -489,9 +497,11 @@ index 0000000000000000000000000000000000000000..9926eb59b83abffffb578356f148f045
+
+ final Path resolvedUpdateDirectory = pluginDirectory.resolve(updateDirectoryName);
+ if (!Files.isDirectory(resolvedUpdateDirectory)) {
+ LOGGER.error("Misconfigured update directory!");
+ LOGGER.error(("Your configured update directory (%s) in bukkit.yml is pointing to a non-directory path. " +
+ "Disabling auto updating functionality.").formatted(resolvedUpdateDirectory));
+ if (Files.exists(resolvedUpdateDirectory)) {
+ LOGGER.error("Misconfigured update directory!");
+ LOGGER.error("Your configured update directory ({}) in bukkit.yml is pointing to a non-directory path. " +
+ "Auto updating functionality will not work.", resolvedUpdateDirectory);
+ }
+ return new PluginInitializerManager(pluginDirectory, null);
+ }
+
@ -746,10 +756,10 @@ index 0000000000000000000000000000000000000000..f9a2c55a354c877749db3f92956de802
+}
diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java
new file mode 100644
index 0000000000000000000000000000000000000000..f1a2d25079c841daff19f41f2b24fb8e97d2c7d3
index 0000000000000000000000000000000000000000..392eb260b44d5f9e685ce09596c19f0af9cc0339
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java
@@ -0,0 +1,193 @@
@@ -0,0 +1,204 @@
+package io.papermc.paper.plugin.entrypoint.classloader;
+
+import io.papermc.paper.plugin.configuration.PluginMeta;
@ -768,6 +778,7 @@ index 0000000000000000000000000000000000000000..f1a2d25079c841daff19f41f2b24fb8e
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
@ -791,7 +802,7 @@ index 0000000000000000000000000000000000000000..f1a2d25079c841daff19f41f2b24fb8e
+ registerAsParallelCapable();
+ }
+
+ private final ClassLoader libraryLoader;
+ private final URLClassLoader libraryLoader;
+ private final Set<String> seenIllegalAccess = Collections.newSetFromMap(new ConcurrentHashMap<>());
+ private final Logger logger;
+ @Nullable
@ -799,7 +810,7 @@ index 0000000000000000000000000000000000000000..f1a2d25079c841daff19f41f2b24fb8e
+ @Nullable
+ private PluginClassLoaderGroup group;
+
+ public PaperPluginClassLoader(Logger logger, Path source, JarFile file, PaperPluginMeta configuration, ClassLoader parentLoader, ClassLoader libraryLoader) throws IOException {
+ public PaperPluginClassLoader(Logger logger, Path source, JarFile file, PaperPluginMeta configuration, ClassLoader parentLoader, URLClassLoader libraryLoader) throws IOException {
+ super(source, file, configuration, parentLoader);
+ this.libraryLoader = libraryLoader;
+
@ -902,9 +913,9 @@ index 0000000000000000000000000000000000000000..f1a2d25079c841daff19f41f2b24fb8e
+ config.getProvidedPlugins(),
+ config.getMainClass(),
+ "", // Classloader load order api
+ List.of(), // Dependencies
+ List.of(), // Soft Depends
+ List.of(), // Load Before
+ config.getPluginDependencies(), // Dependencies
+ config.getPluginSoftDependencies(), // Soft Depends
+ config.getLoadBeforePlugins(), // Load Before
+ config.getVersion(),
+ Map.of(), // Commands, we use a separate system
+ config.getDescription(),
@ -929,7 +940,8 @@ index 0000000000000000000000000000000000000000..f1a2d25079c841daff19f41f2b24fb8e
+ }
+
+ @Nullable
+ public JavaPlugin getLoadedJavaPlugin() {
+ @Override
+ public JavaPlugin getPlugin() {
+ return this.loadedJavaPlugin;
+ }
+
@ -942,6 +954,15 @@ index 0000000000000000000000000000000000000000..f1a2d25079c841daff19f41f2b24fb8e
+ ", group=" + this.group +
+ '}';
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ super.close();
+ } finally {
+ this.libraryLoader.close();
+ }
+ }
+}
diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperSimplePluginClassLoader.java b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperSimplePluginClassLoader.java
new file mode 100644
@ -1573,10 +1594,10 @@ index 0000000000000000000000000000000000000000..f43295fdeaa587cf30c35a1d54516707
+}
diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/dependency/DependencyUtil.java b/src/main/java/io/papermc/paper/plugin/entrypoint/dependency/DependencyUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..b963fae0285d2d87a6f6a4eddf98996a27dabac2
index 0000000000000000000000000000000000000000..bfa258faf17ca6118aeddfa4e95bbd082bcd1390
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/entrypoint/dependency/DependencyUtil.java
@@ -0,0 +1,70 @@
@@ -0,0 +1,75 @@
+package io.papermc.paper.plugin.entrypoint.dependency;
+
+import com.google.common.graph.MutableGraph;
@ -1589,6 +1610,7 @@ index 0000000000000000000000000000000000000000..b963fae0285d2d87a6f6a4eddf98996a
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Predicate;
+
+@SuppressWarnings("UnstableApiUsage")
+public class DependencyUtil {
@ -1613,14 +1635,18 @@ index 0000000000000000000000000000000000000000..b963fae0285d2d87a6f6a4eddf98996a
+ }
+
+ @NotNull
+ public static MutableGraph<String> buildLoadGraph(@NotNull MutableGraph<String> dependencyGraph, @NotNull LoadOrderConfiguration configuration) {
+ public static MutableGraph<String> buildLoadGraph(@NotNull MutableGraph<String> dependencyGraph, @NotNull LoadOrderConfiguration configuration, Predicate<String> validator) {
+ String identifier = configuration.getMeta().getName();
+ for (String dependency : configuration.getLoadAfter()) {
+ dependencyGraph.putEdge(identifier, dependency);
+ if (validator.test(dependency)) {
+ dependencyGraph.putEdge(identifier, dependency);
+ }
+ }
+
+ for (String loadBeforeTarget : configuration.getLoadBefore()) {
+ dependencyGraph.putEdge(loadBeforeTarget, identifier);
+ if (validator.test(loadBeforeTarget)) {
+ dependencyGraph.putEdge(loadBeforeTarget, identifier);
+ }
+ }
+
+ dependencyGraph.addNode(identifier); // Make sure dependencies at least have a node
@ -2054,7 +2080,7 @@ index 0000000000000000000000000000000000000000..22189a1c42459c00d3e8bdeb980d15a6
+}
diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/strategy/LegacyPluginLoadingStrategy.java b/src/main/java/io/papermc/paper/plugin/entrypoint/strategy/LegacyPluginLoadingStrategy.java
new file mode 100644
index 0000000000000000000000000000000000000000..d116134db072ecea7caeb90310fab9d83534ef48
index 0000000000000000000000000000000000000000..746272e0f8fb5311d5408175abe08db8aa356376
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/entrypoint/strategy/LegacyPluginLoadingStrategy.java
@@ -0,0 +1,269 @@
@ -2266,7 +2292,7 @@ index 0000000000000000000000000000000000000000..d116134db072ecea7caeb90310fab9d8
+ javapluginsLoaded.add(new ProviderPair<>(file, loadedPlugin));
+ }
+
+ } catch (Exception ex) {
+ } catch (Throwable ex) {
+ LOGGER.log(Level.SEVERE, "Could not load '" + file.getSource() + "' in folder '" + file.getParentSource() + "'", ex); // Paper
+ }
+ }
@ -2298,7 +2324,7 @@ index 0000000000000000000000000000000000000000..d116134db072ecea7caeb90310fab9d8
+ javapluginsLoaded.add(new ProviderPair<>(file, loadedPlugin));
+ }
+ break;
+ } catch (Exception ex) {
+ } catch (Throwable ex) {
+ LOGGER.log(Level.SEVERE, "Could not load '" + file.getSource() + "' in folder '" + file.getParentSource() + "'", ex); // Paper
+ }
+ }
@ -2329,7 +2355,7 @@ index 0000000000000000000000000000000000000000..d116134db072ecea7caeb90310fab9d8
+}
diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/strategy/ModernPluginLoadingStrategy.java b/src/main/java/io/papermc/paper/plugin/entrypoint/strategy/ModernPluginLoadingStrategy.java
new file mode 100644
index 0000000000000000000000000000000000000000..f2ef0ac8b498013d232ee56fdafba331c7dcbe27
index 0000000000000000000000000000000000000000..fa7bbfeff53d5cab3d96a5f1181b610f4ce22518
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/entrypoint/strategy/ModernPluginLoadingStrategy.java
@@ -0,0 +1,148 @@
@ -2356,7 +2382,7 @@ index 0000000000000000000000000000000000000000..f2ef0ac8b498013d232ee56fdafba331
+@SuppressWarnings("UnstableApiUsage")
+public class ModernPluginLoadingStrategy<T> implements ProviderLoadingStrategy<T> {
+
+ private static final Logger LOGGER = LogUtils.getLogger();
+ private static final Logger LOGGER = LogUtils.getClassLogger();
+ private final ProviderConfiguration<T> configuration;
+
+ public ModernPluginLoadingStrategy(ProviderConfiguration<T> onLoad) {
@ -2421,7 +2447,7 @@ index 0000000000000000000000000000000000000000..f2ef0ac8b498013d232ee56fdafba331
+ LoadOrderConfiguration loadOrderConfiguration = validated.createConfiguration(providerMapMirror);
+
+ // Build a validated provider's load order changes
+ DependencyUtil.buildLoadGraph(loadOrderGraph, loadOrderConfiguration);
+ DependencyUtil.buildLoadGraph(loadOrderGraph, loadOrderConfiguration, providerMap::containsKey);
+
+ // Build a validated provider's dependencies into the graph
+ DependencyUtil.buildDependencyGraph(dependencyGraph, configuration);
@ -2463,7 +2489,7 @@ index 0000000000000000000000000000000000000000..f2ef0ac8b498013d232ee56fdafba331
+ if (this.configuration.load(retrievedProvider, instance)) {
+ loadedPlugins.add(new ProviderPair<>(retrievedProvider, instance));
+ }
+ } catch (Exception ex) {
+ } catch (Throwable ex) {
+ LOGGER.error("Could not load plugin '%s' in folder '%s'".formatted(retrievedProvider.getFileName(), retrievedProvider.getParentSource()), ex); // Paper
+ }
+ }
@ -5682,7 +5708,7 @@ index 0000000000000000000000000000000000000000..b2a6544e321fa61c58bdf5684231de10
+}
diff --git a/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProvider.java b/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..0da361611bd93bc3299b8559d5c7c2127a8a6f0f
index 0000000000000000000000000000000000000000..600023770e19f02258327816122298f58d73e4ab
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProvider.java
@@ -0,0 +1,188 @@
@ -5819,7 +5845,7 @@ index 0000000000000000000000000000000000000000..0da361611bd93bc3299b8559d5c7c212
+
+
+ this.status = ProviderStatus.INITIALIZED;
+ return loader.plugin;
+ return loader.getPlugin();
+ } catch (Throwable ex) {
+ this.status = ProviderStatus.ERRORED;
+ SneakyThrow.sneaky(ex);
@ -6282,22 +6308,22 @@ index 0000000000000000000000000000000000000000..fd55fd1d6518ebd1bc2513dd331f0720
+ }
+}
diff --git a/src/main/java/io/papermc/paper/util/StackWalkerUtil.java b/src/main/java/io/papermc/paper/util/StackWalkerUtil.java
index f7114d5b8f2f93f62883e24da29afaf9f74ee1a6..00e78a495575abb9496b1849822605b613afe3b4 100644
index f7114d5b8f2f93f62883e24da29afaf9f74ee1a6..8bf0630c0e06950cd99b7ae9898137f70c22063f 100644
--- a/src/main/java/io/papermc/paper/util/StackWalkerUtil.java
+++ b/src/main/java/io/papermc/paper/util/StackWalkerUtil.java
@@ -1,9 +1,11 @@
@@ -1,9 +1,10 @@
package io.papermc.paper.util;
+import io.papermc.paper.plugin.entrypoint.classloader.PaperPluginClassLoader;
+import io.papermc.paper.plugin.provider.classloader.ConfiguredPluginClassLoader;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.PluginClassLoader;
-import org.bukkit.plugin.java.PluginClassLoader;
import org.jetbrains.annotations.Nullable;
+import java.util.Objects;
import java.util.Optional;
public class StackWalkerUtil {
@@ -12,11 +14,20 @@ public class StackWalkerUtil {
@@ -12,11 +13,18 @@ public class StackWalkerUtil {
public static JavaPlugin getFirstPluginCaller() {
Optional<JavaPlugin> foundFrame = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE)
.walk(stream -> stream
@ -6307,10 +6333,8 @@ index f7114d5b8f2f93f62883e24da29afaf9f74ee1a6..00e78a495575abb9496b1849822605b6
- return classLoader.getPlugin();
+ ClassLoader classLoader = frame.getDeclaringClass().getClassLoader();
+ JavaPlugin plugin;
+ if (classLoader instanceof PaperPluginClassLoader pluginClassLoader) {
+ plugin = pluginClassLoader.getLoadedJavaPlugin();
+ } else if (classLoader instanceof PluginClassLoader spigotClassloader) {
+ plugin = spigotClassloader.getPlugin();
+ if (classLoader instanceof ConfiguredPluginClassLoader configuredPluginClassLoader) {
+ plugin = configuredPluginClassLoader.getPlugin();
+ } else {
+ plugin = null;
+ }

Datei anzeigen

@ -7,7 +7,7 @@ Also don't fire level events or game events if stalactite
drip is cancelled
diff --git a/src/main/java/net/minecraft/world/level/block/CauldronBlock.java b/src/main/java/net/minecraft/world/level/block/CauldronBlock.java
index 53089c3a36bf2c0ec1bc9b436884deff0c30f028..46846ac9981e447fc6886aecf82563378a4f5548 100644
index 53089c3a36bf2c0ec1bc9b436884deff0c30f028..2f85b893dd0abc39fcedec65acc89e1567faf6f0 100644
--- a/src/main/java/net/minecraft/world/level/block/CauldronBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CauldronBlock.java
@@ -36,10 +36,18 @@ public class CauldronBlock extends AbstractCauldronBlock {
@ -16,7 +16,7 @@ index 53089c3a36bf2c0ec1bc9b436884deff0c30f028..46846ac9981e447fc6886aecf8256337
if (precipitation == Biome.Precipitation.RAIN) {
- world.setBlockAndUpdate(pos, Blocks.WATER_CAULDRON.defaultBlockState());
+ // Paper start - call event for initial fill
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.WATER_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) {
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.WATER_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL, false)) { // avoid duplicate game event
+ return;
+ }
+ // Paper end
@ -24,7 +24,7 @@ index 53089c3a36bf2c0ec1bc9b436884deff0c30f028..46846ac9981e447fc6886aecf8256337
} else if (precipitation == Biome.Precipitation.SNOW) {
- world.setBlockAndUpdate(pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState());
+ // Paper start - call event for initial fill
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) {
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL, false)) { // avoid duplicate game event
+ return;
+ }
+ // Paper end
@ -54,15 +54,30 @@ index 53089c3a36bf2c0ec1bc9b436884deff0c30f028..46846ac9981e447fc6886aecf8256337
}
diff --git a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
index 24d2da792bc498adf4251555a538df4cafe2e827..1a7cb12fd3f183c00079d679452a01b8df8d2bbb 100644
index 24d2da792bc498adf4251555a538df4cafe2e827..14164aa59fa5e315788cd7a207228081a05fd18f 100644
--- a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
@@ -91,7 +91,7 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock {
@@ -91,7 +91,13 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock {
}
// CraftBukkit start
- public static boolean changeLevel(BlockState iblockdata, Level world, BlockPos blockposition, BlockState newBlock, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
+ // Paper start
+ public static boolean changeLevel(BlockState iblockdata, Level world, BlockPos blockposition, BlockState newBlock, @javax.annotation.Nullable Entity entity, CauldronLevelChangeEvent.ChangeReason reason) { // Paper - entity is nullable
+ return changeLevel(iblockdata, world, blockposition, newBlock, entity, reason, true);
+ }
+
+ public static boolean changeLevel(BlockState iblockdata, Level world, BlockPos blockposition, BlockState newBlock, @javax.annotation.Nullable Entity entity, CauldronLevelChangeEvent.ChangeReason reason, boolean sendGameEvent) { // Paper - entity is nullable
+ // Paper end
CraftBlockState newState = CraftBlockStates.getBlockState(world, blockposition);
newState.setData(newBlock);
@@ -104,7 +110,7 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock {
return false;
}
newState.update(true);
- world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(newBlock));
+ if (sendGameEvent) world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(newBlock)); // Paper
return true;
}
// CraftBukkit end