3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/server/0938-Add-onboarding-message-for-initial-server-start.patch
Bjarne Koll c5a10665b8
Remove wall-time / unused skip tick protection (#11412)
Spigot still maintains some partial implementation of "tick skipping", a
practice in which the MinecraftServer.currentTick field is updated not
by an increment of one per actual tick, but instead set to
System.currentTimeMillis() / 50. This behaviour means that the tracked
tick may "skip" a tick value in case a previous tick took more than the
expected 50ms.

To compensate for this in important paths, spigot/craftbukkit
implements "wall-time". Instead of incrementing/decrementing ticks on
block entities/entities by one for each call to their tick() method,
they instead increment/decrement important values, like
an ItemEntity's age or pickupDelay, by the difference of
`currentTick - lastTick`, where `lastTick` is the value of
`currentTick` during the last tick() call.

These "fixes" however do not play nicely with minecraft's simulation
distance as entities/block entities implementing the above behaviour
would "catch up" their values when moving from a non-ticking chunk to a
ticking one as their `lastTick` value remains stuck on the last tick in
a ticking chunk and hence lead to a large "catch up" once ticked again.

Paper completely removes the "tick skipping" behaviour (See patch
"Further-improve-server-tick-loop"), making the above precautions
completely unnecessary, which also rids paper of the previous described
incompatibility with non-ticking chunks.
2024-09-19 16:36:07 +02:00

104 Zeilen
6.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: leguan <longboard.noah@gmail.com>
Date: Sun, 10 Mar 2024 20:10:41 +0100
Subject: [PATCH] Add onboarding message for initial server start
diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java
index d9502ba028a96f9cc846f9ed428bd8066b857ca3..87e5f614ba988547a827486740db217e28585773 100644
--- a/src/main/java/io/papermc/paper/configuration/Configurations.java
+++ b/src/main/java/io/papermc/paper/configuration/Configurations.java
@@ -129,6 +129,7 @@ public abstract class Configurations<G, W> {
if (Files.notExists(configFile)) {
node = CommentedConfigurationNode.root(loader.defaultOptions());
node.node(Configuration.VERSION_FIELD).raw(this.globalConfigVersion());
+ GlobalConfiguration.isFirstStart = true;
} else {
node = loader.load();
this.verifyGlobalConfigVersion(node);
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
index 917bd0c1dd8f356edc3741ee59d24e4d090af182..f19b4a17a7e22969f7b51d3bea4056b41ab25484 100644
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
@@ -27,6 +27,7 @@ public class GlobalConfiguration extends ConfigurationPart {
private static final Logger LOGGER = LogUtils.getLogger();
static final int CURRENT_VERSION = 29; // (when you change the version, change the comment, so it conflicts on rebases): <insert changes here>
private static GlobalConfiguration instance;
+ public static boolean isFirstStart = false;
public static GlobalConfiguration get() {
return instance;
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 3ee0e2adf576e312c18da90adc46160ad85179fb..42a74f5471da882d63c194b1e212f78a94b103ec 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1135,6 +1135,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
long tickSection = Util.getNanos();
long currentTime;
// Paper end - further improve server tick loop
+ // Paper start - Add onboarding message for initial server start
+ if (io.papermc.paper.configuration.GlobalConfiguration.isFirstStart) {
+ LOGGER.info("*************************************************************************************");
+ LOGGER.info("This is the first time you're starting this server.");
+ LOGGER.info("It's recommended you read our 'Getting Started' documentation for guidance.");
+ LOGGER.info("View this and more helpful information here: https://docs.papermc.io/paper/next-steps");
+ LOGGER.info("*************************************************************************************");
+ }
+ // Paper end - Add onboarding message for initial server start
+
while (this.running) {
long i;
diff --git a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
index 4d3fe4f56e0b264fa030409919caf52d5f421d46..759062d219ff490a3cb19e710c4d18e3e08288e0 100644
--- a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
+++ b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
@@ -90,6 +90,7 @@ public class MinecraftServerGui extends JComponent {
this.setLayout(new BorderLayout());
try {
+ this.add(this.buildOnboardingPanel(), "North"); // Paper - Add onboarding message for initial server start
this.add(this.buildChatPanel(), "Center");
this.add(this.buildInfoPanel(), "West");
} catch (Exception exception) {
@@ -115,6 +116,39 @@ public class MinecraftServerGui extends JComponent {
return jpanel;
}
+ // Paper start - Add onboarding message for initial server start
+ private JComponent buildOnboardingPanel() {
+ String onboardingLink = "https://docs.papermc.io/paper/next-steps";
+ JPanel jPanel = new JPanel();
+
+ javax.swing.JLabel jLabel = new javax.swing.JLabel("If you need help setting up your server you can visit:");
+ jLabel.setFont(MinecraftServerGui.MONOSPACED);
+
+ javax.swing.JLabel link = new javax.swing.JLabel("<html><u> " + onboardingLink + "</u></html>");
+ link.setFont(MinecraftServerGui.MONOSPACED);
+ link.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
+ link.addMouseListener(new java.awt.event.MouseAdapter() {
+ @Override
+ public void mouseClicked(final java.awt.event.MouseEvent e) {
+ try {
+ java.awt.Desktop.getDesktop().browse(java.net.URI.create(onboardingLink));
+ } catch (java.io.IOException exception) {
+ LOGGER.error("Unable to find a default browser. Please manually visit the website: " + onboardingLink, exception);
+ } catch (UnsupportedOperationException exception) {
+ LOGGER.error("This platform does not support the BROWSE action. Please manually visit the website: " + onboardingLink, exception);
+ } catch (SecurityException exception) {
+ LOGGER.error("This action has been denied by the security manager. Please manually visit the website: " + onboardingLink, exception);
+ }
+ }
+ });
+
+ jPanel.add(jLabel);
+ jPanel.add(link);
+
+ return jPanel;
+ }
+ // Paper end - Add onboarding message for initial server start
+
private JComponent buildPlayerPanel() {
JList<?> jlist = new PlayerListComponent(this.server);
JScrollPane jscrollpane = new JScrollPane(jlist, 22, 30);