diff --git a/plugin/src/main/java/net/thenextlvl/worlds/command/WorldLoadCommand.java b/plugin/src/main/java/net/thenextlvl/worlds/command/WorldLoadCommand.java index f54d53b..efa4671 100644 --- a/plugin/src/main/java/net/thenextlvl/worlds/command/WorldLoadCommand.java +++ b/plugin/src/main/java/net/thenextlvl/worlds/command/WorldLoadCommand.java @@ -32,13 +32,22 @@ class WorldLoadCommand { private int load(CommandContext context) { var name = context.getArgument("world", String.class); var level = new File(plugin.getServer().getWorldContainer(), name); + var world = plugin.levelView().isLevel(level) ? plugin.levelView().loadLevel(level, optional -> optional.map(extras -> !extras.enabled()).isPresent()) : null; + var message = world != null ? "world.load.success" : "world.load.failed"; plugin.bundle().sendMessage(context.getSource().getSender(), message, Placeholder.parsed("world", world != null ? world.key().asString() : name)); + if (world != null && context.getSource().getSender() instanceof Entity entity) entity.teleportAsync(world.getSpawnLocation(), COMMAND); + + if (world != null) { + plugin.persistStatus(world, true, true); + plugin.levelView().saveLevelData(world, true); + } + return world != null ? Command.SINGLE_SUCCESS : 0; } }