patches
This commit is contained in:
parent
0050c2a090
commit
e208af9741
16 changed files with 53 additions and 67 deletions
|
@ -1,62 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 5 Apr 2020 22:22:58 -0500
|
||||
Subject: [PATCH] Add tick times API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index caa3d77b5906a2227f6409a877bd0ba14d05caba..411d06b14a0892531ac578e51d0b166f670adbd6 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -1720,6 +1720,25 @@ public final class Bukkit {
|
||||
public static double[] getTPS() {
|
||||
return server.getTPS();
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Get a sample of the servers last tick times (in nanos)
|
||||
+ *
|
||||
+ * @return A sample of the servers last tick times (in nanos)
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public static long[] getTickTimes() {
|
||||
+ return server.getTickTimes();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the average tick time (in millis)
|
||||
+ *
|
||||
+ * @return Average tick time (in millis)
|
||||
+ */
|
||||
+ public static double getAverageTickTime() {
|
||||
+ return server == null ? 0D : server.getAverageTickTime();
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index bf1920857008c272d557f602544009986c3ed284..1cabf4de832b60abae8c25c0d80d409e8fa727cc 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -1460,6 +1460,21 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
*/
|
||||
@NotNull
|
||||
public double[] getTPS();
|
||||
+
|
||||
+ /**
|
||||
+ * Get a sample of the servers last tick times (in nanos)
|
||||
+ *
|
||||
+ * @return A sample of the servers last tick times (in nanos)
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ long[] getTickTimes();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the average tick time (in millis)
|
||||
+ *
|
||||
+ * @return Average tick time (in millis)
|
||||
+ */
|
||||
+ double getAverageTickTime();
|
||||
// Paper end
|
||||
|
||||
// Paper start
|
|
@ -1,44 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: JRoy <joshroy126@gmail.com>
|
||||
Date: Fri, 10 Apr 2020 21:24:35 -0400
|
||||
Subject: [PATCH] Expose MinecraftServer#isRunning
|
||||
|
||||
This allows for plugins to detect if the server is actually turning off in onDisable rather than just plugins reloading.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 411d06b14a0892531ac578e51d0b166f670adbd6..796f72b1026371fff09e8ce60536d30609987449 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -1998,6 +1998,15 @@ public final class Bukkit {
|
||||
public static int getCurrentTick() {
|
||||
return server.getCurrentTick();
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if the server is in the process of being shutdown.
|
||||
+ *
|
||||
+ * @return true if server is in the process of being shutdown
|
||||
+ */
|
||||
+ public static boolean isStopping() {
|
||||
+ return server.isStopping();
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@NotNull
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 1cabf4de832b60abae8c25c0d80d409e8fa727cc..552b56995ffb0898ffd459e0175af57341f39f46 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -1754,5 +1754,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
* @return Current tick
|
||||
*/
|
||||
int getCurrentTick();
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if the server is in the process of being shutdown.
|
||||
+ *
|
||||
+ * @return true if server is in the process of being shutdown
|
||||
+ */
|
||||
+ boolean isStopping();
|
||||
// Paper end
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Thu, 30 Apr 2020 16:56:31 +0200
|
||||
Subject: [PATCH] Add Raw Byte ItemStack Serialization
|
||||
|
||||
Serializes using NBT which is safer for server data migrations than bukkits format.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index d6897f43a0692e031bed8a212d9a637ef548cc60..e348034288c74ab80360086d71f0b7f61551df24 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -97,5 +97,9 @@ public interface UnsafeValues {
|
||||
static boolean isLegacyPlugin(org.bukkit.plugin.Plugin plugin) {
|
||||
return !Bukkit.getUnsafe().isSupportedApiVersion(plugin.getDescription().getAPIVersion());
|
||||
}
|
||||
+
|
||||
+ byte[] serializeItem(ItemStack item);
|
||||
+
|
||||
+ ItemStack deserializeItem(byte[] data);
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index aacf8ea85909299355d16cad0386072ec542a70e..b80ef2e5c23764ee68f809268185492bf5577913 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -629,6 +629,30 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
|
||||
return Bukkit.getServer().getItemFactory().ensureServerConversions(this);
|
||||
}
|
||||
|
||||
+ /**
|
||||
+ * Deserializes this itemstack from raw NBT bytes. NBT is safer for data migrations as it will
|
||||
+ * use the built in data converter instead of bukkits dangerous serialization system.
|
||||
+ *
|
||||
+ * This expects that the DataVersion was stored on the root of the Compound, as saved from
|
||||
+ * the {@link #serializeAsBytes()} API returned.
|
||||
+ * @param bytes bytes representing an item in NBT
|
||||
+ * @return ItemStack migrated to this version of Minecraft if needed.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public static ItemStack deserializeBytes(@NotNull byte[] bytes) {
|
||||
+ return org.bukkit.Bukkit.getUnsafe().deserializeItem(bytes);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Serializes this itemstack to raw bytes in NBT. NBT is safer for data migrations as it will
|
||||
+ * use the built in data converter instead of bukkits dangerous serialization system.
|
||||
+ * @return bytes representing this item in NBT.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public byte[] serializeAsBytes() {
|
||||
+ return org.bukkit.Bukkit.getUnsafe().serializeItem(this);
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Gets the Display name as seen in the Client.
|
||||
* Currently the server only supports the English language. To override this,
|
|
@ -1,25 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 11 Apr 2020 21:38:59 -0400
|
||||
Subject: [PATCH] Disable Sync Events firing Async errors during shutdown
|
||||
|
||||
This is how it use to behave on Paper, and this is totally destroying
|
||||
the ability to try to shut the server down gracefully during the
|
||||
shutdown process as events firing on the watchdog thread are throwing
|
||||
errors.
|
||||
|
||||
This isn't an issue on Spigot
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
index a3027c1c6109bcb20d0468f6d0cd37182bb279ea..20b4ef7a94e00d9264b8ecc126ce5853b584ea8c 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
@@ -595,7 +595,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||
// Paper - replace callEvent by merging to below method
|
||||
if (event.isAsynchronous() && server.isPrimaryThread()) {
|
||||
throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
||||
- } else if (!event.isAsynchronous() && !server.isPrimaryThread()) {
|
||||
+ } else if (!event.isAsynchronous() && !server.isPrimaryThread() && !server.isStopping() ) {
|
||||
throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Trigary <trigary0@gmail.com>
|
||||
Date: Wed, 15 Apr 2020 01:24:55 -0400
|
||||
Subject: [PATCH] Make JavaPluginLoader thread-safe
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
index f26303315c9c93356f0b04440136855dd54d32b7..ce751577623eaad0f31e2eb7bf0842d1ab73e845 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
@@ -52,6 +52,8 @@ 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, 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;
|
||||
|
||||
@@ -201,12 +203,33 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
|
||||
@Nullable
|
||||
Class<?> getClassByName(final String name, boolean resolve, PluginDescriptionFile description) {
|
||||
+ // Paper start - make MT safe
|
||||
+ 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 {
|
||||
+ // Paper end
|
||||
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
|
||||
+ } finally {
|
||||
+ synchronized (classLoadLock) {
|
||||
+ lock.writeLock().unlock();
|
||||
+ if (classLoadLockCount.get(name) == 1) {
|
||||
+ classLoadLock.remove(name);
|
||||
+ classLoadLockCount.remove(name);
|
||||
+ } else {
|
||||
+ classLoadLockCount.compute(name, (x, prev) -> prev - 1);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue