diff options
author | Bjarne Koll <[email protected]> | 2024-09-19 16:36:07 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2024-09-19 16:36:07 +0200 |
commit | c5a10665b8b80af650500b9263036f778f06d500 (patch) | |
tree | fedc133f0dbc101067951e1fccd9d577c312fdb8 /patches/server/0969-Allow-Bukkit-plugin-to-use-Paper-PluginLoader-API.patch | |
parent | 5c829557332f21b34bc81e6ad1a73e511faef8f6 (diff) | |
download | Paper-c5a10665b8b80af650500b9263036f778f06d500.tar.gz Paper-c5a10665b8b80af650500b9263036f778f06d500.zip |
Remove wall-time / unused skip tick protection (#11412)
Spigot still maintains some partial implementation of "tick skipping", a
practice in which the MinecraftServer.currentTick field is updated not
by an increment of one per actual tick, but instead set to
System.currentTimeMillis() / 50. This behaviour means that the tracked
tick may "skip" a tick value in case a previous tick took more than the
expected 50ms.
To compensate for this in important paths, spigot/craftbukkit
implements "wall-time". Instead of incrementing/decrementing ticks on
block entities/entities by one for each call to their tick() method,
they instead increment/decrement important values, like
an ItemEntity's age or pickupDelay, by the difference of
`currentTick - lastTick`, where `lastTick` is the value of
`currentTick` during the last tick() call.
These "fixes" however do not play nicely with minecraft's simulation
distance as entities/block entities implementing the above behaviour
would "catch up" their values when moving from a non-ticking chunk to a
ticking one as their `lastTick` value remains stuck on the last tick in
a ticking chunk and hence lead to a large "catch up" once ticked again.
Paper completely removes the "tick skipping" behaviour (See patch
"Further-improve-server-tick-loop"), making the above precautions
completely unnecessary, which also rids paper of the previous described
incompatibility with non-ticking chunks.
Diffstat (limited to 'patches/server/0969-Allow-Bukkit-plugin-to-use-Paper-PluginLoader-API.patch')
-rw-r--r-- | patches/server/0969-Allow-Bukkit-plugin-to-use-Paper-PluginLoader-API.patch | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/patches/server/0969-Allow-Bukkit-plugin-to-use-Paper-PluginLoader-API.patch b/patches/server/0969-Allow-Bukkit-plugin-to-use-Paper-PluginLoader-API.patch new file mode 100644 index 0000000000..8b39d13b43 --- /dev/null +++ b/patches/server/0969-Allow-Bukkit-plugin-to-use-Paper-PluginLoader-API.patch @@ -0,0 +1,130 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jason Penilla <[email protected]> +Date: Tue, 21 May 2024 13:18:15 -0700 +Subject: [PATCH] Allow Bukkit plugin to use Paper PluginLoader API + + +diff --git a/src/main/java/io/papermc/paper/plugin/loader/PaperClasspathBuilder.java b/src/main/java/io/papermc/paper/plugin/loader/PaperClasspathBuilder.java +index f871a329eb52da077f58d0ceaaabd3349f84cad0..21a0a4e29c0eb1b4f7dc89ad3df481ca89dbf1a4 100644 +--- a/src/main/java/io/papermc/paper/plugin/loader/PaperClasspathBuilder.java ++++ b/src/main/java/io/papermc/paper/plugin/loader/PaperClasspathBuilder.java +@@ -41,15 +41,7 @@ public class PaperClasspathBuilder implements PluginClasspathBuilder { + } + + public PaperPluginClassLoader buildClassLoader(Logger logger, Path source, JarFile jarFile, PaperPluginMeta configuration) { +- PaperLibraryStore paperLibraryStore = new PaperLibraryStore(); +- for (ClassPathLibrary library : this.libraries) { +- library.register(paperLibraryStore); +- } +- +- List<Path> paths = paperLibraryStore.getPaths(); +- if (PluginInitializerManager.instance().pluginRemapper != null) { +- paths = PluginInitializerManager.instance().pluginRemapper.remapLibraries(paths); +- } ++ List<Path> paths = this.buildLibraryPaths(true); + URL[] urls = new URL[paths.size()]; + for (int i = 0; i < paths.size(); i++) { + Path path = paths.get(i); +@@ -69,4 +61,17 @@ public class PaperClasspathBuilder implements PluginClasspathBuilder { + throw new RuntimeException(exception); + } + } ++ ++ public List<Path> buildLibraryPaths(final boolean remap) { ++ PaperLibraryStore paperLibraryStore = new PaperLibraryStore(); ++ for (ClassPathLibrary library : this.libraries) { ++ library.register(paperLibraryStore); ++ } ++ ++ List<Path> paths = paperLibraryStore.getPaths(); ++ if (remap && PluginInitializerManager.instance().pluginRemapper != null) { ++ paths = PluginInitializerManager.instance().pluginRemapper.remapLibraries(paths); ++ } ++ return paths; ++ } + } +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 +index 75a2b687d58d76b94f8bec111df8613f120ff74b..0fd1040ed376f19c6d5326767baaf3048ce1bfb4 100644 +--- 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 +@@ -40,15 +40,17 @@ public class SpigotPluginProvider implements PluginProvider<JavaPlugin>, Provide + private final PluginDescriptionFile description; + private final JarFile jarFile; + private final Logger logger; ++ private final List<Path> paperLibraryPaths; + private final ComponentLogger componentLogger; + private ProviderStatus status; + private DependencyContext dependencyContext; + +- SpigotPluginProvider(Path path, JarFile file, PluginDescriptionFile description) { ++ SpigotPluginProvider(Path path, JarFile file, PluginDescriptionFile description, List<Path> paperLibraryPaths) { + this.path = path; + this.jarFile = file; + this.description = description; + this.logger = PaperPluginLogger.getLogger(description); ++ this.paperLibraryPaths = paperLibraryPaths; + this.componentLogger = ComponentLogger.logger(this.logger.getName()); + } + +@@ -120,7 +122,7 @@ public class SpigotPluginProvider implements PluginProvider<JavaPlugin>, Provide + + final PluginClassLoader loader; + try { +- loader = new PluginClassLoader(this.getClass().getClassLoader(), this.description, dataFolder, this.path.toFile(), LIBRARY_LOADER.createLoader(this.description), this.jarFile, this.dependencyContext); // Paper ++ loader = new PluginClassLoader(this.getClass().getClassLoader(), this.description, dataFolder, this.path.toFile(), LIBRARY_LOADER.createLoader(this.description, this.paperLibraryPaths), this.jarFile, this.dependencyContext); // Paper + } catch (InvalidPluginException ex) { + throw ex; + } catch (Throwable ex) { +diff --git a/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java b/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java +index 1bf0fa1530b8e5f94d726d0313b7a00f675b500c..9edf79dffd2836b40d41da4437c18d6145853f89 100644 +--- a/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java ++++ b/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java +@@ -1,9 +1,18 @@ + package io.papermc.paper.plugin.provider.type.spigot; + ++import com.destroystokyo.paper.utils.PaperPluginLogger; ++import io.papermc.paper.plugin.bootstrap.PluginProviderContextImpl; + import io.papermc.paper.plugin.entrypoint.classloader.BytecodeModifyingURLClassLoader; ++import io.papermc.paper.plugin.entrypoint.classloader.PaperSimplePluginClassLoader; ++import io.papermc.paper.plugin.loader.PaperClasspathBuilder; ++import io.papermc.paper.plugin.loader.PluginLoader; + import io.papermc.paper.plugin.provider.configuration.serializer.constraints.PluginConfigConstraints; + import io.papermc.paper.plugin.provider.type.PluginTypeFactory; ++import io.papermc.paper.plugin.provider.util.ProviderUtil; + import io.papermc.paper.util.MappingEnvironment; ++import java.util.List; ++import java.util.logging.Logger; ++import net.kyori.adventure.text.logger.slf4j.ComponentLogger; + import org.bukkit.plugin.InvalidDescriptionException; + import org.bukkit.plugin.PluginDescriptionFile; + import org.bukkit.plugin.java.LibraryLoader; +@@ -36,7 +45,28 @@ class SpigotPluginProviderFactory implements PluginTypeFactory<SpigotPluginProvi + throw new InvalidDescriptionException("Restricted name, cannot use 0x20 (space character) in a plugin name."); + } + +- return new SpigotPluginProvider(source, file, configuration); ++ final List<Path> paperLibraryPaths; ++ if (configuration.getPaperPluginLoader() != null) { ++ final Logger logger = PaperPluginLogger.getLogger(configuration); ++ PaperClasspathBuilder builder = new PaperClasspathBuilder(PluginProviderContextImpl.create( ++ configuration, ComponentLogger.logger(logger.getName()), source ++ )); ++ ++ try ( ++ PaperSimplePluginClassLoader simplePluginClassLoader = new PaperSimplePluginClassLoader(source, file, configuration, this.getClass().getClassLoader()) ++ ) { ++ PluginLoader loader = ProviderUtil.loadClass(configuration.getPaperPluginLoader(), PluginLoader.class, simplePluginClassLoader); ++ loader.classloader(builder); ++ } catch (IOException e) { ++ throw new RuntimeException(e); ++ } ++ ++ paperLibraryPaths = builder.buildLibraryPaths(false); ++ } else { ++ paperLibraryPaths = null; ++ } ++ ++ return new SpigotPluginProvider(source, file, configuration, paperLibraryPaths); + } + + @Override |