@@ -31,50 +31,49 @@ public static void sendPowerSignal(CommandSender sender, String serverName, Stri
31
31
32
32
// Send signal
33
33
plugin .config .getPowerController ().sendPowerSignal (serverName , serverId , signalType ).thenRun (() -> {
34
+ if (signalType == PowerSignal .STOP ) {
35
+ // When stopping the server
36
+ sender .sendMessage (plugin .messages .success ("server_stop" , serverName ));
37
+ }
38
+
34
39
// Start auto stop task and send warning
35
- if (signalType == PowerSignal . START ) {
40
+ if (sender instanceof ProxiedPlayer && plugin . config . startupJoinTimeout > 0 ) {
36
41
// If auto join is configured, join the server when it is started
37
- if (sender instanceof ProxiedPlayer && plugin .config .startupJoinTimeout > 0 ) {
38
- // If auto join is configured, join the server when it is started
39
- sender .sendMessage (plugin .messages .success ("server_startup_join" , serverName ));
40
-
41
- // Get the server info
42
- ServerInfo serverInfo = plugin .getProxy ().getServerInfo (serverName );
43
- // ServerInfo is null if the server is not found on bungeecord config
44
- if (serverInfo != null ) {
45
- // Wait until the server is started
46
- onceStarted (serverInfo ).thenRun (() -> {
47
- // Move player to the started server
48
- ProxiedPlayer player = (ProxiedPlayer ) sender ;
49
- if (plugin .config .joinDelay > 0 ) {
50
- // Delay the join
51
- plugin .getProxy ().getScheduler ().schedule (plugin , () -> player .connect (serverInfo ), plugin .config .joinDelay , TimeUnit .SECONDS );
52
- // Send a message
53
- player .sendMessage (plugin .messages .success ("server_startup_join_move_delayed" , serverName , plugin .config .joinDelay ));
54
- } else {
55
- // Join immediately
56
- player .connect (serverInfo );
57
- // Send a message
58
- player .sendMessage (plugin .messages .success ("server_startup_join_move" , serverName ));
59
- }
60
- }).exceptionally ((Throwable e ) -> {
61
- sender .sendMessage (plugin .messages .warning ("server_startup_join_failed" , serverName ));
62
- return null ;
63
- });
64
- }
65
-
66
- } else {
67
- // Otherwise, just send a message
68
- sender .sendMessage (plugin .messages .success ("server_start" , serverName ));
42
+ sender .sendMessage (plugin .messages .success ("server_startup_join" , serverName ));
43
+
44
+ // Get the server info
45
+ ServerInfo serverInfo = plugin .getProxy ().getServerInfo (serverName );
46
+ // ServerInfo is null if the server is not found on bungeecord config
47
+ if (serverInfo != null ) {
48
+ // Wait until the server is started
49
+ onceStarted (serverInfo ).thenRun (() -> {
50
+ // Move player to the started server
51
+ ProxiedPlayer player = (ProxiedPlayer ) sender ;
52
+ if (plugin .config .joinDelay > 0 ) {
53
+ // Delay the join
54
+ plugin .getProxy ().getScheduler ().schedule (plugin , () -> player .connect (serverInfo ), plugin .config .joinDelay , TimeUnit .SECONDS );
55
+ // Send a message
56
+ player .sendMessage (plugin .messages .success ("server_startup_join_move_delayed" , serverName , plugin .config .joinDelay ));
57
+ } else {
58
+ // Join immediately
59
+ player .connect (serverInfo );
60
+ // Send a message
61
+ player .sendMessage (plugin .messages .success ("server_startup_join_move" , serverName ));
62
+ }
63
+ }).exceptionally ((Throwable e ) -> {
64
+ sender .sendMessage (plugin .messages .warning ("server_startup_join_failed" , serverName ));
65
+ return null ;
66
+ });
69
67
}
70
68
71
- // Stop the server if nobody joins after a while
72
- stopAfterWhile (sender , serverName , serverId , signalType );
73
69
} else {
74
- // When stopping the server
75
- sender .sendMessage (plugin .messages .success ("server_stop " , serverName ));
70
+ // Otherwise, just send a message
71
+ sender .sendMessage (plugin .messages .success ("server_start " , serverName ));
76
72
}
77
73
74
+ // Stop the server if nobody joins after a while
75
+ stopAfterWhile (sender , serverName , serverId , signalType );
76
+
78
77
}).exceptionally (e -> {
79
78
sender .sendMessage (plugin .messages .error ("server_" + signal + "_failed" , serverName ));
80
79
return null ;
@@ -95,21 +94,26 @@ public static void stopAfterWhile(CommandSender sender, String serverName, Strin
95
94
String signal = signalType .getSignal ();
96
95
97
96
// Get the auto stop time
98
- Integer serverTimeout = plugin .config .getServerTimeout (serverName );
99
- if (serverTimeout != null && serverTimeout >= 0 ) {
100
- // Stop the server after a while
101
- plugin .delay .stopAfterWhile (serverName , serverTimeout , () -> {
102
- // Stop the server
103
- sendPowerSignal (sender , serverName , serverId , PowerSignal .STOP );
104
-
105
- // Record statistics
106
- plugin .statistics .actionCounter .increment (Statistics .ActionCounter .ActionType .STOP_SERVER_NOBODY );
107
- plugin .statistics .startReasonRecorder .recordStop (serverName );
108
- });
109
-
110
- // Send message
111
- sender .sendMessage (plugin .messages .warning ("server_" + signal + "_warning" , serverName , serverTimeout ));
97
+ int serverTimeout = plugin .config .getServerTimeout (serverName );
98
+ if (serverTimeout == 0 ) return ;
99
+
100
+ // When on starting, use the start timeout additionally
101
+ if (signalType == PowerSignal .START ) {
102
+ serverTimeout += plugin .config .startTimeout ;
112
103
}
104
+
105
+ // Stop the server after a while
106
+ plugin .delay .stopAfterWhile (serverName , serverTimeout , () -> {
107
+ // Stop the server
108
+ sendPowerSignal (sender , serverName , serverId , PowerSignal .STOP );
109
+
110
+ // Record statistics
111
+ plugin .statistics .actionCounter .increment (Statistics .ActionCounter .ActionType .STOP_SERVER_NOBODY );
112
+ plugin .statistics .startReasonRecorder .recordStop (serverName );
113
+ });
114
+
115
+ // Send message
116
+ sender .sendMessage (plugin .messages .warning ("server_" + signal + "_warning" , serverName , serverTimeout ));
113
117
}
114
118
115
119
/**
0 commit comments