From 99f376a0f0d232a3390a2feede6201927149df28 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 15 May 2021 15:52:07 -0700 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5643) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 146a7e4b SPIGOT-5345: Add automatic library support CraftBukkit Changes: b1064c69 Remove sisu annotation processor from jar 32e40866 SPIGOT-6189: Persistent data disappears when calling setFacingDirection on an item frame d189f78b # 827: Trigger vanilla dimension advancements in non-main worlds 5bbb4a65 Add plumbing for automatic library support Spigot Changes: 9fb885e8 Rebuild patches --- ...or-plugins-modifying-the-parent-of-t.patch | 2 +- ...lose-Plugin-Class-Loaders-on-Disable.patch | 4 +- .../Enable-multi-release-plugin-jars.patch | 2 +- .../Make-JavaPluginLoader-thread-safe.patch | 22 ++++------ ...rioritise-own-classes-where-possible.patch | 44 +++++++++++-------- Spigot-API-Patches/Timings-v2.patch | 2 +- ...n-item-frames-are-modified-MC-123450.patch | 13 ------ Spigot-Server-Patches/POM-Changes.patch | 25 +++++++---- work/Bukkit | 2 +- work/CraftBukkit | 2 +- work/Spigot | 2 +- 11 files changed, 58 insertions(+), 62 deletions(-) diff --git a/Spigot-API-Patches/Add-workaround-for-plugins-modifying-the-parent-of-t.patch b/Spigot-API-Patches/Add-workaround-for-plugins-modifying-the-parent-of-t.patch index b50ff2c515..2406cc6426 100644 --- a/Spigot-API-Patches/Add-workaround-for-plugins-modifying-the-parent-of-t.patch +++ b/Spigot-API-Patches/Add-workaround-for-plugins-modifying-the-parent-of-t.patch @@ -99,8 +99,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 static { ClassLoader.registerAsParallelCapable(); @@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot - this.manifest = jar.getManifest(); this.url = file.toURI().toURL(); + this.libraryLoader = libraryLoader; + this.logger = com.destroystokyo.paper.utils.PaperPluginLogger.getLogger(description); // Paper - Register logger early + diff --git a/Spigot-API-Patches/Close-Plugin-Class-Loaders-on-Disable.patch b/Spigot-API-Patches/Close-Plugin-Class-Loaders-on-Disable.patch index 641a99917b..3775343b68 100644 --- a/Spigot-API-Patches/Close-Plugin-Class-Loaders-on-Disable.patch +++ b/Spigot-API-Patches/Close-Plugin-Class-Loaders-on-Disable.patch @@ -123,8 +123,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (plugin.isEnabled()) { @@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader { - for (String name : names) { - removeClass(name); + } catch (IOException ex) { + // } + // Paper start - close Class Loader on disable + try { diff --git a/Spigot-API-Patches/Enable-multi-release-plugin-jars.patch b/Spigot-API-Patches/Enable-multi-release-plugin-jars.patch index 178e39bf6c..97b4c61f4f 100644 --- a/Spigot-API-Patches/Enable-multi-release-plugin-jars.patch +++ b/Spigot-API-Patches/Enable-multi-release-plugin-jars.patch @@ -27,4 +27,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end this.manifest = jar.getManifest(); this.url = file.toURI().toURL(); - + this.libraryLoader = libraryLoader; diff --git a/Spigot-API-Patches/Make-JavaPluginLoader-thread-safe.patch b/Spigot-API-Patches/Make-JavaPluginLoader-thread-safe.patch index 0a359dec90..33c26d2809 100644 --- a/Spigot-API-Patches/Make-JavaPluginLoader-thread-safe.patch +++ b/Spigot-API-Patches/Make-JavaPluginLoader-thread-safe.patch @@ -8,37 +8,31 @@ diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java -@@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader { +@@ -0,0 +0,0 @@ import org.yaml.snakeyaml.error.YAMLException; + public final class JavaPluginLoader implements PluginLoader { final Server server; private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")}; - private final Map> classes = new ConcurrentHashMap>(); + private final Map classLoadLock = new java.util.HashMap(); // Paper + private final Map classLoadLockCount = new java.util.HashMap(); // Paper private final List loaders = new CopyOnWriteArrayList(); + private final LibraryLoader libraryLoader; - /** @@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader { @Nullable - Class getClassByName(final String name) { + Class getClassByName(final String name, boolean resolve, PluginDescriptionFile description) { + // Paper start - make MT safe - Class cachedClass = classes.get(name); -+ if (cachedClass != null) { -+ return cachedClass; -+ } + java.util.concurrent.locks.ReentrantReadWriteLock lock; + synchronized (classLoadLock) { + lock = classLoadLock.computeIfAbsent(name, (x) -> new java.util.concurrent.locks.ReentrantReadWriteLock()); + classLoadLockCount.compute(name, (x, prev) -> prev != null ? prev + 1 : 1); + } + lock.writeLock().lock();try { -+ cachedClass = classes.get(name); + // Paper end - - if (cachedClass != null) { - return cachedClass; -@@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader { - } + for (PluginClassLoader loader : loaders) { + try { + return loader.loadClass0(name, resolve, false, ((SimplePluginManager) server.getPluginManager()).isTransitiveDepend(description, loader.plugin.getDescription())); + } catch (ClassNotFoundException cnfe) { } } + // Paper start - make MT safe diff --git a/Spigot-API-Patches/Prioritise-own-classes-where-possible.patch b/Spigot-API-Patches/Prioritise-own-classes-where-possible.patch index 44177329cd..f72e697a46 100644 --- a/Spigot-API-Patches/Prioritise-own-classes-where-possible.patch +++ b/Spigot-API-Patches/Prioritise-own-classes-where-possible.patch @@ -34,20 +34,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 final Server server; + private static final boolean DISABLE_CLASS_PRIORITIZATION = Boolean.getBoolean("Paper.DisableClassPrioritization"); // Paper private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")}; - private final Map> classes = new ConcurrentHashMap>(); private final Map classLoadLock = new java.util.HashMap(); // Paper + private final Map classLoadLockCount = new java.util.HashMap(); // Paper @@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader { @Nullable - Class getClassByName(final String name) { + Class getClassByName(final String name, boolean resolve, PluginDescriptionFile description) { + // Paper start - prioritize self -+ return getClassByName(name, null); ++ return getClassByName(name, resolve, description, null); + } -+ Class getClassByName(final String name, PluginClassLoader requester) { ++ Class getClassByName(final String name, boolean resolve, PluginDescriptionFile description, PluginClassLoader requester) { + // Paper end // Paper start - make MT safe - Class cachedClass = classes.get(name); - if (cachedClass != null) { + java.util.concurrent.locks.ReentrantReadWriteLock lock; + synchronized (classLoadLock) { @@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader { classLoadLockCount.compute(name, (x, prev) -> prev != null ? prev + 1 : 1); } @@ -55,26 +55,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - prioritize self + if (!DISABLE_CLASS_PRIORITIZATION && requester != null) { + try { -+ cachedClass = requester.findClass(name, false); ++ return requester.loadClass0(name, false, false, ((SimplePluginManager) server.getPluginManager()).isTransitiveDepend(description, requester.getDescription())); + } catch (ClassNotFoundException cnfe) {} -+ if (cachedClass != null) { -+ return cachedClass; -+ } + } -+ // Paper end- - cachedClass = classes.get(name); ++ // Paper end // Paper end - + for (PluginClassLoader loader : loaders) { + try { diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java +++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java @@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot + public JavaPlugin getPlugin() { return plugin; } // Spigot + private final JavaPluginLoader loader; + private final Map> classes = new ConcurrentHashMap>(); +- private final PluginDescriptionFile description; ++ private final PluginDescriptionFile description; PluginDescriptionFile getDescription() { return description; } // Paper + private final File dataFolder; + private final File file; + private final JarFile jar; +@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot + } - if (result == null) { - if (checkGlobal) { -- result = loader.getClassByName(name); -+ result = loader.getClassByName(name, this); // Paper - prioritize self + if (checkGlobal) { +- Class result = loader.getClassByName(name, resolve, description); ++ Class result = loader.getClassByName(name, resolve, description, this); // Paper - prioritize self - if (result != null) { - PluginDescriptionFile provider = ((PluginClassLoader) result.getClassLoader()).description; + if (result != null) { + PluginDescriptionFile provider = ((PluginClassLoader) result.getClassLoader()).description; diff --git a/Spigot-API-Patches/Timings-v2.patch b/Spigot-API-Patches/Timings-v2.patch index 4fd3cfafb9..9abb77ffc0 100644 --- a/Spigot-API-Patches/Timings-v2.patch +++ b/Spigot-API-Patches/Timings-v2.patch @@ -3459,8 +3459,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader { private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")}; - private final Map> classes = new ConcurrentHashMap>(); private final List loaders = new CopyOnWriteArrayList(); + private final LibraryLoader libraryLoader; - public static final CustomTimingsHandler pluginParentTimer = new CustomTimingsHandler("** Plugins"); // Spigot /** diff --git a/Spigot-Server-Patches/Fix-sounds-when-item-frames-are-modified-MC-123450.patch b/Spigot-Server-Patches/Fix-sounds-when-item-frames-are-modified-MC-123450.patch index 699eecaed7..aac7b63a1a 100644 --- a/Spigot-Server-Patches/Fix-sounds-when-item-frames-are-modified-MC-123450.patch +++ b/Spigot-Server-Patches/Fix-sounds-when-item-frames-are-modified-MC-123450.patch @@ -18,16 +18,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.playSound(SoundEffects.ENTITY_ITEM_FRAME_ADD_ITEM, 1.0F, 1.0F); } -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java -@@ -0,0 +0,0 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { - old.die(); - - EntityItemFrame frame = new EntityItemFrame(world, position, direction); -- frame.setItem(item); -+ frame.setItem(item, true, false); // Paper - fix itemframe sound - world.addEntity(frame); - this.entity = frame; - } diff --git a/Spigot-Server-Patches/POM-Changes.patch b/Spigot-Server-Patches/POM-Changes.patch index 7d7ae35d19..d484f76ec2 100644 --- a/Spigot-Server-Patches/POM-Changes.patch +++ b/Spigot-Server-Patches/POM-Changes.patch @@ -58,17 +58,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - spigot-api + com.destroystokyo.paper + paper-api ++ ${project.version} ++ compile ++ ++ ++ com.destroystokyo.paper ++ paper-mojangapi ${project.version} compile - org.spigotmc -+ com.destroystokyo.paper -+ paper-mojangapi -+ ${project.version} -+ compile -+ -+ + io.papermc minecraft-server ${minecraft.version}-SNAPSHOT @@ -123,7 +123,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 8.0.23 runtime - + +@@ -0,0 +0,0 @@ + + org.apache.logging.log4j + log4j-slf4j-impl +- 2.8.1 ++ + compile + + @@ -0,0 +0,0 @@ @@ -219,7 +228,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat - + @@ -0,0 +0,0 @@ jline org.bukkit.craftbukkit.libs.jline diff --git a/work/Bukkit b/work/Bukkit index b9ef9229d4..146a7e4bd7 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit b9ef9229d4c10b4068d9fbdce8845cfd4a9f8fc5 +Subproject commit 146a7e4bd764990c56bb326643e92eb69f24d27e diff --git a/work/CraftBukkit b/work/CraftBukkit index 51e2981b5b..b1064c69c4 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 51e2981b5ba4910e93f87bbf95e111e78ad6f9f3 +Subproject commit b1064c69c444b9447a65ad36b6cff39d9e052263 diff --git a/work/Spigot b/work/Spigot index bd6b566898..9fb885e86d 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit bd6b56689828d8bb08f6b5f46935162f9cc43d87 +Subproject commit 9fb885e86def1d9d86e25233c9b5a4de45b7a09d