Add isReloading

This commit is contained in:
Tamion 2023-11-26 09:06:27 +01:00
parent e7e286e115
commit dc0fe830c0
No known key found for this signature in database
GPG Key ID: 01E616386DBAE296
2 changed files with 96 additions and 2 deletions

View File

@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tamion <70228790+notTamion@users.noreply.github.com>
Date: Sun, 26 Nov 2023 09:02:09 +0100
Subject: [PATCH] Add required-plugins config option
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 884902cb7f86c0b56594ccafc7d05c6c7a23ab53..2f1249ece0f5d6b5476f31e61a1c03155a3be2c3 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -985,6 +985,15 @@ public final class Bukkit {
public static @Nullable ItemStack createExplorerMap(@NotNull World world, @NotNull Location location, @NotNull org.bukkit.generator.structure.StructureType structureType, @NotNull org.bukkit.map.MapCursor.Type mapIcon, int radius, boolean findUnexplored) {
return server.createExplorerMap(world, location, structureType, mapIcon, radius, findUnexplored);
}
+
+ /**
+ * Checks if the Server is currently Reloading
+ *
+ * @return if the Server is Reloading
+ */
+ public static boolean isReloading() {
+ return server.isReloading();
+ }
// Paper end
/**
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index d0c634629aa0b6bac0da93655dd86ad3aea0ce30..90497df99691d3e42fceaab4685db9971f77e44d 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -839,6 +839,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* org.bukkit.generator.structure.StructureType, int, boolean)
*/
@Nullable ItemStack createExplorerMap(@NotNull World world, @NotNull Location location, @NotNull org.bukkit.generator.structure.StructureType structureType, @NotNull org.bukkit.map.MapCursor.Type mapIcon, int radius, boolean findUnexplored);
+
+ /**
+ * Checks if the Server is currently Reloading
+ *
+ * @return if the Server is Reloading
+ */
+ boolean isReloading();
// Paper end
/**

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add required-plugins config option
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java
index 9c7552968b8c017c71a7a77557a66a03ed89f125..688812294909ea0cdaeb10aac88bc74287ed4294 100644
index 9c7552968b8c017c71a7a77557a66a03ed89f125..20bf5892408dbd94417f48ae069ecbae7709c43f 100644
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java
@@ -210,6 +210,13 @@ class PaperPluginInstanceManager {
@ -13,7 +13,7 @@ index 9c7552968b8c017c71a7a77557a66a03ed89f125..688812294909ea0cdaeb10aac88bc742
throw new IllegalArgumentException("Only expects java plugins.");
}
+ // Paper start
+ if (!this.server.isStopping() && org.spigotmc.WatchdogThread.hasStarted && io.papermc.paper.configuration.GlobalConfiguration.get().misc.requiredPlugins.contains(plugin.getName())) {
+ if (!this.server.isStopping() && !this.server.isReloading() && io.papermc.paper.configuration.GlobalConfiguration.get().misc.requiredPlugins.contains(plugin.getName())) {
+ this.server.getLogger().severe("The required Plugin " + plugin.getName() + " got disabled. Stopping Server.");
+ this.server.shutdown();
+ return;
@ -40,3 +40,53 @@ index 1c9742ad81f04052d2c3bc18c7636f45b2fc5160..beab25cd9ed84135547db62d52636d7e
boolean usingProxy = org.spigotmc.SpigotConfig.bungee || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled;
String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord";
String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/";
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 9c08303de2891de92e06de8a939a618b7a6f7321..c836ce5d111e4a520b0b03b56aa72eee72fdcbab 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -304,6 +304,7 @@ public final class CraftServer implements Server {
private boolean overrideAllCommandBlockCommands = false;
public boolean ignoreVanillaPermissions = false;
private final List<CraftPlayer> playerView;
+ public boolean isReloading; // Paper
public int reloadCount;
private final io.papermc.paper.datapack.PaperDatapackManager datapackManager; // Paper
public static Exception excessiveVelEx; // Paper - Velocity warnings
@@ -1009,7 +1010,10 @@ public final class CraftServer implements Server {
@Override
public void reload() {
- org.spigotmc.WatchdogThread.hasStarted = false; // Paper - Disable watchdog early timeout on reload
+ // Paper start
+ this.isReloading = true;
+ org.spigotmc.WatchdogThread.hasStarted = false; // Disable watchdog early timeout on reload
+ // Paper end
this.reloadCount++;
this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile());
this.commandsConfiguration = YamlConfiguration.loadConfiguration(this.getCommandsConfigFile());
@@ -1100,10 +1104,11 @@ public final class CraftServer implements Server {
this.enablePlugins(PluginLoadOrder.STARTUP);
this.enablePlugins(PluginLoadOrder.POSTWORLD);
this.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.RELOAD));
- org.spigotmc.WatchdogThread.hasStarted = true; // Paper - Disable watchdog early timeout on reload
+ // Paper start
+ org.spigotmc.WatchdogThread.hasStarted = true; // Disable watchdog early timeout on reload
+ this.isReloading = false;
}
- // Paper start
public void waitForAsyncTasksShutdown() {
int pollCount = 0;
@@ -1957,6 +1962,11 @@ public final class CraftServer implements Server {
return CraftItemStack.asBukkitCopy(stack);
}
+
+ @Override
+ public boolean isReloading() {
+ return this.isReloading;
+ }
// Paper end
@Override