mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 12:05:14 +01:00
Fix and refactor cloneWorld hasWorldFolder check
This commit is contained in:
parent
e889e406ae
commit
38dd0018e7
@ -185,17 +185,12 @@ public class WorldManager {
|
||||
return worldActionResult(CreateFailureReason.WORLD_EXIST_LOADED, options.worldName());
|
||||
} else if (getWorld(options.worldName()).isDefined()) {
|
||||
return worldActionResult(CreateFailureReason.WORLD_EXIST_UNLOADED, options.worldName());
|
||||
} else if (hasWorldFolder(options.worldName())) {
|
||||
} else if (worldNameChecker.hasWorldFolder(options.worldName())) {
|
||||
return worldActionResult(CreateFailureReason.WORLD_EXIST_FOLDER, options.worldName());
|
||||
}
|
||||
return worldActionResult(options);
|
||||
}
|
||||
|
||||
private boolean hasWorldFolder(String worldName) {
|
||||
File worldFolder = new File(Bukkit.getWorldContainer(), worldName);
|
||||
return worldFolder.exists();
|
||||
}
|
||||
|
||||
private Attempt<LoadedMultiverseWorld, CreateFailureReason> createValidatedWorld(
|
||||
CreateWorldOptions options) {
|
||||
String parsedGenerator = parseGenerator(options.worldName(), options.generator());
|
||||
@ -530,9 +525,6 @@ public class WorldManager {
|
||||
Logging.severe("Invalid world name: " + newWorldName);
|
||||
return worldActionResult(CloneFailureReason.INVALID_WORLDNAME, newWorldName);
|
||||
}
|
||||
if (worldNameChecker.isValidWorldFolder(newWorldName)) {
|
||||
return worldActionResult(CloneFailureReason.WORLD_EXIST_FOLDER, newWorldName);
|
||||
}
|
||||
if (isLoadedWorld(newWorldName)) {
|
||||
Logging.severe("World already loaded when attempting to clone: " + newWorldName);
|
||||
return worldActionResult(CloneFailureReason.WORLD_EXIST_LOADED, newWorldName);
|
||||
@ -541,6 +533,9 @@ public class WorldManager {
|
||||
Logging.severe("World already exist unloaded: " + newWorldName);
|
||||
return worldActionResult(CloneFailureReason.WORLD_EXIST_UNLOADED, newWorldName);
|
||||
}
|
||||
if (worldNameChecker.hasWorldFolder(newWorldName)) {
|
||||
return worldActionResult(CloneFailureReason.WORLD_EXIST_FOLDER, newWorldName);
|
||||
}
|
||||
return worldActionResult(options);
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,17 @@ public class WorldNameChecker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a world name has a valid world folder.
|
||||
* Check if a world name has a world folder directory. It may not contain valid world data.
|
||||
*
|
||||
* @param worldName The world name to check on.
|
||||
* @return True if the folder exists, else false.
|
||||
*/
|
||||
public boolean hasWorldFolder(@Nullable String worldName) {
|
||||
return checkFolder(worldName) != FolderStatus.DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a world name has a valid world folder with basic world data.
|
||||
*
|
||||
* @param worldName The world name to check on.
|
||||
* @return True if check result is valid, else false.
|
||||
@ -65,7 +75,7 @@ public class WorldNameChecker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a world folder is valid.
|
||||
* Checks if a world folder is valid with basic world data.
|
||||
*
|
||||
* @param worldFolder The world folder to check on.
|
||||
* @return True if check result is valid, else false.
|
||||
|
Loading…
Reference in New Issue
Block a user