@@ -83,8 +83,10 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
8383 private static final Logger LOGGER = LogManager .getLogger (ConfigSessionHandler .class );
8484
8585 // Advance the backend to PLAY this long after it finishes configuring, decoupling it from a client
86- // still held in config (e.g. applying a resource pack) before the backend times out.
87- private static final long SPLIT_PHASE_DELAY_SECONDS = 9L ;
86+ // still held in config (e.g. applying a resource pack) before the backend times out. When 0 or
87+ // less, advance immediately without ever holding the backend in config.
88+ private static final long SPLIT_PHASE_DELAY_SECONDS =
89+ Long .getLong ("velocity-ctd.split-phase-delay-seconds" , 9L );
8890
8991 private final VelocityServer server ;
9092
@@ -264,12 +266,20 @@ public boolean handle(FinishedUpdatePacket packet) {
264266 CompletableFuture <Void > clientFinished = configHandler .handleBackendFinishUpdate (serverConn );
265267
266268 // Advance the backend to PLAY on whichever comes first: the client finishing, or the timeout.
267- // If the timeout wins, buffer the backend's PLAY packets until the client catches up.
268- ScheduledFuture <?> splitTask = smc .eventLoop ().schedule (
269- () -> advanceBackendToPlay (true ), SPLIT_PHASE_DELAY_SECONDS , TimeUnit .SECONDS );
269+ // If the timeout wins, buffer the backend's PLAY packets until the client catches up. A delay of
270+ // 0 or less advances immediately, buffering from the start without holding the backend in config.
271+ final ScheduledFuture <?> splitTask = SPLIT_PHASE_DELAY_SECONDS > 0
272+ ? smc .eventLoop ().schedule (
273+ () -> advanceBackendToPlay (true ), SPLIT_PHASE_DELAY_SECONDS , TimeUnit .SECONDS )
274+ : null ;
275+ if (splitTask == null ) {
276+ advanceBackendToPlay (true );
277+ }
270278
271279 clientFinished .thenRunAsync (() -> {
272- splitTask .cancel (false );
280+ if (splitTask != null ) {
281+ splitTask .cancel (false );
282+ }
273283 // Client won the race: advance now (already in PLAY, no buffering) and drain anything the
274284 // timeout may have buffered.
275285 advanceBackendToPlay (false );
0 commit comments