mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
config for startup commands
This commit is contained in:
@@ -1,49 +0,0 @@
|
|||||||
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/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
|
||||||
index 1dc4476ca1fc41030001d4d23ffff1b810a056cd..115069f2bce9b7742d8d3fbf181a47cacf8b0046 100644
|
|
||||||
--- a/net/minecraft/server/MinecraftServer.java
|
|
||||||
+++ b/net/minecraft/server/MinecraftServer.java
|
|
||||||
@@ -1293,6 +1293,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Purpur end
|
|
||||||
+
|
|
||||||
+ // 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) {
|
|
||||||
long i;
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
||||||
index 2d76827f83638c7f6bfa0d45bf950e18df22063e..66953d206d59c6e8ef3f925aca7451d57f98b81a 100644
|
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
||||||
@@ -587,4 +587,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);
|
|
||||||
+ });
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
@@ -60,6 +60,23 @@
|
|||||||
public final RollingAverage tps1 = new RollingAverage(60);
|
public final RollingAverage tps1 = new RollingAverage(60);
|
||||||
public final RollingAverage tps5 = new RollingAverage(60 * 5);
|
public final RollingAverage tps5 = new RollingAverage(60 * 5);
|
||||||
public final RollingAverage tps15 = new RollingAverage(60 * 15);
|
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 @@
|
@@ -1221,14 +_,19 @@
|
||||||
if (++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0) {
|
if (++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0) {
|
||||||
final long diff = currentTime - tickSection;
|
final long diff = currentTime - tickSection;
|
||||||
|
|||||||
@@ -583,4 +583,16 @@ public class PurpurConfig {
|
|||||||
private static void registerMinecraftDebugCommands() {
|
private static void registerMinecraftDebugCommands() {
|
||||||
registerMinecraftDebugCommands = getBoolean("settings.register-minecraft-debug-commands", 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