Implement locale error messages for wm result

This commit is contained in:
Ben Woo 2023-09-05 18:57:35 +08:00
parent 8fc2371077
commit eb5bb4e234
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8
11 changed files with 250 additions and 97 deletions

View File

@ -72,7 +72,6 @@ public class CreateCommand extends MultiverseCommand {
@Description("{@@mv-core.create.description}")
public void onCreateCommand(MVCommandIssuer issuer,
@Conditions("worldname:scope=new")
@Syntax("<name>")
@Description("{@@mv-core.create.name.description}")
String worldName,

View File

@ -36,13 +36,9 @@ public enum MVCorei18n implements MessageKeyProvider {
CREATE_PROPERTIES_GENERATOR,
CREATE_PROPERTIES_STRUCTURES,
CREATE_LOADING,
CREATE_FAILED,
CREATE_SUCCESS,
// delete command
DELETE_DELETING,
DELETE_FAILED,
DELETE_SUCCESS,
DELETE_PROMPT,
// Dumps command
@ -56,13 +52,9 @@ public enum MVCorei18n implements MessageKeyProvider {
// import command
IMPORT_IMPORTING,
IMPORT_FAILED,
IMPORT_SUCCESS,
// load command
LOAD_LOADING,
LOAD_FAILED,
LOAD_SUCCESS,
// regen command
REGEN_REGENERATING,
@ -74,10 +66,6 @@ public enum MVCorei18n implements MessageKeyProvider {
RELOAD_RELOADING,
RELOAD_SUCCESS,
// remove command
REMOVE_FAILED,
REMOVE_SUCCESS,
// root MV command
ROOT_TITLE,
ROOT_HELP,
@ -87,8 +75,6 @@ public enum MVCorei18n implements MessageKeyProvider {
// unload command
UNLOAD_UNLOADING,
UNLOAD_FAILURE,
UNLOAD_SUCCESS,
// debug command
DEBUG_INFO_OFF,
@ -105,6 +91,42 @@ public enum MVCorei18n implements MessageKeyProvider {
ENTRYCHECK_EXCEEDPLAYERLIMIT,
ENTRYCHECK_NOWORLDACCESS,
// world manager result
CREATEWORLD_CREATED,
CREATEWORLD_INVALIDWORLDNAME,
CREATEWORLD_WORLDEXISTFOLDER,
CREATEWORLD_WORLDEXISTOFFLINE,
CREATEWORLD_WORLDEXISTLOADED,
CREATEWORLD_BUKKITCREATIONFAILED,
DELETEWORLD_DELETED,
DELETEWORLD_WORLDNONEXISTENT,
DELETEWORLD_WORLDFOLDERNOTFOUND,
DELETEWORLD_FAILEDTODELETEFOLDER,
IMPORTWORLD_IMPORTED,
IMPORTWORLD_INVALIDWORLDNAME,
IMPORTWORLD_WORLDFOLDERINVALID,
IMPORTWORLD_WORLDEXISTOFFLINE,
IMPORTWORLD_WORLDEXISTLOADED,
IMPORTWORLD_BUKKITCREATIONFAILED,
LOADWORLD_LOADED,
LOADWORLD_WORLDALREADYLOADING,
LOADWORLD_WORLDNONEXISTENT,
LOADWORLD_WORLDEXISTFOLDER,
LOADWORLD_WORLDEXISTLOADED,
LOADWORLD_BUKKITCREATIONFAILED,
REMOVEWORLD_REMOVED,
REMOVEWORLD_WORLDNONEXISTENT,
UNLOADWORLD_UNLOADED,
UNLOADWORLD_WORLDALREADYUNLOADING,
UNLOADWORLD_WORLDNONEXISTENT,
UNLOADWORLD_WORLDOFFLINE,
UNLOADWORLD_BUKKITUNLOADFAILED,
// generic
GENERIC_SUCCESS,
GENERIC_FAILURE

View File

@ -18,6 +18,7 @@ import com.onarandombox.MultiverseCore.worldnew.results.ImportWorldResult;
import com.onarandombox.MultiverseCore.worldnew.results.LoadWorldResult;
import com.onarandombox.MultiverseCore.worldnew.results.RemoveWorldResult;
import com.onarandombox.MultiverseCore.worldnew.results.UnloadWorldResult;
import com.onarandombox.MultiverseCore.worldnew.results.WorldFailureReason;
import io.vavr.control.Option;
import jakarta.inject.Inject;
import org.bukkit.Bukkit;
@ -36,6 +37,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.onarandombox.MultiverseCore.utils.message.MessageReplacement.replace;
@Service
public class WorldManager {
@ -119,20 +122,20 @@ public class WorldManager {
*/
public Result<CreateWorldResult.Success, CreateWorldResult.Failure> createWorld(CreateWorldOptions options) {
if (!worldNameChecker.isValidWorldName(options.worldName())) {
return Result.failure(CreateWorldResult.Failure.INVALID_WORLDNAME);
return Result.failure(CreateWorldResult.Failure.INVALID_WORLDNAME, replace("{world}").with(options.worldName()));
}
if (getMVWorld(options.worldName()).isDefined()) {
return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_LOADED);
return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_LOADED, replace("{world}").with(options.worldName()));
}
if (getOfflineWorld(options.worldName()).isDefined()) {
return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_OFFLINE);
return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_OFFLINE, replace("{world}").with(options.worldName()));
}
File worldFolder = new File(Bukkit.getWorldContainer(), options.worldName());
if (worldFolder.exists()) {
return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_FOLDER);
return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_FOLDER, replace("{world}").with(options.worldName()));
}
String parsedGenerator = Strings.isNullOrEmpty(options.generator())
@ -151,7 +154,7 @@ public class WorldManager {
this.loadTracker.remove(options.worldName());
if (world == null) {
Logging.severe("Failed to create world: " + options.worldName());
return Result.failure(CreateWorldResult.Failure.BUKKIT_CREATION_FAILED);
return Result.failure(CreateWorldResult.Failure.BUKKIT_CREATION_FAILED, replace("{world}").with(options.worldName()));
}
Logging.fine("Loaded bukkit world: " + world.getName());
@ -159,24 +162,24 @@ public class WorldManager {
MVWorld mvWorld = newMVWorld(world);
mvWorld.getWorldConfig().setGenerator(Strings.isNullOrEmpty(parsedGenerator) ? "" : options.generator());
saveWorldsConfig();
return Result.success(CreateWorldResult.Success.CREATED);
return Result.success(CreateWorldResult.Success.CREATED, replace("{world}").with(world.getName()));
}
public Result<ImportWorldResult.Success, ImportWorldResult.Failure> importWorld(ImportWorldOptions options) {
if (!worldNameChecker.isValidWorldName(options.worldName())) {
return Result.failure(ImportWorldResult.Failure.INVALID_WORLDNAME);
return Result.failure(ImportWorldResult.Failure.INVALID_WORLDNAME, replace("{world}").with(options.worldName()));
}
if (!worldNameChecker.isValidWorldFolder(options.worldName())) {
return Result.failure(ImportWorldResult.Failure.WORLD_FOLDER_INVALID);
return Result.failure(ImportWorldResult.Failure.WORLD_FOLDER_INVALID, replace("{world}").with(options.worldName()));
}
if (isMVWorld(options.worldName())) {
return Result.failure(ImportWorldResult.Failure.WORLD_EXIST_LOADED);
return Result.failure(ImportWorldResult.Failure.WORLD_EXIST_LOADED, replace("{world}").with(options.worldName()));
}
if (isOfflineWorld(options.worldName())) {
return Result.failure(ImportWorldResult.Failure.WORLD_EXIST_OFFLINE);
return Result.failure(ImportWorldResult.Failure.WORLD_EXIST_OFFLINE, replace("{world}").with(options.worldName()));
}
String parsedGenerator = Strings.isNullOrEmpty(options.generator())
@ -192,7 +195,7 @@ public class WorldManager {
this.loadTracker.remove(options.worldName());
if (world == null) {
Logging.severe("Failed to create world: " + options.worldName());
return Result.failure(ImportWorldResult.Failure.BUKKIT_CREATION_FAILED);
return Result.failure(ImportWorldResult.Failure.BUKKIT_CREATION_FAILED, replace("{world}").with(options.worldName()));
}
Logging.fine("Loaded bukkit world: " + world.getName());
@ -200,7 +203,7 @@ public class WorldManager {
MVWorld mvWorld = newMVWorld(world);
mvWorld.getWorldConfig().setGenerator(Strings.isNullOrEmpty(parsedGenerator) ? "" : options.generator());
saveWorldsConfig();
return Result.success(ImportWorldResult.Success.IMPORTED);
return Result.success(ImportWorldResult.Success.IMPORTED, replace("{world}").with(options.worldName()));
}
private MVWorld newMVWorld(World world) {
@ -217,19 +220,24 @@ public class WorldManager {
public Result<LoadWorldResult.Success, LoadWorldResult.Failure> loadWorld(@NotNull String worldName) {
return getOfflineWorld(worldName)
.map(this::loadWorld)
.getOrElse(() -> Result.failure(LoadWorldResult.Failure.WORLD_NON_EXISTENT));
.getOrElse(() -> {
if (worldNameChecker.isValidWorldFolder(worldName)) {
return Result.failure(LoadWorldResult.Failure.WORLD_EXIST_FOLDER, replace("{world}").with(worldName));
}
return Result.failure(LoadWorldResult.Failure.WORLD_NON_EXISTENT, replace("{world}").with(worldName));
});
}
public Result<LoadWorldResult.Success, LoadWorldResult.Failure> loadWorld(@NotNull OfflineWorld offlineWorld) {
if (loadTracker.contains(offlineWorld.getName())) {
// This is to prevent recursive calls by WorldLoadEvent
Logging.fine("World already loading: " + offlineWorld.getName());
return Result.failure(LoadWorldResult.Failure.WORLD_ALREADY_LOADING);
return Result.failure(LoadWorldResult.Failure.WORLD_ALREADY_LOADING, replace("{world}").with(offlineWorld.getName()));
}
if (isMVWorld(offlineWorld)) {
Logging.severe("World already loaded: " + offlineWorld.getName());
return Result.failure(LoadWorldResult.Failure.WORLD_EXIST_LOADED);
return Result.failure(LoadWorldResult.Failure.WORLD_EXIST_LOADED, replace("{world}").with(offlineWorld.getName()));
}
// TODO: Reduce copy paste from createWorld method
@ -242,7 +250,7 @@ public class WorldManager {
this.loadTracker.remove(offlineWorld.getName());
if (world == null) {
Logging.severe("Failed to create world: " + offlineWorld.getName());
return Result.failure(LoadWorldResult.Failure.BUKKIT_CREATION_FAILED);
return Result.failure(LoadWorldResult.Failure.BUKKIT_CREATION_FAILED, replace("{world}").with(offlineWorld.getName()));
}
Logging.fine("Loaded bukkit world: " + world.getName());
@ -252,26 +260,29 @@ public class WorldManager {
worldsMap.put(mvWorld.getName(), mvWorld);
saveWorldsConfig();
return Result.success(LoadWorldResult.Success.LOADED);
return Result.success(LoadWorldResult.Success.LOADED, replace("{world}").with(mvWorld.getName()));
}
public Result<UnloadWorldResult.Success, UnloadWorldResult.Failure> unloadWorld(@NotNull World world) {
return getMVWorld(world)
.map(this::unloadWorld)
.getOrElse(() -> Result.failure(UnloadWorldResult.Failure.WORLD_NON_EXISTENT));
return unloadWorld(world.getName());
}
public Result<UnloadWorldResult.Success, UnloadWorldResult.Failure> unloadWorld(@NotNull String worldName) {
return getMVWorld(worldName)
.map(this::unloadWorld)
.getOrElse(() -> Result.failure(UnloadWorldResult.Failure.WORLD_NON_EXISTENT));
.getOrElse(() -> {
if (isOfflineOnlyWorld(worldName)) {
return Result.failure(UnloadWorldResult.Failure.WORLD_OFFLINE, replace("{world}").with(worldName));
}
return Result.failure(UnloadWorldResult.Failure.WORLD_NON_EXISTENT, replace("{world}").with(worldName));
});
}
public Result<UnloadWorldResult.Success, UnloadWorldResult.Failure> unloadWorld(@NotNull MVWorld world) {
if (unloadTracker.contains(world.getName())) {
// This is to prevent recursive calls by WorldUnloadEvent
Logging.fine("World already unloading: " + world.getName());
return Result.failure(UnloadWorldResult.Failure.WORLD_ALREADY_UNLOADING);
return Result.failure(UnloadWorldResult.Failure.WORLD_ALREADY_UNLOADING, replace("{world}").with(world.getName()));
}
World bukkitWorld = world.getBukkitWorld().getOrNull();
@ -281,26 +292,26 @@ public class WorldManager {
unloadTracker.remove(world.getName());
if (!unloadSuccess) {
Logging.severe("Failed to unload world: " + world.getName());
return Result.failure(UnloadWorldResult.Failure.BUKKIT_UNLOAD_FAILED);
return Result.failure(UnloadWorldResult.Failure.BUKKIT_UNLOAD_FAILED, replace("{world}").with(world.getName()));
}
MVWorld mvWorld = worldsMap.remove(world.getName());
if (mvWorld == null) {
Logging.severe("Failed to remove world from map: " + world.getName());
return Result.failure(UnloadWorldResult.Failure.WORLD_NON_EXISTENT);
return Result.failure(UnloadWorldResult.Failure.WORLD_NON_EXISTENT, replace("{world}").with(world.getName()));
}
Logging.fine("Unloaded world: " + world.getName());
mvWorld.getWorldConfig().deferenceMVWorld();
return Result.success(UnloadWorldResult.Success.UNLOADED);
return Result.success(UnloadWorldResult.Success.UNLOADED, replace("{world}").with(world.getName()));
}
public Result<RemoveWorldResult.Success, UnloadWorldResult.Failure> removeWorld(@NotNull String worldName) {
public Result<RemoveWorldResult.Success, WorldFailureReason> removeWorld(@NotNull String worldName) {
return getOfflineWorld(worldName)
.map(this::removeWorld)
.getOrElse(() -> Result.failure(RemoveWorldResult.Failure.WORLD_NON_EXISTENT));
.getOrElse(() -> Result.failure(RemoveWorldResult.Failure.WORLD_NON_EXISTENT, replace("{world}").with(worldName)));
}
public Result<RemoveWorldResult.Success, UnloadWorldResult.Failure> removeWorld(@NotNull OfflineWorld world) {
public Result<RemoveWorldResult.Success, WorldFailureReason> removeWorld(@NotNull OfflineWorld world) {
MVWorld mvWorld = getMVWorld(world).getOrNull();
if (mvWorld != null) {
var result = unloadWorld(mvWorld);
@ -317,17 +328,17 @@ public class WorldManager {
return Result.success(RemoveWorldResult.Success.REMOVED);
}
public Result<DeleteWorldResult.Success, UnloadWorldResult.Failure> deleteWorld(@NotNull String worldName) {
public Result<DeleteWorldResult.Success, WorldFailureReason> deleteWorld(@NotNull String worldName) {
return getMVWorld(worldName)
.map(this::deleteWorld)
.getOrElse(() -> Result.failure(DeleteWorldResult.Failure.WORLD_NON_EXISTENT));
.getOrElse(() -> Result.failure(DeleteWorldResult.Failure.WORLD_NON_EXISTENT, replace("{world}").with(worldName)));
}
public Result<DeleteWorldResult.Success, UnloadWorldResult.Failure> deleteWorld(@NotNull MVWorld world) {
public Result<DeleteWorldResult.Success, WorldFailureReason> deleteWorld(@NotNull MVWorld 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 Result.failure(DeleteWorldResult.Failure.WORLD_FOLDER_NOT_FOUND);
return Result.failure(DeleteWorldResult.Failure.WORLD_FOLDER_NOT_FOUND, replace("{world}").with(world.getName()));
}
var result = removeWorld(world);
@ -339,10 +350,10 @@ public class WorldManager {
// TODO: Config options to keep certain files
if (!FileUtils.deleteFolder(worldFolder)) {
Logging.severe("Failed to delete world folder: " + worldFolder);
return Result.failure(DeleteWorldResult.Failure.FAILED_TO_DELETE_FOLDER);
return Result.failure(DeleteWorldResult.Failure.FAILED_TO_DELETE_FOLDER, replace("{world}").with(world.getName()));
}
return Result.success(DeleteWorldResult.Success.DELETED);
return Result.success(DeleteWorldResult.Success.DELETED, replace("{world}").with(world.getName()));
}
public List<String> getPotentialWorlds() {

View File

@ -8,15 +8,27 @@ import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
public class CreateWorldResult {
public enum Success implements SuccessReason {
CREATED
CREATED(MVCorei18n.CREATEWORLD_CREATED)
;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}
public enum Failure implements FailureReason {
INVALID_WORLDNAME(MVCorei18n.GENERIC_FAILURE),
WORLD_EXIST_FOLDER(MVCorei18n.GENERIC_FAILURE),
WORLD_EXIST_OFFLINE(MVCorei18n.GENERIC_FAILURE),
WORLD_EXIST_LOADED(MVCorei18n.GENERIC_FAILURE),
BUKKIT_CREATION_FAILED(MVCorei18n.GENERIC_FAILURE),
public enum Failure implements WorldFailureReason {
INVALID_WORLDNAME(MVCorei18n.CREATEWORLD_INVALIDWORLDNAME),
WORLD_EXIST_FOLDER(MVCorei18n.CREATEWORLD_WORLDEXISTFOLDER),
WORLD_EXIST_OFFLINE(MVCorei18n.CREATEWORLD_WORLDEXISTOFFLINE),
WORLD_EXIST_LOADED(MVCorei18n.CREATEWORLD_WORLDEXISTLOADED),
BUKKIT_CREATION_FAILED(MVCorei18n.CREATEWORLD_BUKKITCREATIONFAILED),
;
private final MessageKeyProvider message;

View File

@ -1,20 +1,42 @@
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.SuccessReason;
public class DeleteWorldResult {
public enum Success implements SuccessReason {
DELETED
DELETED(MVCorei18n.DELETEWORLD_DELETED)
;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}
public static class Failure extends RemoveWorldResult.Failure {
public static final Failure WORLD_FOLDER_NOT_FOUND = new Failure(MVCorei18n.GENERIC_FAILURE);
public static final Failure FAILED_TO_DELETE_FOLDER = new Failure(MVCorei18n.GENERIC_FAILURE);
public enum Failure implements WorldFailureReason {
WORLD_NON_EXISTENT(MVCorei18n.DELETEWORLD_WORLDNONEXISTENT),
WORLD_FOLDER_NOT_FOUND(MVCorei18n.DELETEWORLD_WORLDFOLDERNOTFOUND),
FAILED_TO_DELETE_FOLDER(MVCorei18n.DELETEWORLD_FAILEDTODELETEFOLDER),
;
private final MessageKeyProvider message;
Failure(MessageKeyProvider message) {
super(message);
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}
}

View File

@ -8,15 +8,26 @@ import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
public class ImportWorldResult {
public enum Success implements SuccessReason {
IMPORTED
IMPORTED(MVCorei18n.IMPORTWORLD_IMPORTED);
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}
public enum Failure implements FailureReason {
INVALID_WORLDNAME(MVCorei18n.GENERIC_FAILURE),
WORLD_FOLDER_INVALID(MVCorei18n.GENERIC_FAILURE),
WORLD_EXIST_OFFLINE(MVCorei18n.GENERIC_FAILURE),
WORLD_EXIST_LOADED(MVCorei18n.GENERIC_FAILURE),
BUKKIT_CREATION_FAILED(MVCorei18n.GENERIC_FAILURE),
public enum Failure implements WorldFailureReason {
INVALID_WORLDNAME(MVCorei18n.IMPORTWORLD_INVALIDWORLDNAME),
WORLD_FOLDER_INVALID(MVCorei18n.IMPORTWORLD_WORLDFOLDERINVALID),
WORLD_EXIST_OFFLINE(MVCorei18n.IMPORTWORLD_WORLDEXISTOFFLINE),
WORLD_EXIST_LOADED(MVCorei18n.IMPORTWORLD_WORLDEXISTLOADED),
BUKKIT_CREATION_FAILED(MVCorei18n.IMPORTWORLD_BUKKITCREATIONFAILED),
;
private final MessageKeyProvider message;

View File

@ -8,15 +8,27 @@ import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
public class LoadWorldResult {
public enum Success implements SuccessReason {
LOADED
LOADED(MVCorei18n.LOADWORLD_LOADED)
;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}
public enum Failure implements FailureReason {
WORLD_ALREADY_LOADING(MVCorei18n.GENERIC_FAILURE),
WORLD_NON_EXISTENT(MVCorei18n.GENERIC_FAILURE),
WORLD_EXIST_FOLDER(MVCorei18n.GENERIC_FAILURE),
WORLD_EXIST_LOADED(MVCorei18n.GENERIC_FAILURE),
BUKKIT_CREATION_FAILED(MVCorei18n.GENERIC_FAILURE),
public enum Failure implements WorldFailureReason {
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;

View File

@ -8,13 +8,34 @@ import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
public class RemoveWorldResult {
public enum Success implements SuccessReason {
REMOVED
REMOVED(MVCorei18n.REMOVEWORLD_REMOVED)
;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}
public static class Failure extends UnloadWorldResult.Failure {
// TODO
public enum Failure implements WorldFailureReason {
WORLD_NON_EXISTENT(MVCorei18n.REMOVEWORLD_WORLDNONEXISTENT),
;
private final MessageKeyProvider message;
Failure(MessageKeyProvider message) {
super(message);
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}
}

View File

@ -8,14 +8,27 @@ import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
public class UnloadWorldResult {
public enum Success implements SuccessReason {
UNLOADED
UNLOADED(MVCorei18n.UNLOADWORLD_UNLOADED)
;
private final MessageKeyProvider message;
Success(MessageKeyProvider message) {
this.message = message;
}
@Override
public MessageKey getMessageKey() {
return message.getMessageKey();
}
}
public static class Failure implements FailureReason {
public static final Failure WORLD_ALREADY_UNLOADING = new Failure(MVCorei18n.GENERIC_FAILURE);
public static final Failure WORLD_NON_EXISTENT = new Failure(MVCorei18n.GENERIC_FAILURE);
public static final Failure WORLD_OFFLINE = new Failure(MVCorei18n.GENERIC_FAILURE);
public static final Failure BUKKIT_UNLOAD_FAILED = new Failure(MVCorei18n.GENERIC_FAILURE);
public enum Failure implements WorldFailureReason {
WORLD_ALREADY_UNLOADING(MVCorei18n.UNLOADWORLD_WORLDALREADYUNLOADING),
WORLD_NON_EXISTENT(MVCorei18n.UNLOADWORLD_WORLDNONEXISTENT),
WORLD_OFFLINE(MVCorei18n.UNLOADWORLD_WORLDOFFLINE),
BUKKIT_UNLOAD_FAILED(MVCorei18n.UNLOADWORLD_BUKKITUNLOADFAILED),
;
private final MessageKeyProvider message;

View File

@ -0,0 +1,6 @@
package com.onarandombox.MultiverseCore.worldnew.results;
import com.onarandombox.MultiverseCore.utils.result.FailureReason;
public interface WorldFailureReason extends FailureReason {
}

View File

@ -41,8 +41,6 @@ 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.failed=Failed to create world '{worldName}'! &fSee console for details.
mv-core.create.success=&aWorld '{worldName}' created successfully!
# /mv debug
mv-core.debug.info.description=Show the current debug level.
@ -55,8 +53,6 @@ mv-core.debug.change.level.description=Debug level to set to.
# /mv delete
mv-core.delete.description=Deletes a world on your server PERMANENTLY.
mv-core.delete.deleting=Deleting world '{world}'...
mv-core.delete.failed=There was an issue deleting '{world}'! &fPlease check console for errors.
mv-core.delete.success=&aWorld {world} was deleted!
mv-core.delete.prompt=Are you sure you want to delete world '{world}'?
# /mv dumps
@ -78,15 +74,11 @@ 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.failed=Failed! &fSee console for more details.
mv-core.import.success=&aComplete!
# /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.failed=Error trying to load world '{world}'!
mv-core.load.success=&aLoaded world '{world}'!
# /mv regen
mv-core.regen.description=Regenerates a world on your server. The previous state will be lost PERMANENTLY.
@ -105,8 +97,6 @@ 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.failed=Error trying to remove world from config!
mv-core.remove.success=&aWorld '{world}' is removed from config!
# /mv
mv-core.root.title=&a{name} version {version}
@ -122,8 +112,6 @@ 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.failure=Error unloading world '{world}'! &fSee console for more details.
mv-core.unload.success=&aUnloaded world '{world}'!
# /mv usage
mv-core.usage.description=Show Multiverse-Core command usage.
@ -139,6 +127,42 @@ mv-core.entrycheck.cannotpayentryfee=you do not have the ability to pay entry fe
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.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.worldexistoffline=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}'!&f See console for details.
mv-core.deleteworld.deleted=&aWorld '{world}' deleted!
mv-core.deleteworld.worldnonexistent=World '{world}' not found!
mv-core.deleteworld.worldfoldernotfound=World '{world}' folder not found!
mv-core.deleteworld.failedtodeletefolder=Failed to delete world '{world}' folder! &fSee console for details.
mv-core.importworld.imported=&aWorld '{world}' imported!
mv-core.importworld.invalidworldname=World '{world}' contains invalid characters!
mv-core.importworld.worldexistoffline=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}'!&f See console for 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}'!&f See console for details.
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.worldoffline=World '{world}' is already unloaded!
mv-core.unloadworld.bukkitunloadfailed=Bukkit failed to unload world '{world}'!&f See console for details.
# generic
mv-core.generic.success=Success!
mv-core.generic.failure=Failed!