More more more more more more more more more more more more work
This commit is contained in:
parent
8f67d293a2
commit
4e81c1fe78
22 changed files with 46 additions and 45 deletions
|
@ -1,86 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Mon, 27 Apr 2020 12:31:59 +0200
|
||||
Subject: [PATCH] Prioritise own classes where possible
|
||||
|
||||
This adds the server property `Paper.DisableClassPrioritization` to disable
|
||||
prioritization of own classes for plugins' classloaders.
|
||||
|
||||
This value is by default not present, and this will therefore break any
|
||||
plugins which abuse behaviour related to not using their own classes
|
||||
while still loading their own. This is often an issue with failing to
|
||||
relocate or shade properly, such as when shading plugin APIs like Vault.
|
||||
|
||||
A plugin's classloader will first look in the same jar as it is loading
|
||||
in for a requested class, then load it. It does not re-use other
|
||||
plugins' classes if it has the chance to avoid doing so.
|
||||
|
||||
If a class is not found in the same jar as it is loading for and it does
|
||||
find it elsewhere, it will still choose the class elsewhere. This is
|
||||
intended behaviour, as it will only prioritise classes it has in its own
|
||||
jar, no other plugins' classes will be prioritised in any other order
|
||||
than the one they were registered in.
|
||||
|
||||
The patch in general terms just loads the class in the plugin's jar
|
||||
before it starts looking elsewhere for it.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
index dfa44d9a0f0e270fddc4f30b845c2b0e23008033..80236a0934861902db7f15571d0d9b4902e70045 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
@@ -51,6 +51,7 @@ import org.yaml.snakeyaml.error.YAMLException;
|
||||
*/
|
||||
public final class JavaPluginLoader implements PluginLoader {
|
||||
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, 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
|
||||
@@ -203,6 +204,11 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
|
||||
@Nullable
|
||||
Class<?> getClassByName(final String name, boolean resolve, PluginDescriptionFile description) {
|
||||
+ // Paper start - prioritize self
|
||||
+ return getClassByName(name, resolve, description, null);
|
||||
+ }
|
||||
+ Class<?> getClassByName(final String name, boolean resolve, PluginDescriptionFile description, PluginClassLoader requester) {
|
||||
+ // Paper end
|
||||
// Paper start - make MT safe
|
||||
java.util.concurrent.locks.ReentrantReadWriteLock lock;
|
||||
synchronized (classLoadLock) {
|
||||
@@ -210,6 +216,13 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
classLoadLockCount.compute(name, (x, prev) -> prev != null ? prev + 1 : 1);
|
||||
}
|
||||
lock.writeLock().lock();try {
|
||||
+ // Paper start - prioritize self
|
||||
+ if (!DISABLE_CLASS_PRIORITIZATION && requester != null) {
|
||||
+ try {
|
||||
+ return requester.loadClass0(name, false, false, ((SimplePluginManager) server.getPluginManager()).isTransitiveDepend(description, requester.getDescription()));
|
||||
+ } catch (ClassNotFoundException cnfe) {}
|
||||
+ }
|
||||
+ // 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 4fa5f7140ea97e1b6a63808b59115bfb1a85cb32..cd1907e8895ece9b780617635b71937596c0f982 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -33,7 +33,7 @@ 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;
|
||||
@@ -123,7 +123,7 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
|
||||
|
||||
if (checkGlobal) {
|
||||
// This ignores the libraries of other plugins, unless they are transitive dependencies.
|
||||
- Class<?> result = loader.getClassByName(name, resolve, description);
|
||||
+ Class<?> result = loader.getClassByName(name, resolve, description, this); // Paper - prioritize self
|
||||
|
||||
if (result != null) {
|
||||
// If the class was loaded from a library instead of a PluginClassLoader, we can assume that its associated plugin is a transitive dependency and can therefore skip this check.
|
|
@ -1,30 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sun, 31 May 2020 15:26:17 +0100
|
||||
Subject: [PATCH] Provide a useful PluginClassLoader#toString
|
||||
|
||||
There are several cases where the plugin classloader may be dumped to the logs,
|
||||
however, this provides no indication of the owner of the classloader, making
|
||||
these messages effectively useless, this patch rectifies this
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
index cd1907e8895ece9b780617635b71937596c0f982..9e14c95deaca0044a3e9284ceefbb2b5c54ede07 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -235,4 +235,16 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
|
||||
javaPlugin.logger = this.logger; // Paper - set logger
|
||||
javaPlugin.init(loader, loader.server, description, dataFolder, file, this);
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public String toString() {
|
||||
+ JavaPlugin currPlugin = plugin != null ? plugin : pluginInit;
|
||||
+ return "PluginClassLoader{" +
|
||||
+ "plugin=" + currPlugin +
|
||||
+ ", pluginEnabled=" + (currPlugin == null ? "uninitialized" : currPlugin.isEnabled()) +
|
||||
+ ", url=" + file +
|
||||
+ '}';
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Phoenix616 <mail@moep.tv>
|
||||
Date: Wed, 10 Jun 2020 23:55:16 +0100
|
||||
Subject: [PATCH] Inventory getHolder method without block snapshot
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/block/DoubleChest.java b/src/main/java/org/bukkit/block/DoubleChest.java
|
||||
index 83a4642119c3f33749e04c774cf2b39839f797e2..a39d2f1acbbd84ae0e2cf29f85594e09e55e9355 100644
|
||||
--- a/src/main/java/org/bukkit/block/DoubleChest.java
|
||||
+++ b/src/main/java/org/bukkit/block/DoubleChest.java
|
||||
@@ -34,6 +34,18 @@ public class DoubleChest implements InventoryHolder {
|
||||
return inventory.getRightSide().getHolder();
|
||||
}
|
||||
|
||||
+ // Paper start - getHolder without snapshot
|
||||
+ @Nullable
|
||||
+ public InventoryHolder getLeftSide(boolean useSnapshot) {
|
||||
+ return inventory.getLeftSide().getHolder(useSnapshot);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public InventoryHolder getRightSide(boolean useSnapshot) {
|
||||
+ return inventory.getRightSide().getHolder(useSnapshot);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return getInventory().getLocation();
|
||||
diff --git a/src/main/java/org/bukkit/inventory/Inventory.java b/src/main/java/org/bukkit/inventory/Inventory.java
|
||||
index 9c6a5bdac8c3ab682bbfae04ff24b76a62bc2883..6386206188e820206bb1a9f516b5e194fdc9d952 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/Inventory.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/Inventory.java
|
||||
@@ -384,6 +384,17 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
@Nullable
|
||||
public InventoryHolder getHolder();
|
||||
|
||||
+ // Paper start - getHolder without snapshot
|
||||
+ /**
|
||||
+ * Gets the block or entity belonging to the open inventory
|
||||
+ *
|
||||
+ * @param useSnapshot Create a snapshot if the holder is a tile entity
|
||||
+ * @return The holder of the inventory; null if it has no holder.
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public InventoryHolder getHolder(boolean useSnapshot);
|
||||
+ // Paper end
|
||||
+
|
||||
@NotNull
|
||||
@Override
|
||||
public ListIterator<ItemStack> iterator();
|
|
@ -1,25 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Nesaak <52047222+Nesaak@users.noreply.github.com>
|
||||
Date: Fri, 22 May 2020 13:35:21 -0400
|
||||
Subject: [PATCH] Expose Arrow getItemStack
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/AbstractArrow.java b/src/main/java/org/bukkit/entity/AbstractArrow.java
|
||||
index e8e56e89e32d84af0639fe2e9b0eeabd747b6007..b1d8007eed489aa061c1a6813bcdafc101231e56 100644
|
||||
--- a/src/main/java/org/bukkit/entity/AbstractArrow.java
|
||||
+++ b/src/main/java/org/bukkit/entity/AbstractArrow.java
|
||||
@@ -143,6 +143,14 @@ public interface AbstractArrow extends Projectile {
|
||||
}
|
||||
|
||||
// Paper start
|
||||
+ /**
|
||||
+ * Gets the ItemStack for this arrow.
|
||||
+ *
|
||||
+ * @return The ItemStack, as if a player picked up the arrow
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ org.bukkit.inventory.ItemStack getItemStack();
|
||||
+
|
||||
/**
|
||||
* Gets the {@link PickupRule} for this arrow.
|
||||
*
|
|
@ -1,96 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: LordKorea <lk97798@posteo.net>
|
||||
Date: Mon, 11 May 2020 22:38:10 -0400
|
||||
Subject: [PATCH] Add and implement PlayerRecipeBookClickEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7fa937d339ee98ad308deebb523fead6522eb262
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java
|
||||
@@ -0,0 +1,84 @@
|
||||
+package com.destroystokyo.paper.event.player;
|
||||
+
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a player clicks a recipe in the recipe book
|
||||
+ */
|
||||
+public class PlayerRecipeBookClickEvent extends PlayerEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancel = false;
|
||||
+ @NotNull private NamespacedKey recipe;
|
||||
+ private boolean makeAll;
|
||||
+
|
||||
+ public PlayerRecipeBookClickEvent(@NotNull Player player, @NotNull NamespacedKey recipe, boolean makeAll) {
|
||||
+ super(player);
|
||||
+ this.recipe = recipe;
|
||||
+ this.makeAll = makeAll;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the namespaced key of the recipe that was clicked by the player
|
||||
+ *
|
||||
+ * @return The namespaced key of the recipe
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public NamespacedKey getRecipe() {
|
||||
+ return recipe;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Changes what recipe is requested. This sets the requested recipe to the recipe with the given key
|
||||
+ *
|
||||
+ * @param recipe The key of the recipe that should be requested
|
||||
+ */
|
||||
+ public void setRecipe(@NotNull NamespacedKey recipe) {
|
||||
+ this.recipe = recipe;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets a boolean which indicates whether or not the player requested to make the maximum amount of results. This is
|
||||
+ * true if shift is pressed while the recipe is clicked in the recipe book
|
||||
+ *
|
||||
+ * @return {@code true} if shift is pressed while the recipe is clicked
|
||||
+ */
|
||||
+ public boolean isMakeAll() {
|
||||
+ return makeAll;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets whether or not the maximum amount of results should be made. If this is true, the request is handled as if
|
||||
+ * the player had pressed shift while clicking on the recipe
|
||||
+ *
|
||||
+ * @param makeAll {@code true} if the request should attempt to make the maximum amount of results
|
||||
+ */
|
||||
+ public void setMakeAll(boolean makeAll) {
|
||||
+ this.makeAll = makeAll;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancel = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
Loading…
Add table
Add a link
Reference in a new issue