chore: cleanup annotations in api adventure patch

This commit is contained in:
Riley Park
2023-03-23 09:49:24 -07:00
parent c4351787c6
commit 39255145b6
64 changed files with 1308 additions and 1246 deletions

View File

@@ -98,24 +98,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if ( isRestarting )
{
- System.out.println( "Attempting to restart with " + restartScript );
+ System.out.println( "Attempting to restart with " + SpigotConfig.restartScript );
+ } else
+ {
+ System.out.println( "Startup script '" + SpigotConfig.restartScript + "' does not exist! Stopping server." );
+ }
+ // Stop the watchdog
+ WatchdogThread.doStop();
-
- // Disable Watchdog
- WatchdogThread.doStop();
+ shutdownServer( isRestarting );
+ // Paper end
+ } catch ( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
-
- // Kick all players
- for ( ServerPlayer p : (List<ServerPlayer>) MinecraftServer.getServer().getPlayerList().players )
- {
@@ -130,6 +116,73 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- }
- // Close the socket so we can rebind with the new process
- MinecraftServer.getServer().getConnection().stop();
-
- // Give time for it to kick in
- try
- {
- Thread.sleep( 100 );
- } catch ( InterruptedException ex )
- {
- }
-
- // Actually shutdown
- try
- {
- MinecraftServer.getServer().close();
- } catch ( Throwable t )
- {
- }
-
- // This will be done AFTER the server has completely halted
- Thread shutdownHook = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- String os = System.getProperty( "os.name" ).toLowerCase(java.util.Locale.ENGLISH);
- if ( os.contains( "win" ) )
- {
- Runtime.getRuntime().exec( "cmd /c start " + restartScript );
- } else
- {
- Runtime.getRuntime().exec( "sh " + restartScript );
- }
- } catch ( Exception e )
- {
- e.printStackTrace();
- }
- }
- };
-
- shutdownHook.setDaemon( true );
- Runtime.getRuntime().addShutdownHook( shutdownHook );
+ System.out.println( "Attempting to restart with " + SpigotConfig.restartScript );
} else
{
System.out.println( "Startup script '" + SpigotConfig.restartScript + "' does not exist! Stopping server." );
-
- // Actually shutdown
- try
- {
- MinecraftServer.getServer().close();
- } catch ( Throwable t )
- {
- }
}
- System.exit( 0 );
+ // Stop the watchdog
+ WatchdogThread.doStop();
+
+ shutdownServer( isRestarting );
+ // Paper end
} catch ( Exception ex )
{
ex.printStackTrace();
}
}
+
+ // Paper start - sync copied from above with minor changes, async added
+ private static void shutdownServer(boolean isRestarting)
+ {
@@ -147,23 +200,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } catch ( InterruptedException ex )
+ {
+ }
- // Give time for it to kick in
- try
- {
- Thread.sleep( 100 );
- } catch ( InterruptedException ex )
- {
- }
+
+ closeSocket();
- // Actually shutdown
- try
- {
- MinecraftServer.getServer().close();
- } catch ( Throwable t )
- {
- }
+
+ // Actually shutdown
+ try
+ {
@@ -174,9 +213,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ // Actually stop the JVM
+ System.exit( 0 );
- // This will be done AFTER the server has completely halted
- Thread shutdownHook = new Thread()
+
+ } else
+ {
+ // Mark the server to shutdown at the end of the tick
@@ -228,63 +265,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ {
+ @Override
+ public void run()
{
- @Override
- public void run()
+ {
+ try
{
- try
+ {
+ String os = System.getProperty( "os.name" ).toLowerCase(java.util.Locale.ENGLISH);
+ if ( os.contains( "win" ) )
{
- String os = System.getProperty( "os.name" ).toLowerCase(java.util.Locale.ENGLISH);
- if ( os.contains( "win" ) )
- {
- Runtime.getRuntime().exec( "cmd /c start " + restartScript );
- } else
- {
- Runtime.getRuntime().exec( "sh " + restartScript );
- }
- } catch ( Exception e )
+ {
+ Runtime.getRuntime().exec( "cmd /c start " + restartScript );
+ } else
{
- e.printStackTrace();
+ {
+ Runtime.getRuntime().exec( "sh " + restartScript );
}
+ }
+ } catch ( Exception e )
+ {
+ e.printStackTrace();
}
- };
-
- shutdownHook.setDaemon( true );
- Runtime.getRuntime().addShutdownHook( shutdownHook );
- } else
- {
- System.out.println( "Startup script '" + SpigotConfig.restartScript + "' does not exist! Stopping server." );
-
- // Actually shutdown
- try
- {
- MinecraftServer.getServer().close();
- } catch ( Throwable t )
- {
}
- }
- System.exit( 0 );
- } catch ( Exception ex )
+ }
+ }
+ };
+
+ shutdownHook.setDaemon( true );
+ Runtime.getRuntime().addShutdownHook( shutdownHook );
+ return true;
+ } else
{
- ex.printStackTrace();
+ {
+ return false;
}
}
+ }
+ }
+ // Paper end
+
}