@@ -171,7 +171,11 @@ private void loadNewWorldConfigs(Collection<WorldConfig> newWorldConfigs) {
171171 }
172172
173173 private void removeWorldsNotInConfigs (Collection <String > removedWorlds ) {
174- removedWorlds .forEach (worldName -> removeWorld (worldName )
174+ removedWorlds .forEach (worldName -> getWorld (worldName )
175+ .fold (
176+ () -> Attempt .failure (FailureReason .GENERIC , Message .of ("world already removed" )),
177+ world -> removeWorld (RemoveWorldOptions .world (world ))
178+ )
175179 .onFailure (failure -> Logging .severe ("Failed to unload world %s: %s" , worldName , failure ))
176180 .onSuccess (success -> Logging .fine ("Unloaded world %s as it was removed from config" , worldName )));
177181 }
@@ -515,10 +519,14 @@ private Attempt<MultiverseWorld, UnloadFailureReason> removeLoadedMultiverseWorl
515519 *
516520 * @param worldName The name of the world to remove.
517521 * @return The result of the remove.
522+ *
523+ * @deprecated Get the {@link MultiverseWorld} yourself and use {@link #removeWorld(RemoveWorldOptions)} instead.
518524 */
525+ @ Deprecated (since = "5.2" , forRemoval = true )
526+ @ ApiStatus .ScheduledForRemoval (inVersion = "6.0" )
519527 public Attempt <String , RemoveFailureReason > removeWorld (@ NotNull String worldName ) {
520528 return getWorld (worldName )
521- .map (this :: removeWorld )
529+ .map (world -> removeWorld ( RemoveWorldOptions . world ( world )) )
522530 .getOrElse (() -> worldActionResult (RemoveFailureReason .WORLD_NON_EXISTENT , worldName ));
523531 }
524532
@@ -528,7 +536,11 @@ public Attempt<String, RemoveFailureReason> removeWorld(@NotNull String worldNam
528536 *
529537 * @param world The multiverse world to remove.
530538 * @return The result of the remove.
539+ *
540+ * @deprecated Use {@link #removeWorld(RemoveWorldOptions)} instead.
531541 */
542+ @ Deprecated (since = "5.2" , forRemoval = true )
543+ @ ApiStatus .ScheduledForRemoval (inVersion = "6.0" )
532544 public Attempt <String , RemoveFailureReason > removeWorld (@ NotNull MultiverseWorld world ) {
533545 return removeWorld (RemoveWorldOptions .world (world ));
534546 }
@@ -539,9 +551,13 @@ public Attempt<String, RemoveFailureReason> removeWorld(@NotNull MultiverseWorld
539551 *
540552 * @param loadedWorld The multiverse world to remove.
541553 * @return The result of the remove.
554+ *
555+ * @deprecated Use {@link #removeWorld(RemoveWorldOptions)} instead.
542556 */
557+ @ Deprecated (since = "5.2" , forRemoval = true )
558+ @ ApiStatus .ScheduledForRemoval (inVersion = "6.0" )
543559 public Attempt <String , RemoveFailureReason > removeWorld (@ NotNull LoadedMultiverseWorld loadedWorld ) {
544- return unloadBeforeRemoveWorld ( loadedWorld , RemoveWorldOptions .world (loadedWorld ));
560+ return removeWorld ( RemoveWorldOptions .world (loadedWorld ));
545561 }
546562
547563 /**
@@ -622,7 +638,11 @@ private Attempt<String, DeleteFailureReason> doDeleteWorld(@NotNull LoadedMultiv
622638 ? Attempt .failure (DeleteFailureReason .EVENT_CANCELLED )
623639 : Attempt .success (null );
624640 })
625- .mapAttempt (() -> removeWorld (world ).transform (DeleteFailureReason .REMOVE_FAILED ))
641+ .mapAttempt (() -> removeWorld (RemoveWorldOptions
642+ .world (world )
643+ .unloadBukkitWorld (true )
644+ .saveBukkitWorld (false )
645+ ).transform (DeleteFailureReason .REMOVE_FAILED ))
626646 .mapAttempt (() -> fileUtils .deleteFolder (worldFolder .get (), options .keepFiles ()).fold (
627647 exception -> worldActionResult (DeleteFailureReason .FAILED_TO_DELETE_FOLDER ,
628648 world .getName (), exception ),
0 commit comments