aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/server/gui/MinecraftServerGui.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/gui/MinecraftServerGui.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/server/gui/MinecraftServerGui.java.patch240
1 files changed, 240 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/gui/MinecraftServerGui.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/gui/MinecraftServerGui.java.patch
new file mode 100644
index 0000000000..e176bc1c0d
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/server/gui/MinecraftServerGui.java.patch
@@ -0,0 +1,240 @@
+--- a/net/minecraft/server/gui/MinecraftServerGui.java
++++ b/net/minecraft/server/gui/MinecraftServerGui.java
+@@ -4,14 +4,15 @@
+ import com.mojang.logging.LogQueues;
+ import com.mojang.logging.LogUtils;
+ import java.awt.BorderLayout;
++import java.awt.Component;
+ import java.awt.Dimension;
+ import java.awt.Font;
+-import java.awt.event.ActionEvent;
+ import java.awt.event.FocusAdapter;
+ import java.awt.event.FocusEvent;
+ import java.awt.event.WindowAdapter;
+ import java.awt.event.WindowEvent;
+ import java.util.Collection;
++import java.util.Objects;
+ import java.util.concurrent.atomic.AtomicBoolean;
+ import javax.swing.JComponent;
+ import javax.swing.JFrame;
+@@ -25,6 +26,7 @@
+ import javax.swing.UIManager;
+ import javax.swing.border.EtchedBorder;
+ import javax.swing.border.TitledBorder;
++import javax.swing.text.AttributeSet;
+ import javax.swing.text.BadLocationException;
+ import javax.swing.text.Document;
+ import net.minecraft.DefaultUncaughtExceptionHandler;
+@@ -32,6 +34,7 @@
+ import org.slf4j.Logger;
+
+ public class MinecraftServerGui extends JComponent {
++
+ private static final Font MONOSPACED = new Font("Monospaced", 0, 12);
+ private static final Logger LOGGER = LogUtils.getLogger();
+ private static final String TITLE = "Minecraft server";
+@@ -44,29 +47,32 @@
+ public static MinecraftServerGui showFrameFor(final DedicatedServer server) {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+- } catch (Exception var3) {
++ } catch (Exception exception) {
++ ;
+ }
+
+- final JFrame jFrame = new JFrame("Minecraft server");
+- final MinecraftServerGui minecraftServerGui = new MinecraftServerGui(server);
+- jFrame.setDefaultCloseOperation(2);
+- jFrame.add(minecraftServerGui);
+- jFrame.pack();
+- jFrame.setLocationRelativeTo(null);
+- jFrame.setVisible(true);
+- jFrame.addWindowListener(new WindowAdapter() {
+- @Override
+- public void windowClosing(WindowEvent event) {
+- if (!minecraftServerGui.isClosing.getAndSet(true)) {
+- jFrame.setTitle("Minecraft server - shutting down!");
++ final JFrame jframe = new JFrame("Minecraft server");
++ final MinecraftServerGui servergui = new MinecraftServerGui(server);
++
++ jframe.setDefaultCloseOperation(2);
++ jframe.add(servergui);
++ jframe.pack();
++ jframe.setLocationRelativeTo((Component) null);
++ jframe.setVisible(true);
++ jframe.addWindowListener(new WindowAdapter() {
++ public void windowClosing(WindowEvent windowevent) {
++ if (!servergui.isClosing.getAndSet(true)) {
++ jframe.setTitle("Minecraft server - shutting down!");
+ server.halt(true);
+- minecraftServerGui.runFinalizers();
++ servergui.runFinalizers();
+ }
++
+ }
+ });
+- minecraftServerGui.addFinalizer(jFrame::dispose);
+- minecraftServerGui.start();
+- return minecraftServerGui;
++ Objects.requireNonNull(jframe);
++ servergui.addFinalizer(jframe::dispose);
++ servergui.start();
++ return servergui;
+ }
+
+ private MinecraftServerGui(DedicatedServer server) {
+@@ -77,9 +83,10 @@
+ try {
+ this.add(this.buildChatPanel(), "Center");
+ this.add(this.buildInfoPanel(), "West");
+- } catch (Exception var3) {
+- LOGGER.error("Couldn't build server GUI", (Throwable)var3);
++ } catch (Exception exception) {
++ MinecraftServerGui.LOGGER.error("Couldn't build server GUI", exception);
+ }
++
+ }
+
+ public void addFinalizer(Runnable finalizer) {
+@@ -87,54 +94,61 @@
+ }
+
+ private JComponent buildInfoPanel() {
+- JPanel jPanel = new JPanel(new BorderLayout());
+- StatsComponent statsComponent = new StatsComponent(this.server);
+- this.finalizers.add(statsComponent::close);
+- jPanel.add(statsComponent, "North");
+- jPanel.add(this.buildPlayerPanel(), "Center");
+- jPanel.setBorder(new TitledBorder(new EtchedBorder(), "Stats"));
+- return jPanel;
++ JPanel jpanel = new JPanel(new BorderLayout());
++ StatsComponent guistatscomponent = new StatsComponent(this.server);
++ Collection<Runnable> collection = this.finalizers; // CraftBukkit - decompile error
++
++ Objects.requireNonNull(guistatscomponent);
++ collection.add(guistatscomponent::close);
++ jpanel.add(guistatscomponent, "North");
++ jpanel.add(this.buildPlayerPanel(), "Center");
++ jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Stats"));
++ return jpanel;
+ }
+
+ private JComponent buildPlayerPanel() {
+- JList<?> jList = new PlayerListComponent(this.server);
+- JScrollPane jScrollPane = new JScrollPane(jList, 22, 30);
+- jScrollPane.setBorder(new TitledBorder(new EtchedBorder(), "Players"));
+- return jScrollPane;
++ JList<?> jlist = new PlayerListComponent(this.server);
++ JScrollPane jscrollpane = new JScrollPane(jlist, 22, 30);
++
++ jscrollpane.setBorder(new TitledBorder(new EtchedBorder(), "Players"));
++ return jscrollpane;
+ }
+
+ private JComponent buildChatPanel() {
+- JPanel jPanel = new JPanel(new BorderLayout());
+- JTextArea jTextArea = new JTextArea();
+- JScrollPane jScrollPane = new JScrollPane(jTextArea, 22, 30);
+- jTextArea.setEditable(false);
+- jTextArea.setFont(MONOSPACED);
+- JTextField jTextField = new JTextField();
+- jTextField.addActionListener(actionEvent -> {
+- String trimmed = jTextField.getText().trim();
+- if (!trimmed.isEmpty()) {
+- this.server.handleConsoleInput(trimmed, this.server.createCommandSourceStack());
++ JPanel jpanel = new JPanel(new BorderLayout());
++ JTextArea jtextarea = new JTextArea();
++ JScrollPane jscrollpane = new JScrollPane(jtextarea, 22, 30);
++
++ jtextarea.setEditable(false);
++ jtextarea.setFont(MinecraftServerGui.MONOSPACED);
++ JTextField jtextfield = new JTextField();
++
++ jtextfield.addActionListener((actionevent) -> {
++ String s = jtextfield.getText().trim();
++
++ if (!s.isEmpty()) {
++ this.server.handleConsoleInput(s, this.server.createCommandSourceStack());
+ }
+
+- jTextField.setText("");
++ jtextfield.setText("");
+ });
+- jTextArea.addFocusListener(new FocusAdapter() {
+- @Override
+- public void focusGained(FocusEvent event) {
+- }
++ jtextarea.addFocusListener(new FocusAdapter() {
++ public void focusGained(FocusEvent focusevent) {}
+ });
+- jPanel.add(jScrollPane, "Center");
+- jPanel.add(jTextField, "South");
+- jPanel.setBorder(new TitledBorder(new EtchedBorder(), "Log and chat"));
++ jpanel.add(jscrollpane, "Center");
++ jpanel.add(jtextfield, "South");
++ jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Log and chat"));
+ this.logAppenderThread = new Thread(() -> {
+- String string;
+- while ((string = LogQueues.getNextLogEvent("ServerGuiConsole")) != null) {
+- this.print(jTextArea, jScrollPane, string);
++ String s;
++
++ while ((s = LogQueues.getNextLogEvent("ServerGuiConsole")) != null) {
++ this.print(jtextarea, jscrollpane, s);
+ }
++
+ });
+- this.logAppenderThread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER));
++ this.logAppenderThread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(MinecraftServerGui.LOGGER));
+ this.logAppenderThread.setDaemon(true);
+- return jPanel;
++ return jpanel;
+ }
+
+ public void start() {
+@@ -145,32 +159,38 @@
+ if (!this.isClosing.getAndSet(true)) {
+ this.runFinalizers();
+ }
++
+ }
+
+ void runFinalizers() {
+ this.finalizers.forEach(Runnable::run);
+ }
+
++ private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})*)?[m|K]"); // CraftBukkit
+ public void print(JTextArea textArea, JScrollPane scrollPane, String line) {
+ if (!SwingUtilities.isEventDispatchThread()) {
+- SwingUtilities.invokeLater(() -> this.print(textArea, scrollPane, line));
++ SwingUtilities.invokeLater(() -> {
++ this.print(textArea, scrollPane, line);
++ });
+ } else {
+ Document document = textArea.getDocument();
+- JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar();
++ JScrollBar jscrollbar = scrollPane.getVerticalScrollBar();
+ boolean flag = false;
++
+ if (scrollPane.getViewport().getView() == textArea) {
+- flag = (double)verticalScrollBar.getValue() + verticalScrollBar.getSize().getHeight() + (double)(MONOSPACED.getSize() * 4)
+- > (double)verticalScrollBar.getMaximum();
++ flag = (double) jscrollbar.getValue() + jscrollbar.getSize().getHeight() + (double) (MinecraftServerGui.MONOSPACED.getSize() * 4) > (double) jscrollbar.getMaximum();
+ }
+
+ try {
+- document.insertString(document.getLength(), line, null);
+- } catch (BadLocationException var8) {
++ document.insertString(document.getLength(), ANSI.matcher(line).replaceAll(""), (AttributeSet) null); // CraftBukkit
++ } catch (BadLocationException badlocationexception) {
++ ;
+ }
+
+ if (flag) {
+- verticalScrollBar.setValue(Integer.MAX_VALUE);
++ jscrollbar.setValue(Integer.MAX_VALUE);
+ }
++
+ }
+ }
+ }