geforkt von Mirrors/Paper
Merge remote-tracking branch 'upstream/master' into 1.21.1-update
Dieser Commit ist enthalten in:
Commit
48f80425f0
22
patches/api/0498-API-to-check-if-the-server-is-sleeping.patch
Normale Datei
22
patches/api/0498-API-to-check-if-the-server-is-sleeping.patch
Normale Datei
@ -0,0 +1,22 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Abel <abelvanhulst@gmail.com>
|
||||
Date: Sun, 10 Nov 2024 16:32:51 +0100
|
||||
Subject: [PATCH] API to check if the server is sleeping
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 0b78564256ebc647ebac402e549d86ab6e307c8d..ba366576a571214e67bcc529dc1bca19e1d59ef8 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2572,4 +2572,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
*/
|
||||
boolean isOwnedByCurrentRegion(@NotNull Entity entity);
|
||||
// Paper end - Folia region threading API
|
||||
+
|
||||
+ // Paper start - API to check if the server is sleeping
|
||||
+ /**
|
||||
+ * Returns whether the server is sleeping/paused.
|
||||
+ */
|
||||
+ boolean isPaused();
|
||||
+ // Paper end - API to check if the server is sleeping
|
||||
}
|
25
patches/api/0499-API-to-allow-disallow-tick-sleeping.patch
Normale Datei
25
patches/api/0499-API-to-allow-disallow-tick-sleeping.patch
Normale Datei
@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Abel <abelvanhulst@gmail.com>
|
||||
Date: Tue, 12 Nov 2024 22:25:35 +0100
|
||||
Subject: [PATCH] API to allow/disallow tick sleeping
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index ba366576a571214e67bcc529dc1bca19e1d59ef8..f55638eb8b315864052f9fe17ab4846e5e9d8dbb 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2578,5 +2578,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
* Returns whether the server is sleeping/paused.
|
||||
*/
|
||||
boolean isPaused();
|
||||
+
|
||||
+ /**
|
||||
+ * Allows or disallows the server to sleep/pause.
|
||||
+ * If any plugin disallows pausing, the server will never pause.
|
||||
+ *
|
||||
+ * @param plugin The {@link org.bukkit.plugin.Plugin} that's allowing or disallowing pausing.
|
||||
+ * @param value Whether to allow sleeping of the server (defaults to true).
|
||||
+ */
|
||||
+ void allowPausing(@NotNull org.bukkit.plugin.Plugin plugin, boolean value);
|
||||
// Paper end - API to check if the server is sleeping
|
||||
}
|
37
patches/server/1068-API-to-check-if-the-server-is-sleeping.patch
Normale Datei
37
patches/server/1068-API-to-check-if-the-server-is-sleeping.patch
Normale Datei
@ -0,0 +1,37 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Abel <abelvanhulst@gmail.com>
|
||||
Date: Sun, 10 Nov 2024 16:32:34 +0100
|
||||
Subject: [PATCH] API to check if the server is sleeping
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 64b56abf8900d0424100da460fc68ac964394793..5d070f036dae6d93f863c55192b557419634456d 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -3186,4 +3186,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
}
|
||||
// Paper end - Add tick times API and /mspt command
|
||||
+
|
||||
+ // Paper start - API to check if the server is sleeping
|
||||
+ public boolean isTickPaused() {
|
||||
+ return this.emptyTicks > 0 && this.emptyTicks >= this.pauseWhileEmptySeconds() * 20;
|
||||
+ }
|
||||
+ // Paper end - API to check if the server is sleeping
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 806e56cb60235a99f468d36a059fdbd54c2d46e3..605662917a7720a6c5134fd1d93aa2d26116b76d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -3246,4 +3246,11 @@ public final class CraftServer implements Server {
|
||||
return this.potionBrewer;
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+ // Paper start - API to check if the server is sleeping
|
||||
+ @Override
|
||||
+ public boolean isPaused() {
|
||||
+ return this.console.isTickPaused();
|
||||
+ }
|
||||
+ // Paper end - API to check if the server is sleeping
|
||||
}
|
67
patches/server/1069-API-to-allow-disallow-tick-sleeping.patch
Normale Datei
67
patches/server/1069-API-to-allow-disallow-tick-sleeping.patch
Normale Datei
@ -0,0 +1,67 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Abel <abelvanhulst@gmail.com>
|
||||
Date: Tue, 12 Nov 2024 22:25:20 +0100
|
||||
Subject: [PATCH] API to allow/disallow tick sleeping
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 5d070f036dae6d93f863c55192b557419634456d..663b4ecd520e82aa108d44f2d5c2a20cfc7bc01f 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -332,6 +332,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public volatile Thread shutdownThread; // Paper
|
||||
public volatile boolean abnormalExit = false; // Paper
|
||||
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
||||
+ private List<String> pluginsBlockingSleep = new ArrayList<>(); // Paper - API to allow/disallow tick sleeping
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
@@ -1623,8 +1624,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
long i = Util.getNanos();
|
||||
int j = this.pauseWhileEmptySeconds() * 20;
|
||||
|
||||
+ this.removeDisabledPluginsBlockingSleep(); // Paper - API to allow/disallow tick sleeping
|
||||
if (j > 0) {
|
||||
- if (this.playerList.getPlayerCount() == 0 && !this.tickRateManager.isSprinting()) {
|
||||
+ if (this.playerList.getPlayerCount() == 0 && !this.tickRateManager.isSprinting() && this.pluginsBlockingSleep.isEmpty()) { // Paper - API to allow/disallow tick sleeping
|
||||
++this.emptyTicks;
|
||||
} else {
|
||||
this.emptyTicks = 0;
|
||||
@@ -3191,5 +3193,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public boolean isTickPaused() {
|
||||
return this.emptyTicks > 0 && this.emptyTicks >= this.pauseWhileEmptySeconds() * 20;
|
||||
}
|
||||
+
|
||||
+ public void addPluginAllowingSleep(final String pluginName, final boolean value) {
|
||||
+ if (!value) {
|
||||
+ this.pluginsBlockingSleep.add(pluginName);
|
||||
+ } else {
|
||||
+ this.pluginsBlockingSleep.remove(pluginName);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void removeDisabledPluginsBlockingSleep() {
|
||||
+ if (this.pluginsBlockingSleep.isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ this.pluginsBlockingSleep.removeIf(plugin -> (
|
||||
+ !io.papermc.paper.plugin.manager.PaperPluginManagerImpl.getInstance().isPluginEnabled(plugin)
|
||||
+ ));
|
||||
+ }
|
||||
// Paper end - API to check if the server is sleeping
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 605662917a7720a6c5134fd1d93aa2d26116b76d..cac8592e3a2f438fe9ca167a4fdcd65152bbb2de 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -3252,5 +3252,10 @@ public final class CraftServer implements Server {
|
||||
public boolean isPaused() {
|
||||
return this.console.isTickPaused();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public void allowPausing(final Plugin plugin, final boolean value) {
|
||||
+ this.console.addPluginAllowingSleep(plugin.getName(), value);
|
||||
+ }
|
||||
// Paper end - API to check if the server is sleeping
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren