2024-12-11 22:26:55 +01:00
--- a/net/minecraft/server/gui/MinecraftServerGui.java
+++ b/net/minecraft/server/gui/MinecraftServerGui.java
2020-10-03 08:27:40 +02:00
@@ -59,6 +59,15 @@
jframe.pack();
jframe.setLocationRelativeTo((Component) null);
jframe.setVisible(true);
+ jframe.setName("Minecraft server"); // Paper - Improve ServerGUI
+
+ // Paper start - Improve ServerGUI
+ try {
+ jframe.setIconImage(javax.imageio.ImageIO.read(Objects.requireNonNull(MinecraftServerGui.class.getClassLoader().getResourceAsStream("logo.png"))));
+ } catch (java.io.IOException ignore) {
+ }
+ // Paper end - Improve ServerGUI
+
jframe.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowevent) {
if (!servergui.isClosing.getAndSet(true)) {
2024-03-10 20:10:41 +01:00
@@ -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 @@
2020-02-02 11:00:40 +01:00
2021-11-21 23:00:00 +01:00
private JComponent buildInfoPanel() {
2021-06-11 07:00:00 +02:00
JPanel jpanel = new JPanel(new BorderLayout());
2020-02-02 11:00:40 +01:00
- StatsComponent guistatscomponent = new StatsComponent(this.server);
2021-06-11 07:00:00 +02:00
- Collection collection = this.finalizers;
2020-02-02 11:00:40 +01:00
+ com.destroystokyo.paper.gui.GuiStatsComponent guistatscomponent = new com.destroystokyo.paper.gui.GuiStatsComponent(this.server); // Paper - Make GUI graph fancier
2021-06-11 07:00:00 +02:00
+ Collection<Runnable> collection = this.finalizers; // CraftBukkit - decompile error
Objects.requireNonNull(guistatscomponent);
2021-11-21 23:00:00 +01:00
collection.add(guistatscomponent::close);
2024-03-10 20:10:41 +01:00
@@ -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 @@
2024-04-23 17:15:00 +02:00
jtextfield.setText("");
});
- jtextarea.addFocusListener(new FocusAdapter(this) {
+ jtextarea.addFocusListener(new FocusAdapter() { // CraftBukkit - decompile error
public void focusGained(FocusEvent focusevent) {}
});
jpanel.add(jscrollpane, "Center");
2024-03-10 20:10:41 +01:00
@@ -166,6 +209,7 @@
2021-06-11 07:00:00 +02:00
this.finalizers.forEach(Runnable::run);
2020-01-21 23:33:40 +01:00
}
2017-06-09 19:03:43 +02:00
+ private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\e\\[[\\d;]*[^\\d;]"); // CraftBukkit // Paper
2024-12-11 22:26:55 +01:00
public void print(JTextArea textArea, JScrollPane scrollPane, String message) {
2020-01-21 23:33:40 +01:00
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(() -> {
2024-03-10 20:10:41 +01:00
@@ -181,7 +225,7 @@
2020-01-21 23:33:40 +01:00
}
try {
2024-12-11 22:26:55 +01:00
- document.insertString(document.getLength(), message, (AttributeSet) null);
+ document.insertString(document.getLength(), MinecraftServerGui.ANSI.matcher(message).replaceAll(""), (AttributeSet) null); // CraftBukkit
2020-01-21 23:33:40 +01:00
} catch (BadLocationException badlocationexception) {
;
}