aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2024-02-02 12:44:09 +0100
committerNassim Jahnke <[email protected]>2024-02-02 12:44:09 +0100
commitc5d168cef92148a6799141832fdb5f95732c1a38 (patch)
tree2eaba8e52bb1d5512ef9e40c555b1d08607a9191 /patches
parent8bc5be8ba726a10c2d2e4a1b0fd500d027c08988 (diff)
downloadPaper-c5d168cef92148a6799141832fdb5f95732c1a38.tar.gz
Paper-c5d168cef92148a6799141832fdb5f95732c1a38.zip
More provider source fixup
Diffstat (limited to 'patches')
-rw-r--r--patches/server/0013-Paper-Plugins.patch100
-rw-r--r--patches/server/0904-Folia-scheduler-and-owned-region-API.patch12
2 files changed, 67 insertions, 45 deletions
diff --git a/patches/server/0013-Paper-Plugins.patch b/patches/server/0013-Paper-Plugins.patch
index 0bc8990f58..9d5b2ad42e 100644
--- a/patches/server/0013-Paper-Plugins.patch
+++ b/patches/server/0013-Paper-Plugins.patch
@@ -3769,10 +3769,10 @@ index 0000000000000000000000000000000000000000..92a69677f21b2c1c035119d8e5a6af63
+}
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java
new file mode 100644
-index 0000000000000000000000000000000000000000..a2a5ab966f7ae118470a8d74cbe1e55cc301c1bb
+index 0000000000000000000000000000000000000000..0f8fa69577f09030fe96df6fa37e88ed38134a2e
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java
-@@ -0,0 +1,304 @@
+@@ -0,0 +1,303 @@
+package io.papermc.paper.plugin.manager;
+
+import com.google.common.base.Preconditions;
@@ -3822,7 +3822,6 @@ index 0000000000000000000000000000000000000000..a2a5ab966f7ae118470a8d74cbe1e55c
+class PaperPluginInstanceManager {
+
+ private static final FileProviderSource FILE_PROVIDER_SOURCE = new FileProviderSource("File '%s'"::formatted);
-+ private static final DirectoryProviderSource DIRECTORY_PROVIDER_SOURCE = new DirectoryProviderSource();
+
+ private final List<Plugin> plugins = new ArrayList<>();
+ private final Map<String, Plugin> lookupNames = new HashMap<>();
@@ -3904,8 +3903,8 @@ index 0000000000000000000000000000000000000000..a2a5ab966f7ae118470a8d74cbe1e55c
+
+ RuntimePluginEntrypointHandler<MultiRuntimePluginProviderStorage> runtimePluginEntrypointHandler = new RuntimePluginEntrypointHandler<>(new MultiRuntimePluginProviderStorage(this.dependencyTree));
+ try {
-+ directory = DIRECTORY_PROVIDER_SOURCE.prepareContext(directory);
-+ DIRECTORY_PROVIDER_SOURCE.registerProviders(runtimePluginEntrypointHandler, directory);
++ List<Path> files = DirectoryProviderSource.INSTANCE.prepareContext(directory);
++ DirectoryProviderSource.INSTANCE.registerProviders(runtimePluginEntrypointHandler, files);
+ runtimePluginEntrypointHandler.enter(Entrypoint.PLUGIN);
+ } catch (Exception e) {
+ // This should never happen, any errors that occur in this provider should instead be logged.
@@ -5480,64 +5479,63 @@ index 0000000000000000000000000000000000000000..49a087381307eab263f7dad43aaa2598
+}
diff --git a/src/main/java/io/papermc/paper/plugin/provider/source/DirectoryProviderSource.java b/src/main/java/io/papermc/paper/plugin/provider/source/DirectoryProviderSource.java
new file mode 100644
-index 0000000000000000000000000000000000000000..162c8ce2cb5e5863ea88c1bfbe90ab45288b50e4
+index 0000000000000000000000000000000000000000..f30fcf60b64150e381c7b813016aa9ddf6f2c4e4
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/provider/source/DirectoryProviderSource.java
-@@ -0,0 +1,67 @@
+@@ -0,0 +1,66 @@
+package io.papermc.paper.plugin.provider.source;
+
+import com.mojang.logging.LogUtils;
+import io.papermc.paper.plugin.entrypoint.EntrypointHandler;
+import java.io.IOException;
-+import java.util.function.Consumer;
-+import org.slf4j.Logger;
-+
+import java.nio.file.FileVisitOption;
+import java.nio.file.Files;
+import java.nio.file.Path;
++import java.util.ArrayList;
++import java.util.List;
++import java.util.function.Consumer;
++import org.slf4j.Logger;
+
+/**
+ * Loads all plugin providers in the given directory.
+ */
-+public class DirectoryProviderSource extends FileProviderSource {
++public class DirectoryProviderSource implements ProviderSource<Path, List<Path>> {
+
+ public static final DirectoryProviderSource INSTANCE = new DirectoryProviderSource();
++ private static final FileProviderSource FILE_PROVIDER_SOURCE = new FileProviderSource("Directory '%s'"::formatted);
+ private static final Logger LOGGER = LogUtils.getClassLogger();
+
-+ public DirectoryProviderSource() {
-+ super("Directory '%s'"::formatted);
-+ }
-+
+ @Override
-+ public Path prepareContext(Path context) throws IOException {
++ public List<Path> prepareContext(Path context) throws IOException {
+ // Symlink happy, create file if missing.
+ if (!Files.isDirectory(context)) {
+ Files.createDirectories(context);
+ }
+
++ final List<Path> files = new ArrayList<>();
+ this.walkFiles(context, path -> {
+ try {
-+ super.prepareContext(path);
++ files.add(FILE_PROVIDER_SOURCE.prepareContext(path));
+ } catch (IllegalArgumentException ignored) {
+ // Ignore illegal argument exceptions from jar checking
+ } catch (IOException e) {
-+ throw new RuntimeException(e);
++ LOGGER.error("Error preparing plugin context: " + e.getMessage(), e);
+ }
+ });
-+ return context;
++ return files;
+ }
+
+ @Override
-+ public void registerProviders(EntrypointHandler entrypointHandler, Path context) throws IOException {
-+ this.walkFiles(context, path -> {
++ public void registerProviders(EntrypointHandler entrypointHandler, List<Path> context) {
++ for (Path path : context) {
+ try {
-+ super.registerProviders(entrypointHandler, path);
++ FILE_PROVIDER_SOURCE.registerProviders(entrypointHandler, path);
+ } catch (IllegalArgumentException ignored) {
+ // Ignore illegal argument exceptions from jar checking
+ } catch (Exception e) {
+ LOGGER.error("Error loading plugin: " + e.getMessage(), e);
+ }
-+ });
++ }
+ }
+
+ private void walkFiles(Path context, Consumer<Path> consumer) throws IOException {
@@ -5553,7 +5551,7 @@ index 0000000000000000000000000000000000000000..162c8ce2cb5e5863ea88c1bfbe90ab45
+}
diff --git a/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java b/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
new file mode 100644
-index 0000000000000000000000000000000000000000..2df0a287b716d86c5224221afb95ff8ba95ae14c
+index 0000000000000000000000000000000000000000..d33762ce5977636320e324dde4aab37075865d8d
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
@@ -0,0 +1,163 @@
@@ -5580,7 +5578,7 @@ index 0000000000000000000000000000000000000000..2df0a287b716d86c5224221afb95ff8b
+/**
+ * Loads a plugin provider at the given plugin jar file path.
+ */
-+public class FileProviderSource implements ProviderSource<Path> {
++public class FileProviderSource implements ProviderSource<Path, Path> {
+
+ private final Function<Path, String> contextChecker;
+
@@ -5722,15 +5720,16 @@ index 0000000000000000000000000000000000000000..2df0a287b716d86c5224221afb95ff8b
+}
diff --git a/src/main/java/io/papermc/paper/plugin/provider/source/PluginFlagProviderSource.java b/src/main/java/io/papermc/paper/plugin/provider/source/PluginFlagProviderSource.java
new file mode 100644
-index 0000000000000000000000000000000000000000..9ec048ec424e2926f76419fdc0b9610ad06b2e98
+index 0000000000000000000000000000000000000000..ac55ae0e30119556f01e2e36c20fc63a111fae5f
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/provider/source/PluginFlagProviderSource.java
-@@ -0,0 +1,34 @@
+@@ -0,0 +1,43 @@
+package io.papermc.paper.plugin.provider.source;
+
+import com.mojang.logging.LogUtils;
+import io.papermc.paper.plugin.entrypoint.EntrypointHandler;
+import java.nio.file.Path;
++import java.util.ArrayList;
+import org.slf4j.Logger;
+
+import java.util.List;
@@ -5738,22 +5737,30 @@ index 0000000000000000000000000000000000000000..9ec048ec424e2926f76419fdc0b9610a
+/**
+ * Registers providers at the provided files in the add-plugin argument.
+ */
-+public class PluginFlagProviderSource implements ProviderSource<List<Path>> {
++public class PluginFlagProviderSource implements ProviderSource<List<Path>, List<Path>> {
+
+ public static final PluginFlagProviderSource INSTANCE = new PluginFlagProviderSource();
++ private static final FileProviderSource FILE_PROVIDER_SOURCE = new FileProviderSource("File '%s' specified through 'add-plugin' argument"::formatted);
+ private static final Logger LOGGER = LogUtils.getClassLogger();
-+ private final FileProviderSource providerSource = new FileProviderSource("File '%s' specified through 'add-plugin' argument"::formatted);
+
+ @Override
+ public List<Path> prepareContext(List<Path> context) {
-+ return context;
++ final List<Path> files = new ArrayList<>();
++ for (Path path : context) {
++ try {
++ files.add(FILE_PROVIDER_SOURCE.prepareContext(path));
++ } catch (Exception e) {
++ LOGGER.error("Error preparing plugin context: " + e.getMessage(), e);
++ }
++ }
++ return files;
+ }
+
+ @Override
+ public void registerProviders(EntrypointHandler entrypointHandler, List<Path> context) {
+ for (Path path : context) {
+ try {
-+ this.providerSource.registerProviders(entrypointHandler, path);
++ FILE_PROVIDER_SOURCE.registerProviders(entrypointHandler, path);
+ } catch (Exception e) {
+ LOGGER.error("Error loading plugin: " + e.getMessage(), e);
+ }
@@ -5762,10 +5769,10 @@ index 0000000000000000000000000000000000000000..9ec048ec424e2926f76419fdc0b9610a
+}
diff --git a/src/main/java/io/papermc/paper/plugin/provider/source/ProviderSource.java b/src/main/java/io/papermc/paper/plugin/provider/source/ProviderSource.java
new file mode 100644
-index 0000000000000000000000000000000000000000..81b199ea16f86d508dfa32956c56be91bfb5d308
+index 0000000000000000000000000000000000000000..6b09813c75fad02fe9b8deb0bf86ad0b148fa770
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/provider/source/ProviderSource.java
-@@ -0,0 +1,17 @@
+@@ -0,0 +1,32 @@
+package io.papermc.paper.plugin.provider.source;
+
+import io.papermc.paper.plugin.entrypoint.EntrypointHandler;
@@ -5775,13 +5782,28 @@ index 0000000000000000000000000000000000000000..81b199ea16f86d508dfa32956c56be91
+ * A provider source is responsible for giving PluginTypes an EntrypointHandler for
+ * registering providers at.
+ *
++ * @param <I> input context
+ * @param <C> context
+ */
-+public interface ProviderSource<C> {
++public interface ProviderSource<I, C> {
+
-+ C prepareContext(C context) throws IOException;
++ /**
++ * Prepares the context for use in {@link #registerProviders(EntrypointHandler, Object)}.
++ *
++ * @param context the context to prepare
++ * @return the prepared context, ready for use in {@link #registerProviders(EntrypointHandler, Object)}
++ * @throws IOException if an error occurs while preparing the context
++ */
++ C prepareContext(I context) throws IOException;
+
-+ void registerProviders(EntrypointHandler entrypointHandler, C context) throws Throwable;
++ /**
++ * Uses the prepared context to register providers at the given entrypoint handler.
++ *
++ * @param entrypointHandler the entrypoint handler to register providers at
++ * @param context the context to register providers at
++ * @throws Exception if an error occurs while registering providers
++ */
++ void registerProviders(EntrypointHandler entrypointHandler, C context) throws Exception;
+}
diff --git a/src/main/java/io/papermc/paper/plugin/provider/type/PluginFileType.java b/src/main/java/io/papermc/paper/plugin/provider/type/PluginFileType.java
new file mode 100644
@@ -6980,7 +7002,7 @@ index 0000000000000000000000000000000000000000..c1114675137e862ac9682b635bfdbfbc
+package io.papermc.paper.plugin.storage;
diff --git a/src/main/java/io/papermc/paper/plugin/util/EntrypointUtil.java b/src/main/java/io/papermc/paper/plugin/util/EntrypointUtil.java
new file mode 100644
-index 0000000000000000000000000000000000000000..3b19a94117d55c2b73efda704ee504a72bec94d1
+index 0000000000000000000000000000000000000000..01c88a23755618b98c1a1cdeb8e404e79401940b
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/util/EntrypointUtil.java
@@ -0,0 +1,20 @@
@@ -6995,9 +7017,9 @@ index 0000000000000000000000000000000000000000..3b19a94117d55c2b73efda704ee504a7
+
+ private static final Logger LOGGER = LogUtils.getClassLogger();
+
-+ public static <C> void registerProvidersFromSource(ProviderSource<C> source, C context) {
++ public static <I, C> void registerProvidersFromSource(ProviderSource<I, C> source, I contextInput) {
+ try {
-+ context = source.prepareContext(context);
++ C context = source.prepareContext(contextInput);
+ source.registerProviders(LaunchEntryPointHandler.INSTANCE, context);
+ } catch (Throwable e) {
+ LOGGER.error(e.getMessage(), e);
diff --git a/patches/server/0904-Folia-scheduler-and-owned-region-API.patch b/patches/server/0904-Folia-scheduler-and-owned-region-API.patch
index 167ce0b99d..a981b4c7de 100644
--- a/patches/server/0904-Folia-scheduler-and-owned-region-API.patch
+++ b/patches/server/0904-Folia-scheduler-and-owned-region-API.patch
@@ -17,10 +17,10 @@ outside of the buffer zone is owned. Then, the plugins may use
the schedulers depending on the result of the ownership check.
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java
-index a2a5ab966f7ae118470a8d74cbe1e55cc301c1bb..713d50da42f46209366c83f9284efb15ce71f382 100644
+index 0f8fa69577f09030fe96df6fa37e88ed38134a2e..eeea1e6f7b1ed64567a3f90d8eb2e2cfd53e5912 100644
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java
-@@ -250,6 +250,22 @@ class PaperPluginInstanceManager {
+@@ -249,6 +249,22 @@ class PaperPluginInstanceManager {
+ pluginName + " (Is it up to date?)", ex, plugin); // Paper
}
@@ -1148,7 +1148,7 @@ index 0000000000000000000000000000000000000000..d306f911757a4d556c82c0070d4837db
+ }
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 3962449262a8d8e99fd57c17ccc0836913949f78..7d637094afecc2a838f9cc5cc837f8bf63cfd5aa 100644
+index 97dbe5a44d2791c6dee830654c3935f4ac54aad4..48da5bdabcf38afbbd1509eca56d5c761622409f 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1497,6 +1497,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1173,7 +1173,7 @@ index 3962449262a8d8e99fd57c17ccc0836913949f78..7d637094afecc2a838f9cc5cc837f8bf
this.profiler.push("commandFunctions");
MinecraftTimings.commandFunctionsTimer.startTiming(); // Spigot // Paper
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
-index 980d03a5594bc6bf1d687230e13c2dead544c18d..56d8767a19b03b5e70c6a5a5cd747a59abf062ee 100644
+index 2eeb216002c1c91879780225335225552744524b..74b3f459c898dc9f5c4411a38c9018fb4866f0b1 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -647,6 +647,7 @@ public abstract class PlayerList {
@@ -1185,7 +1185,7 @@ index 980d03a5594bc6bf1d687230e13c2dead544c18d..56d8767a19b03b5e70c6a5a5cd747a59
this.players.remove(entityplayer);
this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
-index fb934b069312ce27c8ebaf3d3645b2c2475bd87f..ecdf98872f2f9b9b067be80701f20775b45e4aad 100644
+index 417e64d587b516df94abee5893a6dc9e8917eeca..e2f6401249470af599b8b1371105fc01a58b0091 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -246,11 +246,23 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1251,7 +1251,7 @@ index fb934b069312ce27c8ebaf3d3645b2c2475bd87f..ecdf98872f2f9b9b067be80701f20775
public void setLevelCallback(EntityInLevelCallback changeListener) {
this.levelCallback = changeListener;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-index bd2c0c3d4ccfecc61efd4b81c4f2a8dd0aaa2686..dcb4a1bea63cec3a4c4b429dabf76a6ad42dff43 100644
+index c026db3758b7fd9c57a1badd4c1a9c2b34c8712d..248292bdb26cb2f08a41692ed7e9262ca6d6dd13 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -306,6 +306,76 @@ public final class CraftServer implements Server {