import java.io.*; import java.util.Scanner; public class OpenRC { static BufferedReader consoleInput = null; static String os = System.getProperty("os.name").toLowerCase(); static Process server; public static void main(String[] args) throws IOException { // OpenRC by Pacnet2013 System.out.println(System.getProperty("user.dir")); if(os.indexOf("win") >= 0) { os = "Windows"; } else if(os.indexOf("mac") >= 0) { os = "Mac"; } else if(os.indexOf("nux") >= 0) { os = "Linux"; } switch(os){ case "Linux" : //cause I need WINE File file = new File(System.getProperty("user.dir") + "/OpenRC.txt"); try { Scanner scanner = new Scanner(file); String path = scanner.nextLine(); System.out.println("Got BlocklandEXE - " + path); String port = scanner.nextLine(); System.out.println("Got port - " + port); scanner.close(); server = new ProcessBuilder("wine", path + "Blockland.exe", "ptlaaxobimwroe", "-dedicated", "-port" + port).start(); if(consoleInput != null) consoleInput.close(); consoleInput = new BufferedReader(new InputStreamReader(server.getInputStream())); streamLoop(); } catch (FileNotFoundException e) { System.out.println("You don't have an OpenRC Config file OpenRC.txt in the directory of this program"); } } } public static void streamConsole() { String line = ""; int numLines = 0; try { if (consoleInput != null) { while((line = consoleInput.readLine()) != null && consoleInput.ready()) { numLines++; } } } catch (IOException e) { System.out.println("There may be a problem - An IOException (java.io.IOException) was caught so some lines may not display / display correctly"); } if(!line.equals("") && !(line == null)) { System.out.println("Streaming" + numLines + line); writeToFile(System.getProperty("user.dir"), line); } } public static void streamLoop() { try { Thread.sleep(5000); } catch (InterruptedException e) { System.out.println("A slight problem may have happened while trying to read a command"); } streamConsole(); streamLoop(); //it'll go on until you close this program } public static void writeToFile(String filePath, String content) { try { File file = new File(filePath); if (!file.exists()) { file.createNewFile(); System.out.println("Creating new stream text file"); } FileWriter writer = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(writer); bw.write(content); bw.close(); System.out.println("Wrote stream text file"); } catch (IOException e) { e.printStackTrace(); } } }