Refactor world results to remove success reason

This commit is contained in:
Ben Woo 2023-09-10 22:29:42 +08:00
parent 656d9ac208
commit 6f9f9085fd
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8
19 changed files with 205 additions and 351 deletions

View File

@ -51,34 +51,35 @@ public class CloneCommand extends MultiverseCommand {
@CommandCompletion("@mvworlds:scope=both @empty")
@Syntax("<world> <new world name>")
@Description("{@@mv-core.clone.description}")
public void onCloneCommand(MVCommandIssuer issuer,
void onCloneCommand(
MVCommandIssuer issuer,
@Syntax("<world>")
@Description("{@@mv-core.clone.world.description}")
LoadedMultiverseWorld world,
@Syntax("<world>")
@Description("{@@mv-core.clone.world.description}")
LoadedMultiverseWorld world,
@Syntax("<new world name>")
@Description("{@@mv-core.clone.newWorld.description}")
String newWorldName,
@Syntax("<new world name>")
@Description("{@@mv-core.clone.newWorld.description}")
String newWorldName,
@Optional
@Syntax("") // TODO
@Description("{@@mv-core.regen.other.description}")
String[] flags
) {
@Optional
@Syntax("") // TODO
@Description("{@@mv-core.regen.other.description}")
String[] flags) {
ParsedCommandFlags parsedFlags = parseFlags(flags);
issuer.sendInfo(MVCorei18n.CLONE_CLONING, "{world}", world.getName(), "{newworld}", newWorldName);
worldManager.cloneWorld(CloneWorldOptions.fromTo(world, newWorldName)
CloneWorldOptions cloneWorldOptions = CloneWorldOptions.fromTo(world, newWorldName)
.keepWorldConfig(!parsedFlags.hasFlag("--reset-world-config"))
.keepGameRule(!parsedFlags.hasFlag("--reset-gamerules"))
.keepWorldBorder(!parsedFlags.hasFlag("--reset-world-border"))
).onSuccess(newWorld -> {
Logging.fine("World clone success: " + newWorld);
issuer.sendInfo(MVCorei18n.CLONEWORLD_CLONED, "{world}", newWorld.getName());
}).onFailure(failure -> {
Logging.fine("World clone failure: " + failure);
issuer.sendError(failure.getFailureMessage());
});
.keepWorldBorder(!parsedFlags.hasFlag("--reset-world-border"));
worldManager.cloneWorld(cloneWorldOptions)
.onSuccess(newWorld -> {
Logging.fine("World clone success: " + newWorld);
issuer.sendInfo(MVCorei18n.CLONE_SUCCESS, "{world}", newWorld.getName());
}).onFailure(failure -> {
Logging.fine("World clone failure: " + failure);
issuer.sendError(failure.getFailureMessage());
});
}
}

View File

@ -105,7 +105,7 @@ public class CreateCommand extends MultiverseCommand {
.generateStructures(!parsedFlags.hasFlag("--no-structures"))
).onSuccess(newWorld -> {
Logging.fine("World create success: " + newWorld);
issuer.sendInfo(MVCorei18n.CREATEWORLD_CREATED, "{world}", newWorld.getName());
issuer.sendInfo(MVCorei18n.CREATE_SUCCESS, "{world}", newWorld.getName());
}).onFailure(failure -> {
Logging.fine("World create failure: " + failure);
issuer.sendError(failure.getFailureMessage());

View File

@ -53,7 +53,7 @@ public class DeleteCommand extends MultiverseCommand {
worldManager.deleteWorld(worldName)
.onSuccess(deletedWorldName -> {
Logging.fine("World delete success: " + deletedWorldName);
issuer.sendInfo(MVCorei18n.DELETEWORLD_DELETED, "{world}", deletedWorldName);
issuer.sendInfo(MVCorei18n.DELETE_SUCCESS, "{world}", deletedWorldName);
}).onFailure(failure -> {
Logging.fine("World delete failure: " + failure);
issuer.sendError(failure.getFailureMessage());

View File

@ -81,7 +81,7 @@ public class ImportCommand extends MultiverseCommand {
.useSpawnAdjust(parsedFlags.hasFlag("--adjust-spawn"))
).onSuccess(newWorld -> {
Logging.fine("World import success: " + newWorld);
issuer.sendInfo(MVCorei18n.IMPORTWORLD_IMPORTED, "{world}", newWorld.getName());
issuer.sendInfo(MVCorei18n.IMPORT_SUCCESS, "{world}", newWorld.getName());
}).onFailure(failure -> {
Logging.fine("World import failure: " + failure);
issuer.sendError(failure.getFailureMessage());

View File

@ -47,7 +47,7 @@ public class LoadCommand extends MultiverseCommand {
worldManager.loadWorld(worldName)
.onSuccess(newWorld -> {
Logging.fine("World load success: " + newWorld);
issuer.sendInfo(MVCorei18n.LOADWORLD_LOADED, "{world}", newWorld.getName());
issuer.sendInfo(MVCorei18n.LOAD_SUCCESS, "{world}", newWorld.getName());
}).onFailure(failure -> {
Logging.fine("World load failure: " + failure);
issuer.sendError(failure.getFailureMessage());

View File

@ -87,7 +87,7 @@ public class RegenCommand extends MultiverseCommand {
.keepWorldBorder(!parsedFlags.hasFlag("--reset-world-border"))
).onSuccess(newWorld -> {
Logging.fine("World regen success: " + newWorld);
issuer.sendInfo(MVCorei18n.REGENWORLD_REGENERATED, "{world}", newWorld.getName());
issuer.sendInfo(MVCorei18n.REGEN_SUCCESS, "{world}", newWorld.getName());
}).onFailure(failure -> {
Logging.fine("World regen failure: " + failure);
issuer.sendError(failure.getFailureMessage());

View File

@ -44,7 +44,7 @@ public class UnloadCommand extends MultiverseCommand {
worldManager.unloadWorld(world)
.onSuccess(loadedWorld -> {
Logging.fine("World unload success: " + loadedWorld);
issuer.sendInfo(MVCorei18n.UNLOADWORLD_UNLOADED, "{world}", loadedWorld.getName());
issuer.sendInfo(MVCorei18n.UNLOAD_SUCCESS, "{world}", loadedWorld.getName());
}).onFailure(failure -> {
Logging.fine("World unload failure: " + failure);
issuer.sendError(failure.getFailureMessage());

View File

@ -16,6 +16,7 @@ public enum MVCorei18n implements MessageKeyProvider {
// clone command
CLONE_CLONING,
CLONE_SUCCESS,
// Coordinates command
COORDINATES_INFO_TITLE,
@ -34,6 +35,7 @@ public enum MVCorei18n implements MessageKeyProvider {
CREATE_PROPERTIES_GENERATOR,
CREATE_PROPERTIES_STRUCTURES,
CREATE_LOADING,
CREATE_SUCCESS,
// delete command
DELETE_DELETING,
@ -56,13 +58,16 @@ public enum MVCorei18n implements MessageKeyProvider {
// import command
IMPORT_IMPORTING,
IMPORT_SUCCESS,
// load command
LOAD_LOADING,
LOAD_SUCCESS,
// regen command
REGEN_REGENERATING,
REGEN_PROMPT,
REGEN_SUCCESS,
// reload command
RELOAD_RELOADING,
@ -77,6 +82,7 @@ public enum MVCorei18n implements MessageKeyProvider {
// unload command
UNLOAD_UNLOADING,
UNLOAD_SUCCESS,
// debug command
DEBUG_INFO_OFF,
@ -94,46 +100,39 @@ public enum MVCorei18n implements MessageKeyProvider {
ENTRYCHECK_NOWORLDACCESS,
// world manager result
CLONEWORLD_CLONED,
CLONEWORLD_INVALIDWORLDNAME,
CLONEWORLD_WORLDEXISTFOLDER,
CLONEWORLD_WORLDEXISTUNLOADED,
CLONEWORLD_WORLDEXISTLOADED,
CLONEWORLD_COPYFAILED,
CREATEWORLD_CREATED,
CREATEWORLD_INVALIDWORLDNAME,
CREATEWORLD_WORLDEXISTFOLDER,
CREATEWORLD_WORLDEXISTUNLOADED,
CREATEWORLD_WORLDEXISTLOADED,
CREATEWORLD_BUKKITCREATIONFAILED,
DELETEWORLD_DELETED,
DELETE_SUCCESS,
DELETEWORLD_WORLDNONEXISTENT,
DELETEWORLD_LOADFAILED,
DELETEWORLD_WORLDFOLDERNOTFOUND,
DELETEWORLD_FAILEDTODELETEFOLDER,
IMPORTWORLD_IMPORTED,
IMPORTWORLD_INVALIDWORLDNAME,
IMPORTWORLD_WORLDFOLDERINVALID,
IMPORTWORLD_WORLDEXISTUNLOADED,
IMPORTWORLD_WORLDEXISTLOADED,
IMPORTWORLD_BUKKITCREATIONFAILED,
LOADWORLD_LOADED,
LOADWORLD_WORLDALREADYLOADING,
LOADWORLD_WORLDNONEXISTENT,
LOADWORLD_WORLDEXISTFOLDER,
LOADWORLD_WORLDEXISTLOADED,
LOADWORLD_BUKKITCREATIONFAILED,
REGENWORLD_REGENERATED,
REMOVEWORLD_REMOVED,
REMOVEWORLD_WORLDNONEXISTENT,
UNLOADWORLD_UNLOADED,
UNLOADWORLD_WORLDALREADYUNLOADING,
UNLOADWORLD_WORLDNONEXISTENT,
UNLOADWORLD_WORLDUNLOADED,

View File

@ -6,8 +6,8 @@ import com.onarandombox.MultiverseCore.api.BlockSafety;
import com.onarandombox.MultiverseCore.api.LocationManipulation;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.message.MessageReplacement;
import com.onarandombox.MultiverseCore.utils.result.FailureReason;
import com.onarandombox.MultiverseCore.utils.result.Attempt;
import com.onarandombox.MultiverseCore.utils.result.FailureReason;
import com.onarandombox.MultiverseCore.worldnew.config.WorldConfig;
import com.onarandombox.MultiverseCore.worldnew.config.WorldsConfigManager;
import com.onarandombox.MultiverseCore.worldnew.generators.GeneratorProvider;
@ -169,20 +169,20 @@ public class WorldManager {
* @param options The options for customizing the creation of a new world.
* @return The result of the creation.
*/
public Attempt<LoadedMultiverseWorld, CreateWorldResult.Failure> createWorld(CreateWorldOptions options) {
public Attempt<LoadedMultiverseWorld, CreateWorldResult> createWorld(CreateWorldOptions options) {
return validateCreateWorldOptions(options).mapAttempt(this::createValidatedWorld);
}
private Attempt<CreateWorldOptions, CreateWorldResult.Failure> validateCreateWorldOptions(
private Attempt<CreateWorldOptions, CreateWorldResult> validateCreateWorldOptions(
CreateWorldOptions options) {
if (!worldNameChecker.isValidWorldName(options.worldName())) {
return worldActionResult(CreateWorldResult.Failure.INVALID_WORLDNAME, options.worldName());
return worldActionResult(CreateWorldResult.INVALID_WORLDNAME, options.worldName());
} else if (getLoadedWorld(options.worldName()).isDefined()) {
return worldActionResult(CreateWorldResult.Failure.WORLD_EXIST_LOADED, options.worldName());
return worldActionResult(CreateWorldResult.WORLD_EXIST_LOADED, options.worldName());
} else if (getWorld(options.worldName()).isDefined()) {
return worldActionResult(CreateWorldResult.Failure.WORLD_EXIST_UNLOADED, options.worldName());
return worldActionResult(CreateWorldResult.WORLD_EXIST_UNLOADED, options.worldName());
} else if (hasWorldFolder(options.worldName())) {
return worldActionResult(CreateWorldResult.Failure.WORLD_EXIST_FOLDER, options.worldName());
return worldActionResult(CreateWorldResult.WORLD_EXIST_FOLDER, options.worldName());
}
return worldActionResult(options);
}
@ -192,7 +192,7 @@ public class WorldManager {
return worldFolder.exists();
}
private Attempt<LoadedMultiverseWorld, CreateWorldResult.Failure> createValidatedWorld(
private Attempt<LoadedMultiverseWorld, CreateWorldResult> createValidatedWorld(
CreateWorldOptions options) {
String parsedGenerator = parseGenerator(options.worldName(), options.generator());
WorldCreator worldCreator = WorldCreator.name(options.worldName())
@ -202,7 +202,7 @@ public class WorldManager {
.seed(options.seed())
.type(options.worldType());
return createBukkitWorld(worldCreator).fold(
exception -> worldActionResult(CreateWorldResult.Failure.BUKKIT_CREATION_FAILED,
exception -> worldActionResult(CreateWorldResult.BUKKIT_CREATION_FAILED,
options.worldName(), exception),
world -> {
LoadedMultiverseWorld loadedWorld = newLoadedMultiverseWorld(
@ -219,34 +219,34 @@ public class WorldManager {
* @param options The options for customizing the import of an existing world folder.
* @return The result of the import.
*/
public Attempt<LoadedMultiverseWorld, ImportWorldResult.Failure> importWorld(
public Attempt<LoadedMultiverseWorld, ImportWorldResult> importWorld(
ImportWorldOptions options) {
return validateImportWorldOptions(options).mapAttempt(this::doImportWorld);
}
private Attempt<ImportWorldOptions, ImportWorldResult.Failure> validateImportWorldOptions(
private Attempt<ImportWorldOptions, ImportWorldResult> validateImportWorldOptions(
ImportWorldOptions options) {
String worldName = options.worldName();
if (!worldNameChecker.isValidWorldName(worldName)) {
return worldActionResult(ImportWorldResult.Failure.INVALID_WORLDNAME, worldName);
return worldActionResult(ImportWorldResult.INVALID_WORLDNAME, worldName);
} else if (!worldNameChecker.isValidWorldFolder(worldName)) {
return worldActionResult(ImportWorldResult.Failure.WORLD_FOLDER_INVALID, worldName);
return worldActionResult(ImportWorldResult.WORLD_FOLDER_INVALID, worldName);
} else if (isLoadedWorld(worldName)) {
return worldActionResult(ImportWorldResult.Failure.WORLD_EXIST_LOADED, worldName);
return worldActionResult(ImportWorldResult.WORLD_EXIST_LOADED, worldName);
} else if (isWorld(worldName)) {
return worldActionResult(ImportWorldResult.Failure.WORLD_EXIST_UNLOADED, worldName);
return worldActionResult(ImportWorldResult.WORLD_EXIST_UNLOADED, worldName);
}
return worldActionResult(options);
}
private Attempt<LoadedMultiverseWorld, ImportWorldResult.Failure> doImportWorld(
private Attempt<LoadedMultiverseWorld, ImportWorldResult> doImportWorld(
ImportWorldOptions options) {
String parsedGenerator = parseGenerator(options.worldName(), options.generator());
WorldCreator worldCreator = WorldCreator.name(options.worldName())
.environment(options.environment())
.generator(parsedGenerator);
return createBukkitWorld(worldCreator).fold(
exception -> worldActionResult(ImportWorldResult.Failure.BUKKIT_CREATION_FAILED,
exception -> worldActionResult(ImportWorldResult.BUKKIT_CREATION_FAILED,
options.worldName(), exception),
world -> {
LoadedMultiverseWorld loadedWorld = newLoadedMultiverseWorld(world,
@ -302,12 +302,12 @@ public class WorldManager {
* @param worldName The name of the world to load.
* @return The result of the load.
*/
public Attempt<LoadedMultiverseWorld, LoadWorldResult.Failure> loadWorld(@NotNull String worldName) {
public Attempt<LoadedMultiverseWorld, LoadWorldResult> loadWorld(@NotNull String worldName) {
return getWorld(worldName)
.map(this::loadWorld)
.getOrElse(() -> worldNameChecker.isValidWorldFolder(worldName)
? worldActionResult(LoadWorldResult.Failure.WORLD_EXIST_FOLDER, worldName)
: worldActionResult(LoadWorldResult.Failure.WORLD_NON_EXISTENT, worldName));
? worldActionResult(LoadWorldResult.WORLD_EXIST_FOLDER, worldName)
: worldActionResult(LoadWorldResult.WORLD_NON_EXISTENT, worldName));
}
/**
@ -316,29 +316,29 @@ public class WorldManager {
* @param world The world to load.
* @return The result of the load.
*/
public Attempt<LoadedMultiverseWorld, LoadWorldResult.Failure> loadWorld(@NotNull MultiverseWorld world) {
public Attempt<LoadedMultiverseWorld, LoadWorldResult> loadWorld(@NotNull MultiverseWorld world) {
return validateWorldToLoad(world).mapAttempt(this::doLoadWorld);
}
private Attempt<MultiverseWorld, LoadWorldResult.Failure> validateWorldToLoad(
private Attempt<MultiverseWorld, LoadWorldResult> validateWorldToLoad(
@NotNull MultiverseWorld mvWorld) {
if (loadTracker.contains(mvWorld.getName())) {
// This is to prevent recursive calls by WorldLoadEvent
Logging.fine("World already loading: " + mvWorld.getName());
return worldActionResult(LoadWorldResult.Failure.WORLD_ALREADY_LOADING, mvWorld.getName());
return worldActionResult(LoadWorldResult.WORLD_ALREADY_LOADING, mvWorld.getName());
} else if (isLoadedWorld(mvWorld)) {
Logging.severe("World already loaded: " + mvWorld.getName());
return worldActionResult(LoadWorldResult.Failure.WORLD_EXIST_LOADED, mvWorld.getName());
return worldActionResult(LoadWorldResult.WORLD_EXIST_LOADED, mvWorld.getName());
}
return worldActionResult(mvWorld);
}
private Attempt<LoadedMultiverseWorld, LoadWorldResult.Failure> doLoadWorld(@NotNull MultiverseWorld mvWorld) {
private Attempt<LoadedMultiverseWorld, LoadWorldResult> doLoadWorld(@NotNull MultiverseWorld mvWorld) {
return createBukkitWorld(WorldCreator.name(mvWorld.getName())
.environment(mvWorld.getEnvironment())
.generator(Strings.isNullOrEmpty(mvWorld.getGenerator()) ? null : mvWorld.getGenerator())
.seed(mvWorld.getSeed())).fold(
exception -> worldActionResult(LoadWorldResult.Failure.BUKKIT_CREATION_FAILED,
exception -> worldActionResult(LoadWorldResult.BUKKIT_CREATION_FAILED,
mvWorld.getName(), exception),
world -> {
// TODO: Check worldConfig null
@ -361,7 +361,7 @@ public class WorldManager {
* @param world The bukkit world to unload.
* @return The result of the unload action.
*/
public Attempt<MultiverseWorld, UnloadWorldResult.Failure> unloadWorld(@NotNull World world) {
public Attempt<MultiverseWorld, UnloadWorldResult> unloadWorld(@NotNull World world) {
return unloadWorld(world.getName());
}
@ -371,12 +371,12 @@ public class WorldManager {
* @param worldName The name of the world to unload.
* @return The result of the unload action.
*/
public Attempt<MultiverseWorld, UnloadWorldResult.Failure> unloadWorld(@NotNull String worldName) {
public Attempt<MultiverseWorld, UnloadWorldResult> unloadWorld(@NotNull String worldName) {
return getLoadedWorld(worldName)
.map(this::unloadWorld)
.getOrElse(() -> isUnloadedWorld(worldName)
? worldActionResult(UnloadWorldResult.Failure.WORLD_UNLOADED, worldName)
: worldActionResult(UnloadWorldResult.Failure.WORLD_NON_EXISTENT, worldName));
? worldActionResult(UnloadWorldResult.WORLD_UNLOADED, worldName)
: worldActionResult(UnloadWorldResult.WORLD_NON_EXISTENT, worldName));
}
/**
@ -385,23 +385,23 @@ public class WorldManager {
* @param world The multiverse world to unload.
* @return The result of the unload action.
*/
public Attempt<MultiverseWorld, UnloadWorldResult.Failure> unloadWorld(
public Attempt<MultiverseWorld, UnloadWorldResult> unloadWorld(
@NotNull LoadedMultiverseWorld world) {
if (unloadTracker.contains(world.getName())) {
// This is to prevent recursive calls by WorldUnloadEvent
Logging.fine("World already unloading: " + world.getName());
return worldActionResult(UnloadWorldResult.Failure.WORLD_ALREADY_UNLOADING, world.getName());
return worldActionResult(UnloadWorldResult.WORLD_ALREADY_UNLOADING, world.getName());
}
// TODO: removePlayersFromWorld?
return unloadBukkitWorld(world.getBukkitWorld().getOrNull()).fold(
exception -> worldActionResult(UnloadWorldResult.Failure.BUKKIT_UNLOAD_FAILED,
exception -> worldActionResult(UnloadWorldResult.BUKKIT_UNLOAD_FAILED,
world.getName(), exception),
success -> Option.of(loadedWorldsMap.remove(world.getName())).fold(
() -> {
Logging.severe("Failed to remove world from map: " + world.getName());
return worldActionResult(UnloadWorldResult.Failure.WORLD_NON_EXISTENT, world.getName());
return worldActionResult(UnloadWorldResult.WORLD_NON_EXISTENT, world.getName());
},
mvWorld -> {
Logging.fine("Removed MultiverseWorld from map: " + world.getName());
@ -417,11 +417,11 @@ public class WorldManager {
* @param worldName The name of the world to remove.
* @return The result of the remove.
*/
public Attempt<String, RemoveWorldResult.Failure> removeWorld(
public Attempt<String, RemoveWorldResult> removeWorld(
@NotNull String worldName) {
return getWorld(worldName)
.map(this::removeWorld)
.getOrElse(() -> worldActionResult(RemoveWorldResult.Failure.WORLD_NON_EXISTENT, worldName));
.getOrElse(() -> worldActionResult(RemoveWorldResult.WORLD_NON_EXISTENT, worldName));
}
/**
@ -431,7 +431,7 @@ public class WorldManager {
* @param world The multiverse world to remove.
* @return The result of the remove.
*/
public Attempt<String, RemoveWorldResult.Failure> removeWorld(@NotNull MultiverseWorld world) {
public Attempt<String, RemoveWorldResult> removeWorld(@NotNull MultiverseWorld world) {
return getLoadedWorld(world).fold(
() -> removeWorldFromConfig(world),
this::removeWorld);
@ -444,13 +444,10 @@ public class WorldManager {
* @param loadedWorld The multiverse world to remove.
* @return The result of the remove.
*/
public Attempt<String, RemoveWorldResult.Failure> removeWorld(
@NotNull LoadedMultiverseWorld loadedWorld) {
var result = unloadWorld(loadedWorld);
if (result.isFailure()) {
return Attempt.failure(RemoveWorldResult.Failure.UNLOAD_FAILED, result.getFailureMessage());
}
return removeWorldFromConfig(loadedWorld);
public Attempt<String, RemoveWorldResult> removeWorld(@NotNull LoadedMultiverseWorld loadedWorld) {
return unloadWorld(loadedWorld)
.transform(RemoveWorldResult.UNLOAD_FAILED)
.mapAttempt(this::removeWorldFromConfig);
}
/**
@ -459,8 +456,7 @@ public class WorldManager {
* @param world The multiverse world to remove.
* @return The result of the remove.
*/
private Attempt<String, RemoveWorldResult.Failure>
removeWorldFromConfig(@NotNull MultiverseWorld world) {
private Attempt<String, RemoveWorldResult> removeWorldFromConfig(@NotNull MultiverseWorld world) {
// Remove world from config
worldsMap.remove(world.getName());
worldsConfigManager.deleteWorldConfig(world.getName());
@ -476,10 +472,10 @@ public class WorldManager {
* @param worldName The name of the world to delete.
* @return The result of the delete action.
*/
public Attempt<String, DeleteWorldResult.Failure> deleteWorld(@NotNull String worldName) {
public Attempt<String, DeleteWorldResult> deleteWorld(@NotNull String worldName) {
return getWorld(worldName)
.map(this::deleteWorld)
.getOrElse(() -> worldActionResult(DeleteWorldResult.Failure.WORLD_NON_EXISTENT, worldName));
.getOrElse(() -> worldActionResult(DeleteWorldResult.WORLD_NON_EXISTENT, worldName));
}
/**
@ -489,10 +485,10 @@ public class WorldManager {
* @param world The world to delete.
* @return The result of the delete action.
*/
public Attempt<String, DeleteWorldResult.Failure> deleteWorld(@NotNull MultiverseWorld world) {
public Attempt<String, DeleteWorldResult> deleteWorld(@NotNull MultiverseWorld world) {
return getLoadedWorld(world).fold(
() -> loadWorld(world)
.convertReason(DeleteWorldResult.Failure.LOAD_FAILED)
.convertReason(DeleteWorldResult.LOAD_FAILED)
.mapAttempt(this::deleteWorld),
this::deleteWorld);
}
@ -503,24 +499,24 @@ public class WorldManager {
* @param world The multiverse world to delete.
* @return The result of the delete action.
*/
public Attempt<String, DeleteWorldResult.Failure> deleteWorld(@NotNull LoadedMultiverseWorld world) {
public Attempt<String, DeleteWorldResult> deleteWorld(@NotNull LoadedMultiverseWorld world) {
// TODO: Possible config options to keep certain files
AtomicReference<File> worldFolder = new AtomicReference<>();
return validateWorldToDelete(world)
.peek(worldFolder::set)
.mapAttempt(() -> removeWorld(world).transform(DeleteWorldResult.Failure.REMOVE_FAILED))
.mapAttempt(() -> removeWorld(world).transform(DeleteWorldResult.REMOVE_FAILED))
.mapAttempt(() -> filesManipulator.deleteFolder(worldFolder.get()).fold(
exception -> worldActionResult(DeleteWorldResult.Failure.FAILED_TO_DELETE_FOLDER,
exception -> worldActionResult(DeleteWorldResult.FAILED_TO_DELETE_FOLDER,
world.getName(), exception),
success -> worldActionResult(world.getName())));
}
private Attempt<File, DeleteWorldResult.Failure> validateWorldToDelete(
private Attempt<File, DeleteWorldResult> validateWorldToDelete(
@NotNull LoadedMultiverseWorld world) {
File worldFolder = world.getBukkitWorld().map(World::getWorldFolder).getOrNull();
if (worldFolder == null || !worldNameChecker.isValidWorldFolder(worldFolder)) {
Logging.severe("Failed to get world folder for world: " + world.getName());
return worldActionResult(DeleteWorldResult.Failure.WORLD_FOLDER_NOT_FOUND, world.getName());
return worldActionResult(DeleteWorldResult.WORLD_FOLDER_NOT_FOUND, world.getName());
}
return worldActionResult(worldFolder);
}
@ -531,14 +527,15 @@ public class WorldManager {
* @param options The options for customizing the cloning of a world.
* @return The result of the clone.
*/
public Attempt<LoadedMultiverseWorld, CloneWorldResult.Failure> cloneWorld(@NotNull CloneWorldOptions options) {
public Attempt<LoadedMultiverseWorld, CloneWorldResult> cloneWorld(@NotNull CloneWorldOptions options) {
return cloneWorldValidateWorld(options)
.mapAttempt(this::cloneWorldCopyFolder)
.mapAttempt(validatedOptions -> {
ImportWorldOptions importWorldOptions = ImportWorldOptions.worldName(validatedOptions.newWorldName())
ImportWorldOptions importWorldOptions = ImportWorldOptions
.worldName(validatedOptions.newWorldName())
.environment(validatedOptions.world().getEnvironment())
.generator(validatedOptions.world().getGenerator());
return importWorld(importWorldOptions).convertReason(CloneWorldResult.Failure.IMPORT_FAILED);
return importWorld(importWorldOptions).convertReason(CloneWorldResult.IMPORT_FAILED);
})
.onSuccess(newWorld -> {
cloneWorldTransferData(options, newWorld);
@ -546,34 +543,34 @@ public class WorldManager {
});
}
private Attempt<CloneWorldOptions, CloneWorldResult.Failure> cloneWorldValidateWorld(
private Attempt<CloneWorldOptions, CloneWorldResult> cloneWorldValidateWorld(
@NotNull CloneWorldOptions options) {
String newWorldName = options.newWorldName();
if (!worldNameChecker.isValidWorldName(newWorldName)) {
Logging.severe("Invalid world name: " + newWorldName);
return worldActionResult(CloneWorldResult.Failure.INVALID_WORLDNAME, newWorldName);
return worldActionResult(CloneWorldResult.INVALID_WORLDNAME, newWorldName);
}
if (worldNameChecker.isValidWorldFolder(newWorldName)) {
return worldActionResult(CloneWorldResult.Failure.WORLD_EXIST_FOLDER, newWorldName);
return worldActionResult(CloneWorldResult.WORLD_EXIST_FOLDER, newWorldName);
}
if (isLoadedWorld(newWorldName)) {
Logging.severe("World already loaded when attempting to clone: " + newWorldName);
return worldActionResult(CloneWorldResult.Failure.WORLD_EXIST_LOADED, newWorldName);
return worldActionResult(CloneWorldResult.WORLD_EXIST_LOADED, newWorldName);
}
if (isWorld(newWorldName)) {
Logging.severe("World already exist unloaded: " + newWorldName);
return worldActionResult(CloneWorldResult.Failure.WORLD_EXIST_UNLOADED, newWorldName);
return worldActionResult(CloneWorldResult.WORLD_EXIST_UNLOADED, newWorldName);
}
return worldActionResult(options);
}
private Attempt<CloneWorldOptions, CloneWorldResult.Failure> cloneWorldCopyFolder(
private Attempt<CloneWorldOptions, CloneWorldResult> cloneWorldCopyFolder(
@NotNull CloneWorldOptions options) {
// TODO: Check null?
File worldFolder = options.world().getBukkitWorld().map(World::getWorldFolder).getOrNull();
File newWorldFolder = new File(Bukkit.getWorldContainer(), options.newWorldName());
return filesManipulator.copyFolder(worldFolder, newWorldFolder, CLONE_IGNORE_FILES).fold(
exception -> worldActionResult(CloneWorldResult.Failure.COPY_FAILED,
exception -> worldActionResult(CloneWorldResult.COPY_FAILED,
options.world().getName(), exception),
success -> worldActionResult(options));
}
@ -606,7 +603,7 @@ public class WorldManager {
* @param options The options for customizing the regeneration of a world.
* @return The result of the regeneration.
*/
public Attempt<LoadedMultiverseWorld, RegenWorldResult.Failure> regenWorld(@NotNull RegenWorldOptions options) {
public Attempt<LoadedMultiverseWorld, RegenWorldResult> regenWorld(@NotNull RegenWorldOptions options) {
// TODO: Teleport players out of world, and back in after regen
LoadedMultiverseWorld world = options.world();
@ -619,8 +616,8 @@ public class WorldManager {
.worldType(world.getWorldType().getOrElse(WorldType.NORMAL));
return deleteWorld(world)
.convertReason(RegenWorldResult.Failure.DELETE_FAILED)
.mapAttempt(() -> createWorld(createWorldOptions).convertReason(RegenWorldResult.Failure.CREATE_FAILED))
.convertReason(RegenWorldResult.DELETE_FAILED)
.mapAttempt(() -> createWorld(createWorldOptions).convertReason(RegenWorldResult.CREATE_FAILED))
.onSuccess(newWorld -> {
dataTransfer.pasteAllTo(newWorld);
saveWorldsConfig();
@ -632,14 +629,14 @@ public class WorldManager {
}
private <T, F extends FailureReason> Attempt<T, F> worldActionResult(
@NotNull F messageKeyProvider, @NotNull String worldName) {
return Attempt.failure(messageKeyProvider, replaceWorldName(worldName));
@NotNull F failureReason, @NotNull String worldName) {
return Attempt.failure(failureReason, replaceWorldName(worldName));
}
private <T, F extends FailureReason> Attempt<T, F> worldActionResult(
@NotNull F messageKeyProvider, @NotNull String worldName, @NotNull Throwable error) {
@NotNull F failureReason, @NotNull String worldName, @NotNull Throwable error) {
// TODO: Localize error message if its a MultiverseException
return Attempt.failure(messageKeyProvider, replaceWorldName(worldName), replaceError(error.getMessage()));
return Attempt.failure(failureReason, replaceWorldName(worldName), replaceError(error.getMessage()));
}
private MessageReplacement replaceWorldName(@NotNull String worldName) {

View File

@ -9,41 +9,24 @@ import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
/**
* Result of a world clone operation.
*/
public class CloneWorldResult {
public enum Success implements SuccessReason {
CLONED(MVCorei18n.CLONEWORLD_CLONED);
public enum CloneWorldResult implements FailureReason {
INVALID_WORLDNAME(MVCorei18n.CLONEWORLD_INVALIDWORLDNAME),
WORLD_EXIST_FOLDER(MVCorei18n.CLONEWORLD_WORLDEXISTFOLDER),
WORLD_EXIST_UNLOADED(MVCorei18n.CLONEWORLD_WORLDEXISTUNLOADED),
WORLD_EXIST_LOADED(MVCorei18n.CLONEWORLD_WORLDEXISTLOADED),
COPY_FAILED(MVCorei18n.CLONEWORLD_COPYFAILED),
IMPORT_FAILED(null),
MV_WORLD_FAILED(null), // TODO
;
private final MessageKeyProvider message;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
CloneWorldResult(MessageKeyProvider message) {
this.message = message;
}
public enum Failure implements FailureReason {
INVALID_WORLDNAME(MVCorei18n.CLONEWORLD_INVALIDWORLDNAME),
WORLD_EXIST_FOLDER(MVCorei18n.CLONEWORLD_WORLDEXISTFOLDER),
WORLD_EXIST_UNLOADED(MVCorei18n.CLONEWORLD_WORLDEXISTUNLOADED),
WORLD_EXIST_LOADED(MVCorei18n.CLONEWORLD_WORLDEXISTLOADED),
COPY_FAILED(MVCorei18n.CLONEWORLD_COPYFAILED),
IMPORT_FAILED(null),
MV_WORLD_FAILED(null), // TODO
;
private final MessageKeyProvider message;
Failure(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}

View File

@ -9,38 +9,21 @@ import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
/**
* Result of a world creation operation.
*/
public class CreateWorldResult {
public enum Success implements SuccessReason {
CREATED(MVCorei18n.CREATEWORLD_CREATED);
public enum CreateWorldResult implements FailureReason {
INVALID_WORLDNAME(MVCorei18n.CREATEWORLD_INVALIDWORLDNAME),
WORLD_EXIST_FOLDER(MVCorei18n.CREATEWORLD_WORLDEXISTFOLDER),
WORLD_EXIST_UNLOADED(MVCorei18n.CREATEWORLD_WORLDEXISTUNLOADED),
WORLD_EXIST_LOADED(MVCorei18n.CREATEWORLD_WORLDEXISTLOADED),
BUKKIT_CREATION_FAILED(MVCorei18n.CREATEWORLD_BUKKITCREATIONFAILED);
private final MessageKeyProvider message;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
CreateWorldResult(MessageKeyProvider message) {
this.message = message;
}
public enum Failure implements FailureReason {
INVALID_WORLDNAME(MVCorei18n.CREATEWORLD_INVALIDWORLDNAME),
WORLD_EXIST_FOLDER(MVCorei18n.CREATEWORLD_WORLDEXISTFOLDER),
WORLD_EXIST_UNLOADED(MVCorei18n.CREATEWORLD_WORLDEXISTUNLOADED),
WORLD_EXIST_LOADED(MVCorei18n.CREATEWORLD_WORLDEXISTLOADED),
BUKKIT_CREATION_FAILED(MVCorei18n.CREATEWORLD_BUKKITCREATIONFAILED);
private final MessageKeyProvider message;
Failure(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}

View File

@ -9,38 +9,21 @@ import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
/**
* Result of a world deletion operation.
*/
public class DeleteWorldResult {
public enum Success implements SuccessReason {
DELETED(MVCorei18n.DELETEWORLD_DELETED);
public enum DeleteWorldResult implements FailureReason {
WORLD_NON_EXISTENT(MVCorei18n.DELETEWORLD_WORLDNONEXISTENT),
LOAD_FAILED(MVCorei18n.DELETEWORLD_LOADFAILED),
WORLD_FOLDER_NOT_FOUND(MVCorei18n.DELETEWORLD_WORLDFOLDERNOTFOUND),
REMOVE_FAILED(null),
FAILED_TO_DELETE_FOLDER(MVCorei18n.DELETEWORLD_FAILEDTODELETEFOLDER);
private final MessageKeyProvider message;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
DeleteWorldResult(MessageKeyProvider message) {
this.message = message;
}
public enum Failure implements FailureReason {
WORLD_NON_EXISTENT(MVCorei18n.DELETEWORLD_WORLDNONEXISTENT),
LOAD_FAILED(MVCorei18n.DELETEWORLD_LOADFAILED),
WORLD_FOLDER_NOT_FOUND(MVCorei18n.DELETEWORLD_WORLDFOLDERNOTFOUND),
REMOVE_FAILED(null),
FAILED_TO_DELETE_FOLDER(MVCorei18n.DELETEWORLD_FAILEDTODELETEFOLDER);
private final MessageKeyProvider message;
Failure(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}

View File

@ -4,43 +4,25 @@ import co.aikar.locales.MessageKey;
import co.aikar.locales.MessageKeyProvider;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import com.onarandombox.MultiverseCore.utils.result.FailureReason;
import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
/**
* Result of a world import operation.
*/
public class ImportWorldResult {
public enum Success implements SuccessReason {
IMPORTED(MVCorei18n.IMPORTWORLD_IMPORTED);
public enum ImportWorldResult implements FailureReason {
INVALID_WORLDNAME(MVCorei18n.IMPORTWORLD_INVALIDWORLDNAME),
WORLD_FOLDER_INVALID(MVCorei18n.IMPORTWORLD_WORLDFOLDERINVALID),
WORLD_EXIST_UNLOADED(MVCorei18n.IMPORTWORLD_WORLDEXISTUNLOADED),
WORLD_EXIST_LOADED(MVCorei18n.IMPORTWORLD_WORLDEXISTLOADED),
BUKKIT_CREATION_FAILED(MVCorei18n.IMPORTWORLD_BUKKITCREATIONFAILED);
private final MessageKeyProvider message;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
ImportWorldResult(MessageKeyProvider message) {
this.message = message;
}
public enum Failure implements FailureReason {
INVALID_WORLDNAME(MVCorei18n.IMPORTWORLD_INVALIDWORLDNAME),
WORLD_FOLDER_INVALID(MVCorei18n.IMPORTWORLD_WORLDFOLDERINVALID),
WORLD_EXIST_UNLOADED(MVCorei18n.IMPORTWORLD_WORLDEXISTUNLOADED),
WORLD_EXIST_LOADED(MVCorei18n.IMPORTWORLD_WORLDEXISTLOADED),
BUKKIT_CREATION_FAILED(MVCorei18n.IMPORTWORLD_BUKKITCREATIONFAILED);
private final MessageKeyProvider message;
Failure(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}

View File

@ -4,43 +4,25 @@ import co.aikar.locales.MessageKey;
import co.aikar.locales.MessageKeyProvider;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import com.onarandombox.MultiverseCore.utils.result.FailureReason;
import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
/**
* Result of a world loading operation.
*/
public class LoadWorldResult {
public enum Success implements SuccessReason {
LOADED(MVCorei18n.LOADWORLD_LOADED);
public enum LoadWorldResult implements FailureReason {
WORLD_ALREADY_LOADING(MVCorei18n.LOADWORLD_WORLDALREADYLOADING),
WORLD_NON_EXISTENT(MVCorei18n.LOADWORLD_WORLDNONEXISTENT),
WORLD_EXIST_FOLDER(MVCorei18n.LOADWORLD_WORLDEXISTFOLDER),
WORLD_EXIST_LOADED(MVCorei18n.LOADWORLD_WORLDEXISTLOADED),
BUKKIT_CREATION_FAILED(MVCorei18n.LOADWORLD_BUKKITCREATIONFAILED);
private final MessageKeyProvider message;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
LoadWorldResult(MessageKeyProvider message) {
this.message = message;
}
public enum Failure implements FailureReason {
WORLD_ALREADY_LOADING(MVCorei18n.LOADWORLD_WORLDALREADYLOADING),
WORLD_NON_EXISTENT(MVCorei18n.LOADWORLD_WORLDNONEXISTENT),
WORLD_EXIST_FOLDER(MVCorei18n.LOADWORLD_WORLDEXISTFOLDER),
WORLD_EXIST_LOADED(MVCorei18n.LOADWORLD_WORLDEXISTLOADED),
BUKKIT_CREATION_FAILED(MVCorei18n.LOADWORLD_BUKKITCREATIONFAILED);
private final MessageKeyProvider message;
Failure(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}

View File

@ -2,42 +2,23 @@ package com.onarandombox.MultiverseCore.worldnew.results;
import co.aikar.locales.MessageKey;
import co.aikar.locales.MessageKeyProvider;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import com.onarandombox.MultiverseCore.utils.result.FailureReason;
import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
/**
* Result of a world regeneration operation.
*/
public class RegenWorldResult {
public enum Success implements SuccessReason {
REGENERATED(MVCorei18n.REGENWORLD_REGENERATED);
public enum RegenWorldResult implements FailureReason {
DELETE_FAILED(null),
CREATE_FAILED(null);
private final MessageKeyProvider message;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
RegenWorldResult(MessageKeyProvider message) {
this.message = message;
}
public enum Failure implements FailureReason {
DELETE_FAILED(null),
CREATE_FAILED(null);
private final MessageKeyProvider message;
Failure(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}

View File

@ -4,40 +4,22 @@ import co.aikar.locales.MessageKey;
import co.aikar.locales.MessageKeyProvider;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import com.onarandombox.MultiverseCore.utils.result.FailureReason;
import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
/**
* Result of a world removal operation.
*/
public class RemoveWorldResult {
public enum Success implements SuccessReason {
REMOVED(MVCorei18n.REMOVEWORLD_REMOVED);
public enum RemoveWorldResult implements FailureReason {
WORLD_NON_EXISTENT(MVCorei18n.REMOVEWORLD_WORLDNONEXISTENT),
UNLOAD_FAILED(null);
private final MessageKeyProvider message;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
RemoveWorldResult(MessageKeyProvider message) {
this.message = message;
}
public enum Failure implements FailureReason {
WORLD_NON_EXISTENT(MVCorei18n.REMOVEWORLD_WORLDNONEXISTENT),
UNLOAD_FAILED(null);
private final MessageKeyProvider message;
Failure(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}

View File

@ -4,42 +4,24 @@ import co.aikar.locales.MessageKey;
import co.aikar.locales.MessageKeyProvider;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import com.onarandombox.MultiverseCore.utils.result.FailureReason;
import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
/**
* Result of a world unloading operation.
*/
public class UnloadWorldResult {
public enum Success implements SuccessReason {
UNLOADED(MVCorei18n.UNLOADWORLD_UNLOADED);
public enum UnloadWorldResult implements FailureReason {
WORLD_ALREADY_UNLOADING(MVCorei18n.UNLOADWORLD_WORLDALREADYUNLOADING),
WORLD_NON_EXISTENT(MVCorei18n.UNLOADWORLD_WORLDNONEXISTENT),
WORLD_UNLOADED(MVCorei18n.UNLOADWORLD_WORLDUNLOADED),
BUKKIT_UNLOAD_FAILED(MVCorei18n.UNLOADWORLD_BUKKITUNLOADFAILED);
private final MessageKeyProvider message;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
UnloadWorldResult(MessageKeyProvider message) {
this.message = message;
}
public enum Failure implements FailureReason {
WORLD_ALREADY_UNLOADING(MVCorei18n.UNLOADWORLD_WORLDALREADYUNLOADING),
WORLD_NON_EXISTENT(MVCorei18n.UNLOADWORLD_WORLDNONEXISTENT),
WORLD_UNLOADED(MVCorei18n.UNLOADWORLD_WORLDUNLOADED),
BUKKIT_UNLOAD_FAILED(MVCorei18n.UNLOADWORLD_BUKKITUNLOADFAILED);
private final MessageKeyProvider message;
Failure(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}

View File

@ -13,6 +13,7 @@ mv-core.clone.description=Clones a world.
mv-core.clone.world.description=The target world to clone.
mv-core.clone.newWorld.description=The new cloned world name.
mv-core.clone.cloning=Cloning world '{world}' to '{newworld}'...
mv-core.clone.success=&aWorld cloned to '{world}'!
# /mv confirm
mv-core.confirm.description=Confirms dangerous commands before executing them.
@ -39,6 +40,7 @@ mv-core.create.properties.adjustspawn=- Adjust Spawn: &f{adjustSpawn}
mv-core.create.properties.generator=- Generator: &f{generator}
mv-core.create.properties.structures=- Structures: &f{structures}
mv-core.create.loading=Creating world...
mv-core.create.success=&aWorld '{world}' created!
# /mv debug
mv-core.debug.info.description=Show the current debug level.
@ -52,6 +54,7 @@ mv-core.debug.change.level.description=Debug level to set to.
mv-core.delete.description=Deletes a world on your server PERMANENTLY.
mv-core.delete.deleting=Deleting world '{world}'...
mv-core.delete.prompt=Are you sure you want to delete world '{world}'?
mv-core.delete.success=&aWorld '{world}' deleted!
# /mv dumps
mv-core.dumps.description=Dumps version info to the console or paste services
@ -78,11 +81,13 @@ mv-core.import.name.description=Name of the world folder.
mv-core.import.env.description=The world's environment. See: /mv env
mv-core.import.other.description=Other world settings. See: https://gg.gg/nn8c2
mv-core.import.importing=Starting import of world '{world}'...
mv-core.import.success=&aWorld '{world}' imported!
# /mv load
mv-core.load.description=Loads a world. World must be already in worlds.yml, else please use /mv import.
mv-core.load.world.description=Name of world you want to load.
mv-core.load.loading=Loading world '{world}'...
mv-core.load.success=&aWorld '{world}' loaded!
# /mv regen
mv-core.regen.description=Regenerates a world on your server. The previous state will be lost PERMANENTLY.
@ -90,6 +95,7 @@ mv-core.regen.world.description=World that you want to regen.
mv-core.regen.other.description=Other world settings. See: http://gg.gg/nn8lk
mv-core.regen.regenerating=Regenerating world '{world}'...
mv-core.regen.prompt=Are you sure you want to regenerate world '{world}'?
mv-core.regen.success=&aWorld '{world}' regenerated!
# /mv reload
mv-core.reload.description=Reloads config files for all Multiverse modules.
@ -99,6 +105,7 @@ mv-core.reload.success=&aReload complete!
# /mv remove
mv-core.remove.description=Unloads a world from Multiverse and removes it from worlds.yml. This does NOT delete the world folder.
mv-core.remove.world.description=World you want to remove from MV's knowledge.
mv-core.remove.success=&aWorld '{world}' removed!
# /mv
mv-core.root.title=&a{name} version {version}
@ -114,6 +121,7 @@ mv-core.teleport.success=Teleporting {player} to {destination}...
mv-core.unload.description=Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.
mv-core.unload.world.description=Name of the world you want to unload.
mv-core.unload.unloading=Unloading world '{world}'...
mv-core.unload.success=&aWorld '{world}' unloaded!
# /mv usage
mv-core.usage.description=Show Multiverse-Core command usage.
@ -130,46 +138,37 @@ mv-core.entrycheck.exceedplayerlimit=the world has reached its player limit.
mv-core.entrycheck.noworldaccess=you do not have permissions to access the world.
# world manager result
mv-core.cloneworld.cloned=&aWorld cloned to '{world}'!
mv-core.cloneworld.invalidworldname=World '{world}' contains invalid characters!
mv-core.cloneworld.worldexistfolder=World '{world}' exists in server folders! You need to delete it first before cloning.
mv-core.cloneworld.worldexistunloaded=World '{world}' already exists and it's unloaded! You need to delete it first before cloning.
mv-core.cloneworld.worldexistloaded=World '{world}' already exists! You need to delete it first before cloning.
mv-core.cloneworld.copyfailed=Failed to copy world to '{world}': {error}\n&fSee console for more details.
mv-core.createworld.created=&aWorld '{world}' created!
mv-core.createworld.invalidworldname=World '{world}' contains invalid characters!
mv-core.createworld.worldexistfolder=World '{world}' already exists in server folders!&f Type '&a/mv import {world} <environment>&f' if you wish to import it.
mv-core.createworld.worldexistunloaded=World '{world}' already exists, but it's not loaded!&f Type '&a/mv load {world}&f' if you wish to load it.
mv-core.createworld.worldexistloaded=World '{world}' already exists!
mv-core.createworld.bukkitcreationfailed=Bukkit failed to create world '{world}': {error}\n&fSee console for more details.
mv-core.deleteworld.deleted=&aWorld '{world}' deleted!
mv-core.deleteworld.worldnonexistent=World '{world}' not found!
mv-core.deleteworld.loadfailed=Unable to load world '{world}', does the world folder exist?&f You can run '&a/mv remove {world}&f' to remove it from Multiverse, or attempt to load again with '&a/mv load {world}&f'.
mv-core.deleteworld.worldfoldernotfound=World '{world}' folder not found!
mv-core.deleteworld.failedtodeletefolder=Failed to delete world folder '{world}': {error}\n&fSee console for more details.
mv-core.importworld.imported=&aWorld '{world}' imported!
mv-core.importworld.invalidworldname=World '{world}' contains invalid characters!
mv-core.importworld.worldexistunloaded=World '{world}' already exists, but it's not loaded!&f Type '&a/mv load {world}&f' if you wish to load it.
mv-core.importworld.worldexistloaded=World '{world}' already exists!
mv-core.importworld.worldfolderinvalid=World '{world}' folder contents does not seem to be a valid world!
mv-core.importworld.bukkitcreationfailed=Bukkit failed to import world '{world}': {error}\n&fSee console for more details.
mv-core.loadworld.loaded=&aWorld '{world}' loaded!
mv-core.loadworld.worldalreadyloading=World '{world}' is already loading! Please wait...
mv-core.loadworld.worldnonexistent=World '{world}' not found! Use '&a/mv create {world} <environment>&f' to create it.
mv-core.loadworld.worldexistfolder=World '{world}' exists in server folders, but it's not known to Multiverse!&f Type '&a/mv import {world} <environment>&f' if you wish to import it.
mv-core.loadworld.worldexistloaded=World '{world}' is already loaded!
mv-core.loadworld.bukkitcreationfailed=Bukkit failed to load world '{world}': {error}\n&fSee console for more details.
mv-core.regenworld.regenerated=&aWorld '{world}' regenerated!
mv-core.removeworld.removed=&aWorld '{world}' removed!
mv-core.removeworld.worldnonexistent=World '{world}' not found!
mv-core.unloadworld.unloaded=&aWorld '{world}' unloaded!
mv-core.unloadworld.worldalreadyunloading=World '{world}' is already unloading! Please wait...
mv-core.unloadworld.worldnonexistent=World '{world}' does not exist!
mv-core.unloadworld.worldunloaded=World '{world}' is already unloaded!

View File

@ -202,7 +202,7 @@ class LocalizationTest : TestWithMockBukkit() {
private val messageString = "Hello $replacementKey!"
private val replacedMessageString = messageString.replace(replacementKey, replacementValue)
private val message = MVCorei18n.CLONEWORLD_CLONED
private val message = MVCorei18n.CLONE_SUCCESS
.bundle(messageString, replace(replacementKey).with(replacementValue))
@Test