mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-22 10:57:43 +01:00
add config for startup commands
Inspired by Vintagestory's "StartupCommands" config option. (https://wiki.vintagestory.at/index.php/Setting_up_a_Multiplayer_Server#Acquiring_server_admin_rights)
This commit is contained in:
48
patches/server/0295-config-for-startup-commands.patch
Normal file
48
patches/server/0295-config-for-startup-commands.patch
Normal file
@@ -0,0 +1,48 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: granny <granny@purpurmc.org>
|
||||
Date: Sun, 5 May 2024 02:27:52 -0700
|
||||
Subject: [PATCH] config for startup commands
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index dfeae138e830e95ab823b6349a91160b02622208..21327a92b75a460c7beb3aa408502f37a7db31fa 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1188,6 +1188,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
// Paper end - Add onboarding message for initial server start
|
||||
|
||||
+ // Purpur start
|
||||
+ if (!Boolean.getBoolean("Purpur.IReallyDontWantStartupCommands") && !org.purpurmc.purpur.PurpurConfig.startupCommands.isEmpty()) {
|
||||
+ LOGGER.info("Purpur: Running startup commands specified in purpur.yml.");
|
||||
+ for (final String startupCommand : org.purpurmc.purpur.PurpurConfig.startupCommands) {
|
||||
+ LOGGER.info("Purpur: Running the following command: \"{}\"", startupCommand);
|
||||
+ ((DedicatedServer) this).handleConsoleInput(startupCommand, this.createCommandSourceStack());
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
while (this.running) {
|
||||
// Paper start - rewrite chunk system
|
||||
// guarantee that nothing can stop the server from halting if it can at least still tick
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
index a343ad765c2779e9c83bc037ec9e3a24b07b0115..de70bfdbdd7740fdf20dd063a7a623a9e96cef98 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -586,4 +586,16 @@ public class PurpurConfig {
|
||||
private static void registerMinecraftDebugCommands() {
|
||||
registerMinecraftDebugCommands = getBoolean("settings.register-minecraft-debug-commands", registerMinecraftDebugCommands);
|
||||
}
|
||||
+
|
||||
+ public static List<String> startupCommands = new ArrayList<>();
|
||||
+ private static void startupCommands() {
|
||||
+ startupCommands.clear();
|
||||
+ getList("settings.startup-commands", new ArrayList<String>()).forEach(line -> {
|
||||
+ String command = line.toString();
|
||||
+ if (command.startsWith("/")) {
|
||||
+ command = command.substring(1);
|
||||
+ }
|
||||
+ startupCommands.add(command);
|
||||
+ });
|
||||
+ }
|
||||
}
|
||||
Reference in New Issue
Block a user