Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
Added seperate message if using a self compiled version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zartec committed Mar 4, 2016
1 parent 5ddc241 commit 426e779
Showing 1 changed file with 55 additions and 41 deletions.
96 changes: 55 additions & 41 deletions bootstrap/src/main/java/net/md_5/bungee/BungeeCordLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

public class BungeeCordLauncher
{

public static void main(String[] args) throws Exception
{
Security.setProperty( "networkaddress.cache.ttl", "30" );
Expand All @@ -33,79 +32,94 @@ public static void main(String[] args) throws Exception
parser.allowsUnrecognizedOptions();
parser.acceptsAll( Arrays.asList( "v", "version") );
parser.acceptsAll( Arrays.asList( "noconsole" ) );

OptionSet options = parser.parse( args );

if ( options.has("version") )
{
System.out.println(Bootstrap.class.getPackage().getImplementationVersion());
return;
}

if ( BungeeCord.class.getPackage().getSpecificationVersion() != null && System.getProperty( "IReallyKnowWhatIAmDoingISwear" ) == null)
{
String version = BungeeCord.class.getPackage().getSpecificationVersion();
int currentVersion = version.equalsIgnoreCase("unknown") ? 0 : Integer.parseInt( version );

try
if ( version.equalsIgnoreCase("unknown") )
{
URL api = new URL( "https://api.github.com/repos/HexagonMC/BungeeCord/releases/latest" );
URLConnection con = api.openConnection();
// 15 second timeout at various stages
con.setConnectTimeout( 15000 );
con.setReadTimeout( 15000 );

String tagName = null;
System.err.println( "*** You are using a self compiled version ***" );
System.err.println( "*** Please make sure your server is up to date ***" );
System.err.println( "*** Using current version without warranty ***" );
System.err.println( "*** Server will start in 2 seconds ***" );
Thread.sleep( TimeUnit.SECONDS.toMillis( 2 ) );
} else
{
int currentVersion = Integer.parseInt( version );

try
{
JsonObject json = new JsonParser().parse( new InputStreamReader( con.getInputStream() ) ).getAsJsonObject();
tagName = json.get( "tag_name" ).getAsString();
URL api = new URL( "https://api.github.com/repos/HexagonMC/BungeeCord/releases/latest" );
URLConnection con = api.openConnection();
// 15 second timeout at various stages
con.setConnectTimeout( 15000 );
con.setReadTimeout( 15000 );

int latestVersion = Integer.parseInt( tagName.substring( 1, tagName.length() ) );
String tagName = null;

if ( latestVersion > currentVersion )
try
{
System.err.println("*** Warning, this build is outdated ***");
System.err.println("*** Please download a new build from https://github.com/HexagonMC/BungeeCord/releases ***");
System.err.println("*** You will get NO support regarding this build ***");
System.err.println("*** Server will start in 10 seconds ***");
Thread.sleep(TimeUnit.SECONDS.toMillis(10));
JsonObject json = new JsonParser().parse( new InputStreamReader( con.getInputStream() ) ).getAsJsonObject();
tagName = json.get( "tag_name" ).getAsString();

int latestVersion = Integer.parseInt( tagName.substring( 1, tagName.length() ) );

if ( latestVersion > currentVersion )
{
System.err.println("*** Warning, this build is outdated ***");
System.err.println("*** Please download a new build from https://github.com/HexagonMC/BungeeCord/releases ***");
System.err.println("*** You will get NO support regarding this build ***");
System.err.println("*** Server will start in 10 seconds ***");
Thread.sleep(TimeUnit.SECONDS.toMillis(10));
}
}
catch ( JsonIOException e )
{
throw new IOException(e);
}
catch ( JsonSyntaxException e )
{
throw new IOException( e );
}
catch( NumberFormatException e )
{
throw new IOException( e );
}
}
catch ( JsonIOException e )
{
throw new IOException(e);
}
catch ( JsonSyntaxException e )
{
throw new IOException( e );
}
catch( NumberFormatException e )
catch ( IOException e )
{
throw new IOException( e );
System.err.println( "*** Can not test if up to date ***" );
System.err.println( "*** Using current version without warranty ***" );
System.err.println( "*** Server will start in 2 seconds ***" );
Thread.sleep( TimeUnit.SECONDS.toMillis( 2 ) );
}
}
catch ( IOException e )
{
System.err.println( "*** Can not test if up to date ***" );
System.err.println( "*** Using current version without warranty ***" );
System.err.println( "*** Server will start in 2 seconds ***" );
Thread.sleep( TimeUnit.SECONDS.toMillis( 2 ) );
}
}

BungeeCord bungee = new BungeeCord();
ProxyServer.setInstance( bungee );
bungee.getLogger().info( "Enabled BungeeCord version " + bungee.getVersion() );
bungee.start();

if ( !options.has( "noconsole" ) )
{
String line;
while ( bungee.isRunning && ( line = bungee.getConsoleReader().readLine( ">" ) ) != null )
{
if ( !bungee.getPluginManager().dispatchCommand(ConsoleCommandSender.getInstance(), line ) )
{
bungee.getConsole().sendMessage( ChatColor.RED + "Command not found" );
}
}
}
}
}

0 comments on commit 426e779

Please sign in to comment.