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
This commit is contained in:
Jake Potrebic 2021-05-15 15:52:07 -07:00
parent b5488de2ba
commit 99f376a0f0
11 changed files with 58 additions and 62 deletions

View file

@ -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
+

View file

@ -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 {

View file

@ -27,4 +27,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
this.manifest = jar.getManifest();
this.url = file.toURI().toURL();
this.libraryLoader = libraryLoader;

View file

@ -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<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
+ private final Map<String, java.util.concurrent.locks.ReentrantReadWriteLock> classLoadLock = new java.util.HashMap<String, java.util.concurrent.locks.ReentrantReadWriteLock>(); // Paper
+ private final Map<String, Integer> classLoadLockCount = new java.util.HashMap<String, Integer>(); // Paper
private final List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>();
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

View file

@ -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<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
private final Map<String, java.util.concurrent.locks.ReentrantReadWriteLock> classLoadLock = new java.util.HashMap<String, java.util.concurrent.locks.ReentrantReadWriteLock>(); // Paper
private final Map<String, Integer> classLoadLockCount = new java.util.HashMap<String, Integer>(); // 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<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
- 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;

View file

@ -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<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
private final List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>();
private final LibraryLoader libraryLoader;
- public static final CustomTimingsHandler pluginParentTimer = new CustomTimingsHandler("** Plugins"); // Spigot
/**

View file

@ -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;
}

View file

@ -58,17 +58,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <artifactId>spigot-api</artifactId>
+ <groupId>com.destroystokyo.paper</groupId>
+ <artifactId>paper-api</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.destroystokyo.paper</groupId>
+ <artifactId>paper-mojangapi</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>org.spigotmc</groupId>
+ <groupId>com.destroystokyo.paper</groupId>
+ <artifactId>paper-mojangapi</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.papermc</groupId>
<artifactId>minecraft-server</artifactId>
<version>${minecraft.version}-SNAPSHOT</version>
@ -123,7 +123,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ <version>8.0.23</version>
<scope>runtime</scope>
</dependency>
<!-- testing -->
<!-- add these back in as they are not exposed by the API -->
@@ -0,0 +0,0 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
- <version>2.8.1</version>
+ <!--<version>2.8.1</version>--> <!--handled by bom-->
<scope>compile</scope>
<exclusions>
<!-- included in minecraft-server -->
@@ -0,0 +0,0 @@
<!-- This builds a completely 'ready to start' jar with all dependencies inside -->
@ -219,7 +228,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ <exclude>META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat</exclude>
</excludes>
</filter>
</filters>
<filter>
@@ -0,0 +0,0 @@
<pattern>jline</pattern>
<shadedPattern>org.bukkit.craftbukkit.libs.jline</shadedPattern>

@ -1 +1 @@
Subproject commit b9ef9229d4c10b4068d9fbdce8845cfd4a9f8fc5
Subproject commit 146a7e4bd764990c56bb326643e92eb69f24d27e

@ -1 +1 @@
Subproject commit 51e2981b5ba4910e93f87bbf95e111e78ad6f9f3
Subproject commit b1064c69c444b9447a65ad36b6cff39d9e052263

@ -1 +1 @@
Subproject commit bd6b56689828d8bb08f6b5f46935162f9cc43d87
Subproject commit 9fb885e86def1d9d86e25233c9b5a4de45b7a09d