Add onboarding message for initial server start

This commit is contained in:
leguan
2024-03-10 20:10:41 +01:00
parent e06fe76018
commit 046fc5171f
4 changed files with 112 additions and 54 deletions

View File

@@ -16,7 +16,15 @@
jframe.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowevent) {
if (!servergui.isClosing.getAndSet(true)) {
@@ -95,8 +104,8 @@
@@ -81,6 +90,7 @@
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) {
@@ -95,8 +105,8 @@
private JComponent buildInfoPanel() {
JPanel jpanel = new JPanel(new BorderLayout());
@@ -27,7 +35,47 @@
Objects.requireNonNull(guistatscomponent);
collection.add(guistatscomponent::close);
@@ -132,7 +141,7 @@
@@ -106,6 +116,39 @@
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);
@@ -132,7 +175,7 @@
jtextfield.setText("");
});
@@ -36,7 +84,7 @@
public void focusGained(FocusEvent focusevent) {}
});
jpanel.add(jscrollpane, "Center");
@@ -166,6 +175,7 @@
@@ -166,6 +209,7 @@
this.finalizers.forEach(Runnable::run);
}
@@ -44,7 +92,7 @@
public void print(JTextArea textArea, JScrollPane scrollPane, String message) {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(() -> {
@@ -181,7 +191,7 @@
@@ -181,7 +225,7 @@
}
try {