001 import java.io.File; 002 import java.io.FileOutputStream; 003 import java.io.IOException; 004 import java.net.URL; 005 import java.nio.channels.Channels; 006 import java.nio.channels.ReadableByteChannel; 007 008 public class Main { 009 010 public static void main(String[] args) throws IOException { 011 if (!new File("minecraft_server.jar").exists()) { 012 System.out.println("minecraft_server.jar not found, downloading..."); 013 014 URL url = new URL("http://minecraft.net/download/minecraft_server.jar"); 015 ReadableByteChannel rbc = Channels.newChannel(url.openStream()); 016 FileOutputStream fos = new FileOutputStream("minecraft_server.jar"); 017 fos.getChannel().transferFrom(rbc, 0, 1 << 24); 018 019 System.out.println("Finished downloading, starting server"); 020 } 021 022 if (checkForUpdate()) { 023 System.out.println("Update found."); 024 // derp. 025 } 026 027 // My mod doesn't work with gui. 028 try { 029 net.minecraft.server.MinecraftServer.main(args); 030 } catch (Throwable t) { 031 t.printStackTrace(); 032 } 033 } 034 035 public static boolean checkForUpdate() { 036 return false; 037 } 038 }