config for startup commands

This commit is contained in:
granny
2025-01-12 18:07:25 -08:00
committed by granny
parent 194d9685b2
commit e0db368062
3 changed files with 29 additions and 49 deletions

View File

@@ -60,6 +60,23 @@
public final RollingAverage tps1 = new RollingAverage(60);
public final RollingAverage tps5 = new RollingAverage(60 * 5);
public final RollingAverage tps15 = new RollingAverage(60 * 15);
@@ -1197,6 +_,16 @@
}
// Paper end - Add onboarding message for initial server start
+ // Purpur start - config for startup commands
+ 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);
+ ((net.minecraft.server.dedicated.DedicatedServer) this).handleConsoleInput(startupCommand, this.createCommandSourceStack());
+ }
+ }
+ // Purpur end - config for startup commands
+
while (this.running) {
long l;
if (!this.isPaused() && this.tickRateManager.isSprinting() && this.tickRateManager.checkShouldSprintThisTick()) {
@@ -1221,14 +_,19 @@
if (++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0) {
final long diff = currentTime - tickSection;

View File

@@ -583,4 +583,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);
});
}
}