mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 06:50:12 +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
|
||||
+++ b/net/minecraft/server/gui/MinecraftServerGui.java
|
||||
@@ -59,6 +59,15 @@
|
||||
jframe.pack();
|
||||
jframe.setLocationRelativeTo((Component) null);
|
||||
jframe.setVisible(true);
|
||||
+ jframe.setName("Minecraft server"); // Paper - Improve ServerGUI
|
||||
+
|
||||
@@ -53,6 +_,13 @@
|
||||
jFrame.pack();
|
||||
jFrame.setLocationRelativeTo(null);
|
||||
jFrame.setVisible(true);
|
||||
+ // Paper start - Improve ServerGUI
|
||||
+ jFrame.setName("Minecraft server");
|
||||
+ 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) {
|
||||
+ }
|
||||
+ // Paper end - Improve ServerGUI
|
||||
+
|
||||
jframe.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent windowevent) {
|
||||
if (!servergui.isClosing.getAndSet(true)) {
|
||||
@@ -81,6 +90,7 @@
|
||||
jFrame.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent event) {
|
||||
@@ -74,6 +_,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 @@
|
||||
} catch (Exception var3) {
|
||||
@@ -87,7 +_,7 @@
|
||||
|
||||
private JComponent buildInfoPanel() {
|
||||
JPanel jpanel = new JPanel(new BorderLayout());
|
||||
- StatsComponent guistatscomponent = new StatsComponent(this.server);
|
||||
- Collection collection = this.finalizers;
|
||||
+ com.destroystokyo.paper.gui.GuiStatsComponent guistatscomponent = new com.destroystokyo.paper.gui.GuiStatsComponent(this.server); // Paper - Make GUI graph fancier
|
||||
+ Collection<Runnable> collection = this.finalizers; // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(guistatscomponent);
|
||||
collection.add(guistatscomponent::close);
|
||||
@@ -106,6 +116,39 @@
|
||||
return jpanel;
|
||||
JPanel jPanel = new JPanel(new BorderLayout());
|
||||
- StatsComponent statsComponent = new StatsComponent(this.server);
|
||||
+ com.destroystokyo.paper.gui.GuiStatsComponent statsComponent = new com.destroystokyo.paper.gui.GuiStatsComponent(this.server); // Paper - Make GUI graph fancier
|
||||
this.finalizers.add(statsComponent::close);
|
||||
jPanel.add(statsComponent, "North");
|
||||
jPanel.add(this.buildPlayerPanel(), "Center");
|
||||
@@ -150,6 +_,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 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
|
||||
+ private JComponent buildOnboardingPanel() {
|
||||
+ String onboardingLink = "https://docs.papermc.io/paper/next-steps";
|
||||
|
@ -71,33 +85,4 @@
|
|||
+ 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("");
|
||||
});
|
||||
- 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
|
||||
+++ b/net/minecraft/server/gui/StatsComponent.java
|
||||
@@ -34,10 +34,19 @@
|
||||
@@ -34,8 +_,17 @@
|
||||
|
||||
private void tick() {
|
||||
long l = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
|
||||
|
@ -8,19 +8,17 @@
|
|||
+ double[] tps = org.bukkit.Bukkit.getTPS();
|
||||
+ String[] tpsAvg = new String[tps.length];
|
||||
+
|
||||
+ for ( int g = 0; g < tps.length; g++) {
|
||||
+ tpsAvg[g] = format( tps[g] );
|
||||
+ for (int g = 0; g < tps.length; 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[1] = "Avg tick: "
|
||||
+ DECIMAL_FORMAT.format((double)this.server.getAverageTickTimeNanos() / (double)TimeUtil.NANOSECONDS_PER_MILLISECOND)
|
||||
+ " ms";
|
||||
this.msgs[1] = "Avg tick: " + DECIMAL_FORMAT.format((double)this.server.getAverageTickTimeNanos() / TimeUtil.NANOSECONDS_PER_MILLISECOND) + " ms";
|
||||
+ this.msgs[2] = "TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg);
|
||||
+ // Paper end - Improve ServerGUI
|
||||
this.values[this.vp++ & 0xFF] = (int)(l * 100L / Runtime.getRuntime().maxMemory());
|
||||
this.repaint();
|
||||
}
|
||||
@@ -66,4 +75,10 @@
|
||||
@@ -64,4 +_,10 @@
|
||||
public void close() {
|
||||
this.timer.stop();
|
||||
}
|
Loading…
Reference in a new issue