From b5488de2ba1c4610cb967045396843960b76289a Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sat, 15 May 2021 22:10:57 +0100 Subject: [PATCH] Revert "Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5636)" This reverts commit 11c2ef5d2f33fe76c3eba0b68a03eac21f8102d6. --- ...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 | 35 ++++++++++--------- Spigot-API-Patches/Timings-v2.patch | 2 +- ...n-item-frames-are-modified-MC-123450.patch | 13 +++++++ Spigot-Server-Patches/POM-Changes.patch | 16 ++++----- work/Bukkit | 2 +- work/CraftBukkit | 2 +- work/Spigot | 2 +- 11 files changed, 62 insertions(+), 40 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 2406cc6426..b50ff2c515 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 3775343b68..641a99917b 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 { - } catch (IOException ex) { - // + for (String name : names) { + removeClass(name); } + // 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 97b4c61f4f..178e39bf6c 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 33c26d2809..0a359dec90 100644 --- a/Spigot-API-Patches/Make-JavaPluginLoader-thread-safe.patch +++ b/Spigot-API-Patches/Make-JavaPluginLoader-thread-safe.patch @@ -8,31 +8,37 @@ 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 @@ import org.yaml.snakeyaml.error.YAMLException; - public final class JavaPluginLoader implements PluginLoader { +@@ -0,0 +0,0 @@ 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, boolean resolve, PluginDescriptionFile description) { + Class getClassByName(final String name) { + // 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 - for (PluginClassLoader loader : loaders) { - try { - return loader.loadClass0(name, resolve, false, ((SimplePluginManager) server.getPluginManager()).isTransitiveDepend(description, loader.plugin.getDescription())); - } catch (ClassNotFoundException cnfe) { + + if (cachedClass != null) { + return cachedClass; +@@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader { + } } } + // 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 8ae117f9c1..44177329cd 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, boolean resolve, PluginDescriptionFile description) { + Class getClassByName(final String name) { + // Paper start - prioritize self -+ return getClassByName(name, resolve, description, null); ++ return getClassByName(name, null); + } -+ Class getClassByName(final String name, boolean resolve, PluginDescriptionFile description, PluginClassLoader requester) { ++ Class getClassByName(final String name, PluginClassLoader requester) { + // Paper end // Paper start - make MT safe - java.util.concurrent.locks.ReentrantReadWriteLock lock; - synchronized (classLoadLock) { + Class cachedClass = classes.get(name); + if (cachedClass != null) { @@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader { classLoadLockCount.compute(name, (x, prev) -> prev != null ? prev + 1 : 1); } @@ -55,23 +55,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - prioritize self + if (!DISABLE_CLASS_PRIORITIZATION && requester != null) { + try { -+ return requester.loadClass0(name, false, false, ((SimplePluginManager) server.getPluginManager()).isTransitiveDepend(description, requester.plugin.getDescription())); ++ cachedClass = requester.findClass(name, false); + } catch (ClassNotFoundException cnfe) {} ++ if (cachedClass != null) { ++ return cachedClass; ++ } + } -+ // Paper end ++ // Paper end- + cachedClass = classes.get(name); // 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 - } - if (checkGlobal) { -- Class result = loader.getClassByName(name, resolve, description); -+ Class result = loader.getClassByName(name, resolve, description, this); // Paper - prioritize self + if (result == null) { + if (checkGlobal) { +- result = loader.getClassByName(name); ++ result = loader.getClassByName(name, 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 9abb77ffc0..4fd3cfafb9 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 aac7b63a1a..699eecaed7 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,3 +18,16 @@ 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 5818b556f9..7d7ae35d19 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,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 8.0.23 runtime - + @@ -0,0 +0,0 @@ @@ -219,7 +219,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 146a7e4bd7..b9ef9229d4 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 146a7e4bd764990c56bb326643e92eb69f24d27e +Subproject commit b9ef9229d4c10b4068d9fbdce8845cfd4a9f8fc5 diff --git a/work/CraftBukkit b/work/CraftBukkit index b1064c69c4..51e2981b5b 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit b1064c69c444b9447a65ad36b6cff39d9e052263 +Subproject commit 51e2981b5ba4910e93f87bbf95e111e78ad6f9f3 diff --git a/work/Spigot b/work/Spigot index 9fb885e86d..bd6b566898 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit 9fb885e86def1d9d86e25233c9b5a4de45b7a09d +Subproject commit bd6b56689828d8bb08f6b5f46935162f9cc43d87