@@ -180,10 +180,13 @@ private void performTeleport(Player player,
180180 TeleportReason reason ,
181181 Consumer <Boolean > callback ,
182182 Runnable completionHook ) {
183- World world = plugin .getServer ().getWorld (teleportSettings .getWorldName ());
183+ final RandomTeleportSettings effectiveSettings = teleportSettings .isAutoWorld ()
184+ ? teleportSettings .withWorldName (player .getWorld ().getName ())
185+ : teleportSettings ;
186+ World world = plugin .getServer ().getWorld (effectiveSettings .getWorldName ());
184187 if (world == null ) {
185188 com .skyblockexp .ezrtp .util .MessageUtil .send (player , messageProvider .format (MessageKey .WORLD_MISSING ,
186- Map .of ("world" , teleportSettings .getWorldName ()), player ));
189+ Map .of ("world" , effectiveSettings .getWorldName ()), player ));
187190 if (callback != null ) callback .accept (false );
188191 if (completionHook != null ) completionHook .run ();
189192 return ;
@@ -196,9 +199,9 @@ private void performTeleport(Player player,
196199 }
197200
198201 long startTime = System .currentTimeMillis ();
199- CompletableFuture <SearchResult > locationSearchFuture = locationFinder .findSafeLocationAsync (world , teleportSettings );
200- boolean rareSearch = locationFinder .isRareSearch (teleportSettings );
201- long searchTimeoutMillis = resolveSearchTimeoutMillis (teleportSettings , rareSearch );
202+ CompletableFuture <SearchResult > locationSearchFuture = locationFinder .findSafeLocationAsync (world , effectiveSettings );
203+ boolean rareSearch = locationFinder .isRareSearch (effectiveSettings );
204+ long searchTimeoutMillis = resolveSearchTimeoutMillis (effectiveSettings , rareSearch );
202205 CompletableFuture <SearchResult > completionFuture = locationSearchFuture ;
203206 if (searchTimeoutMillis > 0 ) {
204207 completionFuture = locationSearchFuture .orTimeout (searchTimeoutMillis , TimeUnit .MILLISECONDS );
@@ -215,21 +218,21 @@ private void performTeleport(Player player,
215218
216219 try {
217220 if (throwable != null || result == null || result .location ().isEmpty ()) {
218- if (throwable != null && teleportSettings .isDebugRejectionLoggingEnabled ()) {
221+ if (throwable != null && effectiveSettings .isDebugRejectionLoggingEnabled ()) {
219222 plugin .getLogger ().warning ("EzRTP debug: location search failed for player '"
220223 + player .getName () + "' in world '" + world .getName () + "' after "
221224 + duration + "ms: " + throwable .getClass ().getSimpleName () + " - "
222225 + throwable .getMessage ());
223226 }
224- resultHandler .handleFailure (player , teleportSettings , result , duration , biome , cacheHit , cacheChecked );
227+ resultHandler .handleFailure (player , effectiveSettings , result , duration , biome , cacheHit , cacheChecked );
225228 if (callback != null ) callback .accept (false );
226229 return ;
227230 }
228231
229232 validLocation = result .location ().get ();
230233
231234 if (!player .isOnline ()) {
232- locationFinder .cacheValidLocation (validLocation , teleportSettings );
235+ locationFinder .cacheValidLocation (validLocation , effectiveSettings );
233236 statistics .recordPlayerOfflineOrCancelledFailure ();
234237 statistics .recordAttempt (false , duration , biome , cacheHit , cacheChecked );
235238 if (callback != null ) callback .accept (false );
@@ -248,15 +251,15 @@ private void performTeleport(Player player,
248251 return ;
249252 }
250253
251- Location destination = TeleportDestinationAdjuster .adjustForSafety (validLocation , teleportSettings );
254+ Location destination = TeleportDestinationAdjuster .adjustForSafety (validLocation , effectiveSettings );
252255 biome = destination .getBlock ().getBiome ();
253256 Location oldLocation = player .getLocation (); // Store old location before teleport
254257 success = player .teleport (destination );
255258
256259 if (success ) {
257- resultHandler .handleSuccess (player , destination , result , teleportSettings , duration , biome , cacheHit , cacheChecked , validLocation );
260+ resultHandler .handleSuccess (player , destination , result , effectiveSettings , duration , biome , cacheHit , cacheChecked , validLocation );
258261 } else {
259- locationFinder .cacheValidLocation (validLocation , teleportSettings );
262+ locationFinder .cacheValidLocation (validLocation , effectiveSettings );
260263 com .skyblockexp .ezrtp .util .MessageUtil .send (player , messageProvider .format (MessageKey .TELEPORT_FAILED , player ));
261264 statistics .recordTeleportApiFailure ();
262265 statistics .recordAttempt (false , duration , biome , cacheHit , cacheChecked );
0 commit comments