mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-10 10:17:41 +01:00
Remove from commands and add to tests
This commit is contained in:
parent
aa412b1060
commit
5fca5b18b8
@ -26,7 +26,6 @@ import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag;
|
|||||||
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
|
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
|
||||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||||
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
|
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
|
||||||
import com.onarandombox.MultiverseCore.worldnew.WorldManager;
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -40,19 +39,16 @@ import org.jvnet.hk2.annotations.Service;
|
|||||||
public class CreateCommand extends MultiverseCommand {
|
public class CreateCommand extends MultiverseCommand {
|
||||||
|
|
||||||
private final MVWorldManager worldManager;
|
private final MVWorldManager worldManager;
|
||||||
private final WorldManager newWorldManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CreateCommand(
|
public CreateCommand(
|
||||||
@NotNull MVCommandManager commandManager,
|
@NotNull MVCommandManager commandManager,
|
||||||
@NotNull MVWorldManager worldManager,
|
@NotNull MVWorldManager worldManager,
|
||||||
@NotNull UnsafeCallWrapper unsafeCallWrapper,
|
@NotNull UnsafeCallWrapper unsafeCallWrapper
|
||||||
@NotNull WorldManager newWorldManager
|
|
||||||
) {
|
) {
|
||||||
super(commandManager);
|
super(commandManager);
|
||||||
|
|
||||||
this.worldManager = worldManager;
|
this.worldManager = worldManager;
|
||||||
this.newWorldManager = newWorldManager;
|
|
||||||
|
|
||||||
registerFlagGroup(CommandFlagGroup.builder("mvcreate")
|
registerFlagGroup(CommandFlagGroup.builder("mvcreate")
|
||||||
.add(CommandValueFlag.builder("--seed", String.class)
|
.add(CommandValueFlag.builder("--seed", String.class)
|
||||||
@ -116,8 +112,6 @@ public class CreateCommand extends MultiverseCommand {
|
|||||||
|
|
||||||
issuer.sendInfo(MVCorei18n.CREATE_LOADING);
|
issuer.sendInfo(MVCorei18n.CREATE_LOADING);
|
||||||
|
|
||||||
newWorldManager.addWorld(worldName);
|
|
||||||
|
|
||||||
if (!worldManager.addWorld(
|
if (!worldManager.addWorld(
|
||||||
worldName,
|
worldName,
|
||||||
environment,
|
environment,
|
||||||
|
@ -15,7 +15,6 @@ import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
|||||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||||
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
|
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
|
||||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||||
import com.onarandombox.MultiverseCore.worldnew.WorldManager;
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jvnet.hk2.annotations.Service;
|
import org.jvnet.hk2.annotations.Service;
|
||||||
@ -25,13 +24,11 @@ import org.jvnet.hk2.annotations.Service;
|
|||||||
public class DeleteCommand extends MultiverseCommand {
|
public class DeleteCommand extends MultiverseCommand {
|
||||||
|
|
||||||
private final MVWorldManager worldManager;
|
private final MVWorldManager worldManager;
|
||||||
private final WorldManager newWorldManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DeleteCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager, @NotNull WorldManager newWorldManager) {
|
public DeleteCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
|
||||||
super(commandManager);
|
super(commandManager);
|
||||||
this.worldManager = worldManager;
|
this.worldManager = worldManager;
|
||||||
this.newWorldManager = newWorldManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("delete")
|
@Subcommand("delete")
|
||||||
@ -51,7 +48,6 @@ public class DeleteCommand extends MultiverseCommand {
|
|||||||
issuer.getIssuer(),
|
issuer.getIssuer(),
|
||||||
() -> {
|
() -> {
|
||||||
issuer.sendInfo(MVCorei18n.DELETE_DELETING, "{world}", worldName);
|
issuer.sendInfo(MVCorei18n.DELETE_DELETING, "{world}", worldName);
|
||||||
this.newWorldManager.deleteWorld(worldName);
|
|
||||||
if (!this.worldManager.deleteWorld(worldName)) {
|
if (!this.worldManager.deleteWorld(worldName)) {
|
||||||
issuer.sendError(MVCorei18n.DELETE_FAILED, "{world}", worldName);
|
issuer.sendError(MVCorei18n.DELETE_FAILED, "{world}", worldName);
|
||||||
return;
|
return;
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package org.mvplugins.multiverse.core.world
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.worldnew.WorldManager
|
||||||
|
import org.mvplugins.multiverse.core.TestWithMockBukkit
|
||||||
|
import kotlin.test.BeforeTest
|
||||||
|
import kotlin.test.Test
|
||||||
|
|
||||||
|
class WorldManagerTest : TestWithMockBukkit() {
|
||||||
|
private lateinit var worldManager: WorldManager
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
fun setUp() {
|
||||||
|
worldManager = multiverseCore.getService(WorldManager::class.java).takeIf { it != null } ?: run {
|
||||||
|
throw IllegalStateException("WorldManager is not available as a service") }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Add world`() {
|
||||||
|
worldManager.addWorld("world")
|
||||||
|
// TODO: When logic is implemented, check that the world is added
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Delete world`() {
|
||||||
|
worldManager.deleteWorld("world")
|
||||||
|
// TODO: When logic is implemented, check that the world is removed
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user