|
1 | 1 | package org.mcphackers.mcp.tools;
|
2 | 2 |
|
3 |
| -import java.awt.*; |
| 3 | +import java.awt.Desktop; |
| 4 | +import java.awt.Toolkit; |
4 | 5 | import java.awt.datatransfer.StringSelection;
|
5 | 6 | import java.io.BufferedInputStream;
|
6 | 7 | import java.io.BufferedReader;
|
@@ -37,41 +38,34 @@ public static int runCommand(String[] cmd, Path dir, boolean killOnShutdown) thr
|
37 | 38 | BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
38 | 39 | Thread stderr = new Thread(()-> {
|
39 | 40 | String line;
|
40 |
| - while (true) { |
41 |
| - try { |
42 |
| - line = err.readLine(); |
43 |
| - if(line != null) { |
44 |
| - System.out.println("Minecraft STDERR: " + line); |
45 |
| - } |
46 |
| - } catch (IOException ignored) { |
47 |
| - // we don't really care what happens here |
| 41 | + try { |
| 42 | + while((line = err.readLine()) != null) { |
| 43 | + System.out.println("Minecraft STDERR: " + line); |
48 | 44 | }
|
| 45 | + } catch (IOException ignored) { |
| 46 | + // we don't really care what happens here |
49 | 47 | }
|
50 | 48 |
|
51 | 49 | });
|
52 | 50 | Thread stdout = new Thread(()-> {
|
53 | 51 | String line;
|
54 |
| - while (true) { |
55 |
| - try { |
56 |
| - line = in.readLine(); |
57 |
| - if(line != null) { |
58 |
| - System.out.println( line); |
59 |
| - } |
60 |
| - } catch (IOException ignored) { |
61 |
| - // we don't really care what happens here |
| 52 | + try { |
| 53 | + while((line = in.readLine()) != null) { |
| 54 | + System.out.println(line); |
62 | 55 | }
|
| 56 | + } catch (IOException ignored) { |
| 57 | + // we don't really care what happens here |
63 | 58 | }
|
64 |
| - |
65 | 59 | });
|
| 60 | + stdout.start(); |
| 61 | + stderr.start(); |
66 | 62 | try {
|
67 | 63 | proc.waitFor();
|
68 | 64 | } catch (InterruptedException e) {
|
69 | 65 | throw new RuntimeException("thread interrupted while runCommand was waiting for a process to finish", e );
|
70 | 66 | }
|
71 | 67 | in.close();
|
72 | 68 | err.close();
|
73 |
| - stderr.interrupt(); |
74 |
| - stdout.interrupt(); |
75 | 69 |
|
76 | 70 | if (killOnShutdown) {
|
77 | 71 | Runtime.getRuntime().removeShutdownHook(hook);
|
|
0 commit comments