Commits
Bruno Ivan authored and md_5 committed 971f0633ae3
1 1 | package org.spigotmc.builder; |
2 2 | |
3 3 | import com.google.common.base.Joiner; |
4 4 | import java.awt.GraphicsEnvironment; |
5 + | import joptsimple.OptionSet; |
5 6 | import org.spigotmc.gui.BuildToolsGui; |
7 + | import org.spigotmc.utils.Flags; |
6 8 | import org.spigotmc.utils.SwingUtils; |
7 9 | import org.spigotmc.utils.Utils; |
8 10 | |
9 11 | public class Bootstrap |
10 12 | { |
11 13 | |
12 14 | private static boolean guiEnabled = false; |
13 15 | |
14 16 | public static void main(String[] args) throws Exception |
15 17 | { |
16 - | if ( args.length == 0 ) |
18 + | OptionSet options = Flags.PARSER.parse( args ); |
19 + | |
20 + | if ( ( args.length == 0 && !Utils.isRanFromCommandLine() ) || options.has( Flags.GUI_FLAG ) ) |
17 21 | { |
18 - | if ( !Utils.isRanFromCommandLine() ) |
22 + | if ( !options.has( Flags.NO_GUI_FLAG ) ) |
19 23 | { |
20 24 | if ( !GraphicsEnvironment.isHeadless() ) |
21 25 | { |
22 26 | guiEnabled = true; |
23 27 | |
24 28 | SwingUtils.applyInitialTheme(); |
25 29 | |
26 30 | BuildToolsGui gui = new BuildToolsGui(); |
27 31 | gui.setLocationRelativeTo( null ); |
28 32 | gui.setVisible( true ); |
46 50 | long memoryMb = Runtime.getRuntime().maxMemory() >> 20; |
47 51 | if ( memoryMb < 448 ) // Older JVMs (including Java 8) report less than Xmx here. Allow some slack for people actually using -Xmx512M |
48 52 | { |
49 53 | System.err.println( "BuildTools requires at least 512M of memory to run (1024M recommended), but has only detected " + memoryMb + "M." ); |
50 54 | System.err.println( "This can often occur if you are running a 32-bit system, or one with low RAM." ); |
51 55 | System.err.println( "Please re-run BuildTools with manually specified memory, e.g: java -Xmx1024M -jar BuildTools.jar " + Joiner.on( ' ' ).join( args ) ); |
52 56 | System.exit( 1 ); |
53 57 | } |
54 58 | |
55 59 | Builder.logOutput( System.out, System.err ); |
56 - | Builder.main( args ); |
60 + | Builder.startBuilder( args, options ); |
57 61 | } |
58 62 | } |
59 63 | } |