From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: leguan 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 c01b4393439838976965823298f12e4762e72eff..218bf89fd7583d6db9f64754c4db8fcce5415bdb 100644 --- a/src/main/java/io/papermc/paper/configuration/Configurations.java +++ b/src/main/java/io/papermc/paper/configuration/Configurations.java @@ -126,6 +126,7 @@ public abstract class Configurations { 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 0b283171294eca65a898ddd9ab1b7295ad183b0d..481cfe3a291196c0391c2ec8560e566e0e1e2fb8 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -25,6 +25,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): 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 1d8c63a5a0b05340396a9f7ba079eb7fceda03e2..325ba58a1c79fd928ac22d8f1ef93605357300d2 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1132,6 +1132,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop " + onboardingLink + ""); + 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);