mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 18:47:20 +01:00
Implement remaining locales for clone and regen
This commit is contained in:
parent
6427881c98
commit
6ebcd40a50
@ -1,12 +1,10 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
@ -15,7 +13,6 @@ import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlag;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import com.onarandombox.MultiverseCore.worldnew.MVWorld;
|
||||
@ -25,9 +22,6 @@ import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class CloneCommand extends MultiverseCommand {
|
||||
@ -86,6 +80,5 @@ public class CloneCommand extends MultiverseCommand {
|
||||
Logging.fine("World remove failure: " + failure);
|
||||
issuer.sendError(failure.getReasonMessage());
|
||||
});
|
||||
issuer.sendInfo(MVCorei18n.CLONE_SUCCESS, "{world}", newWorldName);
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,6 @@ public enum MVCorei18n implements MessageKeyProvider {
|
||||
|
||||
// clone command
|
||||
CLONE_CLONING,
|
||||
CLONE_FAILED,
|
||||
CLONE_SUCCESS,
|
||||
|
||||
// Coordinates command
|
||||
COORDINATES_INFO_TITLE,
|
||||
@ -58,8 +56,6 @@ public enum MVCorei18n implements MessageKeyProvider {
|
||||
|
||||
// regen command
|
||||
REGEN_REGENERATING,
|
||||
REGEN_FAILED,
|
||||
REGEN_SUCCESS,
|
||||
REGEN_PROMPT,
|
||||
|
||||
// reload command
|
||||
@ -92,6 +88,13 @@ public enum MVCorei18n implements MessageKeyProvider {
|
||||
ENTRYCHECK_NOWORLDACCESS,
|
||||
|
||||
// world manager result
|
||||
CLONEWORLD_CLONED,
|
||||
CLONEWORLD_INVALIDWORLDNAME,
|
||||
CLONEWORLD_WORLDEXISTFOLDER,
|
||||
CLONEWORLD_WORLDEXISTOFFLINE,
|
||||
CLONEWORLD_WORLDEXISTLOADED,
|
||||
CLONEWORLD_COPYFAILED,
|
||||
|
||||
CREATEWORLD_CREATED,
|
||||
CREATEWORLD_INVALIDWORLDNAME,
|
||||
CREATEWORLD_WORLDEXISTFOLDER,
|
||||
@ -119,6 +122,8 @@ public enum MVCorei18n implements MessageKeyProvider {
|
||||
LOADWORLD_WORLDEXISTLOADED,
|
||||
LOADWORLD_BUKKITCREATIONFAILED,
|
||||
|
||||
REGENWORLD_REGENERATED,
|
||||
|
||||
REMOVEWORLD_REMOVED,
|
||||
REMOVEWORLD_WORLDNONEXISTENT,
|
||||
|
||||
|
@ -506,7 +506,10 @@ public class WorldManager {
|
||||
|
||||
File worldFolder = world.getBukkitWorld().map(World::getWorldFolder).getOrNull(); // TODO: Check null?
|
||||
File newWorldFolder = new File(Bukkit.getWorldContainer(), newWorldName);
|
||||
FileUtils.copyFolder(worldFolder, newWorldFolder, CLONE_IGNORE_FILES);
|
||||
if (!FileUtils.copyFolder(worldFolder, newWorldFolder, CLONE_IGNORE_FILES)) {
|
||||
// TODO: Use Try<Void>
|
||||
return Result.failure(CloneWorldResult.Failure.COPY_FAILED, replace("{world}").with(world.getName()));
|
||||
}
|
||||
|
||||
var importResult = importWorld(ImportWorldOptions.worldName(newWorldName)
|
||||
.environment(world.getEnvironment())
|
||||
@ -519,7 +522,9 @@ public class WorldManager {
|
||||
dataTransfer.pasteAllTo(newWorld);
|
||||
saveWorldsConfig();
|
||||
});
|
||||
return Result.success(CloneWorldResult.Success.CLONED, replace("{world}").with(world.getName()));
|
||||
return Result.success(CloneWorldResult.Success.CLONED,
|
||||
replace("{world}").with(world.getName()),
|
||||
replace("{newworld}").with(newWorldName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,7 +8,7 @@ import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
|
||||
|
||||
public class CloneWorldResult {
|
||||
public enum Success implements SuccessReason {
|
||||
CLONED(MVCorei18n.GENERIC_SUCCESS)
|
||||
CLONED(MVCorei18n.CLONEWORLD_CLONED)
|
||||
;
|
||||
|
||||
private final MessageKeyProvider message;
|
||||
@ -24,10 +24,11 @@ public class CloneWorldResult {
|
||||
}
|
||||
|
||||
public enum Failure implements FailureReason {
|
||||
INVALID_WORLDNAME(MVCorei18n.CREATEWORLD_INVALIDWORLDNAME),
|
||||
WORLD_EXIST_FOLDER(MVCorei18n.CREATEWORLD_WORLDEXISTFOLDER),
|
||||
WORLD_EXIST_OFFLINE(MVCorei18n.CREATEWORLD_WORLDEXISTOFFLINE),
|
||||
WORLD_EXIST_LOADED(MVCorei18n.CREATEWORLD_WORLDEXISTLOADED),
|
||||
INVALID_WORLDNAME(MVCorei18n.CLONEWORLD_INVALIDWORLDNAME),
|
||||
WORLD_EXIST_FOLDER(MVCorei18n.CLONEWORLD_WORLDEXISTFOLDER),
|
||||
WORLD_EXIST_OFFLINE(MVCorei18n.CLONEWORLD_WORLDEXISTOFFLINE),
|
||||
WORLD_EXIST_LOADED(MVCorei18n.CLONEWORLD_WORLDEXISTLOADED),
|
||||
COPY_FAILED(MVCorei18n.CLONEWORLD_COPYFAILED),
|
||||
IMPORT_FAILED(null),
|
||||
;
|
||||
|
||||
|
@ -8,7 +8,7 @@ import com.onarandombox.MultiverseCore.utils.result.SuccessReason;
|
||||
|
||||
public class RegenWorldResult {
|
||||
public enum Success implements SuccessReason {
|
||||
REGENERATED(MVCorei18n.GENERIC_SUCCESS)
|
||||
REGENERATED(MVCorei18n.REGENWORLD_REGENERATED)
|
||||
;
|
||||
|
||||
private final MessageKeyProvider message;
|
||||
|
@ -13,8 +13,6 @@ 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.failed=World could not be cloned! &fSee console for more details.
|
||||
mv-core.clone.success=Cloned world '{world}'!
|
||||
|
||||
# /mv confirm
|
||||
mv-core.confirm.description=Confirms dangerous commands before executing them.
|
||||
@ -85,8 +83,6 @@ mv-core.regen.description=Regenerates a world on your server. The previous state
|
||||
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.failed=There was an issue regenerating '{world}'! &fPlease check console for errors.
|
||||
mv-core.regen.success=&aWorld {world} was regenerated!
|
||||
mv-core.regen.prompt=Are you sure you want to regenerate world '{world}'?
|
||||
|
||||
# /mv reload
|
||||
@ -128,6 +124,13 @@ 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 '{world}' cloned to '{newworld}'!
|
||||
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.worldexistoffline=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 '{world}' to '{newworld}': {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.
|
||||
|
@ -202,7 +202,7 @@ class LocalizationTest : TestWithMockBukkit() {
|
||||
private val messageString = "Hello $replacementKey!"
|
||||
private val replacedMessageString = messageString.replace(replacementKey, replacementValue)
|
||||
|
||||
private val message = MVCorei18n.CLONE_SUCCESS
|
||||
private val message = MVCorei18n.CLONEWORLD_CLONED
|
||||
.bundle(messageString, replace(replacementKey).with(replacementValue))
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user