aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/server/gui/MinecraftServerGui.java.patch
blob: d8691c8b4d6d5daaa0f71ea072a0f14f0446687c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
--- a/net/minecraft/server/gui/MinecraftServerGui.java
+++ b/net/minecraft/server/gui/MinecraftServerGui.java
@@ -44,7 +44,7 @@
     private final Collection<Runnable> finalizers = Lists.newArrayList();
     final AtomicBoolean isClosing = new AtomicBoolean();
 
-    public static MinecraftServerGui showFrameFor(final DedicatedServer dedicatedserver) {
+    public static MinecraftServerGui showFrameFor(final DedicatedServer server) {
         try {
             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
         } catch (Exception exception) {
@@ -52,32 +52,31 @@
         }
 
         final JFrame jframe = new JFrame("Minecraft server");
-        final MinecraftServerGui minecraftservergui = new MinecraftServerGui(dedicatedserver);
+        final MinecraftServerGui servergui = new MinecraftServerGui(server);
 
         jframe.setDefaultCloseOperation(2);
-        jframe.add(minecraftservergui);
+        jframe.add(servergui);
         jframe.pack();
         jframe.setLocationRelativeTo((Component) null);
         jframe.setVisible(true);
         jframe.addWindowListener(new WindowAdapter() {
-            @Override
             public void windowClosing(WindowEvent windowevent) {
-                if (!minecraftservergui.isClosing.getAndSet(true)) {
+                if (!servergui.isClosing.getAndSet(true)) {
                     jframe.setTitle("Minecraft server - shutting down!");
-                    dedicatedserver.halt(true);
-                    minecraftservergui.runFinalizers();
+                    server.halt(true);
+                    servergui.runFinalizers();
                 }
 
             }
         });
         Objects.requireNonNull(jframe);
-        minecraftservergui.addFinalizer(jframe::dispose);
-        minecraftservergui.start();
-        return minecraftservergui;
+        servergui.addFinalizer(jframe::dispose);
+        servergui.start();
+        return servergui;
     }
 
-    private MinecraftServerGui(DedicatedServer dedicatedserver) {
-        this.server = dedicatedserver;
+    private MinecraftServerGui(DedicatedServer server) {
+        this.server = server;
         this.setPreferredSize(new Dimension(854, 480));
         this.setLayout(new BorderLayout());
 
@@ -90,18 +89,18 @@
 
     }
 
-    public void addFinalizer(Runnable runnable) {
-        this.finalizers.add(runnable);
+    public void addFinalizer(Runnable finalizer) {
+        this.finalizers.add(finalizer);
     }
 
     private JComponent buildInfoPanel() {
         JPanel jpanel = new JPanel(new BorderLayout());
-        StatsComponent statscomponent = new StatsComponent(this.server);
-        Collection collection = this.finalizers;
+        StatsComponent guistatscomponent = new StatsComponent(this.server);
+        Collection<Runnable> collection = this.finalizers; // CraftBukkit - decompile error
 
-        Objects.requireNonNull(statscomponent);
-        collection.add(statscomponent::close);
-        jpanel.add(statscomponent, "North");
+        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;
@@ -134,7 +133,6 @@
             jtextfield.setText("");
         });
         jtextarea.addFocusListener(new FocusAdapter() {
-            @Override
             public void focusGained(FocusEvent focusevent) {}
         });
         jpanel.add(jscrollpane, "Center");
@@ -168,22 +166,23 @@
         this.finalizers.forEach(Runnable::run);
     }
 
-    public void print(JTextArea jtextarea, JScrollPane jscrollpane, String s) {
+    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(jtextarea, jscrollpane, s);
+                this.print(textArea, scrollPane, line);
             });
         } else {
-            Document document = jtextarea.getDocument();
-            JScrollBar jscrollbar = jscrollpane.getVerticalScrollBar();
+            Document document = textArea.getDocument();
+            JScrollBar jscrollbar = scrollPane.getVerticalScrollBar();
             boolean flag = false;
 
-            if (jscrollpane.getViewport().getView() == jtextarea) {
+            if (scrollPane.getViewport().getView() == textArea) {
                 flag = (double) jscrollbar.getValue() + jscrollbar.getSize().getHeight() + (double) (MinecraftServerGui.MONOSPACED.getSize() * 4) > (double) jscrollbar.getMaximum();
             }
 
             try {
-                document.insertString(document.getLength(), s, (AttributeSet) null);
+                document.insertString(document.getLength(), ANSI.matcher(line).replaceAll(""), (AttributeSet) null); // CraftBukkit
             } catch (BadLocationException badlocationexception) {
                 ;
             }