mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
net.minecraft.server.gui
This commit is contained in:
parent
2a9bf40295
commit
68961d9f5e
2 changed files with 44 additions and 61 deletions
|
@ -1,44 +1,58 @@
|
||||||
--- a/net/minecraft/server/gui/MinecraftServerGui.java
|
--- a/net/minecraft/server/gui/MinecraftServerGui.java
|
||||||
+++ b/net/minecraft/server/gui/MinecraftServerGui.java
|
+++ b/net/minecraft/server/gui/MinecraftServerGui.java
|
||||||
@@ -59,6 +59,15 @@
|
@@ -53,6 +_,13 @@
|
||||||
jframe.pack();
|
jFrame.pack();
|
||||||
jframe.setLocationRelativeTo((Component) null);
|
jFrame.setLocationRelativeTo(null);
|
||||||
jframe.setVisible(true);
|
jFrame.setVisible(true);
|
||||||
+ jframe.setName("Minecraft server"); // Paper - Improve ServerGUI
|
|
||||||
+
|
|
||||||
+ // Paper start - Improve ServerGUI
|
+ // Paper start - Improve ServerGUI
|
||||||
|
+ jFrame.setName("Minecraft server");
|
||||||
+ try {
|
+ try {
|
||||||
+ jframe.setIconImage(javax.imageio.ImageIO.read(Objects.requireNonNull(MinecraftServerGui.class.getClassLoader().getResourceAsStream("logo.png"))));
|
+ jFrame.setIconImage(javax.imageio.ImageIO.read(java.util.Objects.requireNonNull(MinecraftServerGui.class.getClassLoader().getResourceAsStream("logo.png"))));
|
||||||
+ } catch (java.io.IOException ignore) {
|
+ } catch (java.io.IOException ignore) {
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Improve ServerGUI
|
+ // Paper end - Improve ServerGUI
|
||||||
+
|
jFrame.addWindowListener(new WindowAdapter() {
|
||||||
jframe.addWindowListener(new WindowAdapter() {
|
@Override
|
||||||
public void windowClosing(WindowEvent windowevent) {
|
public void windowClosing(WindowEvent event) {
|
||||||
if (!servergui.isClosing.getAndSet(true)) {
|
@@ -74,6 +_,7 @@
|
||||||
@@ -81,6 +90,7 @@
|
|
||||||
this.setLayout(new BorderLayout());
|
this.setLayout(new BorderLayout());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
+ this.add(this.buildOnboardingPanel(), "North"); // Paper - Add onboarding message for initial server start
|
+ this.add(this.buildOnboardingPanel(), "North"); // Paper - Add onboarding message for initial server start
|
||||||
this.add(this.buildChatPanel(), "Center");
|
this.add(this.buildChatPanel(), "Center");
|
||||||
this.add(this.buildInfoPanel(), "West");
|
this.add(this.buildInfoPanel(), "West");
|
||||||
} catch (Exception exception) {
|
} catch (Exception var3) {
|
||||||
@@ -95,8 +105,8 @@
|
@@ -87,7 +_,7 @@
|
||||||
|
|
||||||
private JComponent buildInfoPanel() {
|
private JComponent buildInfoPanel() {
|
||||||
JPanel jpanel = new JPanel(new BorderLayout());
|
JPanel jPanel = new JPanel(new BorderLayout());
|
||||||
- StatsComponent guistatscomponent = new StatsComponent(this.server);
|
- StatsComponent statsComponent = new StatsComponent(this.server);
|
||||||
- Collection collection = this.finalizers;
|
+ com.destroystokyo.paper.gui.GuiStatsComponent statsComponent = new com.destroystokyo.paper.gui.GuiStatsComponent(this.server); // Paper - Make GUI graph fancier
|
||||||
+ com.destroystokyo.paper.gui.GuiStatsComponent guistatscomponent = new com.destroystokyo.paper.gui.GuiStatsComponent(this.server); // Paper - Make GUI graph fancier
|
this.finalizers.add(statsComponent::close);
|
||||||
+ Collection<Runnable> collection = this.finalizers; // CraftBukkit - decompile error
|
jPanel.add(statsComponent, "North");
|
||||||
|
jPanel.add(this.buildPlayerPanel(), "Center");
|
||||||
Objects.requireNonNull(guistatscomponent);
|
@@ -150,6 +_,7 @@
|
||||||
collection.add(guistatscomponent::close);
|
this.finalizers.forEach(Runnable::run);
|
||||||
@@ -106,6 +116,39 @@
|
|
||||||
return jpanel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\e\\[[\\d;]*[^\\d;]"); // CraftBukkit // Paper
|
||||||
|
public void print(JTextArea textArea, JScrollPane scrollPane, String line) {
|
||||||
|
if (!SwingUtilities.isEventDispatchThread()) {
|
||||||
|
SwingUtilities.invokeLater(() -> this.print(textArea, scrollPane, line));
|
||||||
|
@@ -162,7 +_,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
- document.insertString(document.getLength(), line, null);
|
||||||
|
+ document.insertString(document.getLength(), MinecraftServerGui.ANSI.matcher(line).replaceAll(""), null); // CraftBukkit
|
||||||
|
} catch (BadLocationException var8) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -171,4 +_,37 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
+ // Paper start - Add onboarding message for initial server start
|
+ // Paper start - Add onboarding message for initial server start
|
||||||
+ private JComponent buildOnboardingPanel() {
|
+ private JComponent buildOnboardingPanel() {
|
||||||
+ String onboardingLink = "https://docs.papermc.io/paper/next-steps";
|
+ String onboardingLink = "https://docs.papermc.io/paper/next-steps";
|
||||||
|
@ -71,33 +85,4 @@
|
||||||
+ return jPanel;
|
+ return jPanel;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Add onboarding message for initial server start
|
+ // 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("");
|
|
||||||
});
|
|
||||||
- jtextarea.addFocusListener(new FocusAdapter(this) {
|
|
||||||
+ jtextarea.addFocusListener(new FocusAdapter() { // CraftBukkit - decompile error
|
|
||||||
public void focusGained(FocusEvent focusevent) {}
|
|
||||||
});
|
|
||||||
jpanel.add(jscrollpane, "Center");
|
|
||||||
@@ -166,6 +209,7 @@
|
|
||||||
this.finalizers.forEach(Runnable::run);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\e\\[[\\d;]*[^\\d;]"); // CraftBukkit // Paper
|
|
||||||
public void print(JTextArea textArea, JScrollPane scrollPane, String message) {
|
|
||||||
if (!SwingUtilities.isEventDispatchThread()) {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
@@ -181,7 +225,7 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
- document.insertString(document.getLength(), message, (AttributeSet) null);
|
|
||||||
+ document.insertString(document.getLength(), MinecraftServerGui.ANSI.matcher(message).replaceAll(""), (AttributeSet) null); // CraftBukkit
|
|
||||||
} catch (BadLocationException badlocationexception) {
|
|
||||||
;
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
--- a/net/minecraft/server/gui/StatsComponent.java
|
--- a/net/minecraft/server/gui/StatsComponent.java
|
||||||
+++ b/net/minecraft/server/gui/StatsComponent.java
|
+++ b/net/minecraft/server/gui/StatsComponent.java
|
||||||
@@ -34,10 +34,19 @@
|
@@ -34,8 +_,17 @@
|
||||||
|
|
||||||
private void tick() {
|
private void tick() {
|
||||||
long l = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
|
long l = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
|
||||||
|
@ -8,19 +8,17 @@
|
||||||
+ double[] tps = org.bukkit.Bukkit.getTPS();
|
+ double[] tps = org.bukkit.Bukkit.getTPS();
|
||||||
+ String[] tpsAvg = new String[tps.length];
|
+ String[] tpsAvg = new String[tps.length];
|
||||||
+
|
+
|
||||||
+ for ( int g = 0; g < tps.length; g++) {
|
+ for (int g = 0; g < tps.length; g++) {
|
||||||
+ tpsAvg[g] = format( tps[g] );
|
+ tpsAvg[g] = format(tps[g]);
|
||||||
+ }
|
+ }
|
||||||
this.msgs[0] = "Memory use: " + l / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)";
|
this.msgs[0] = "Memory use: " + l / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)";
|
||||||
this.msgs[1] = "Avg tick: "
|
this.msgs[1] = "Avg tick: " + DECIMAL_FORMAT.format((double)this.server.getAverageTickTimeNanos() / TimeUtil.NANOSECONDS_PER_MILLISECOND) + " ms";
|
||||||
+ DECIMAL_FORMAT.format((double)this.server.getAverageTickTimeNanos() / (double)TimeUtil.NANOSECONDS_PER_MILLISECOND)
|
|
||||||
+ " ms";
|
|
||||||
+ this.msgs[2] = "TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg);
|
+ this.msgs[2] = "TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg);
|
||||||
+ // Paper end - Improve ServerGUI
|
+ // Paper end - Improve ServerGUI
|
||||||
this.values[this.vp++ & 0xFF] = (int)(l * 100L / Runtime.getRuntime().maxMemory());
|
this.values[this.vp++ & 0xFF] = (int)(l * 100L / Runtime.getRuntime().maxMemory());
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
@@ -66,4 +75,10 @@
|
@@ -64,4 +_,10 @@
|
||||||
public void close() {
|
public void close() {
|
||||||
this.timer.stop();
|
this.timer.stop();
|
||||||
}
|
}
|
Loading…
Reference in a new issue