From 08c7a20114af0dc401da31ef7c736a0859eb1064 Mon Sep 17 00:00:00 2001 From: creatorfromhell Date: Tue, 28 Nov 2023 19:41:51 -0500 Subject: [PATCH] Start import command. Just have to add output messages. --- .../commands/phantomworlds/PWCommand.java | 3 +- .../parameters/sub/ImportCommand.java | 55 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/parameters/sub/ImportCommand.java diff --git a/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/PWCommand.java b/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/PWCommand.java index 2782940..4f5857a 100644 --- a/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/PWCommand.java +++ b/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/PWCommand.java @@ -21,6 +21,7 @@ import me.lokka30.phantomworlds.commands.phantomworlds.parameters.sub.CompatibilityCommand; import me.lokka30.phantomworlds.commands.phantomworlds.parameters.sub.DebugCommand; import me.lokka30.phantomworlds.commands.phantomworlds.parameters.sub.DeleteCommand; +import me.lokka30.phantomworlds.commands.phantomworlds.parameters.sub.ImportCommand; import me.lokka30.phantomworlds.commands.phantomworlds.parameters.sub.InfoCommand; import me.lokka30.phantomworlds.commands.phantomworlds.parameters.sub.ListCommand; import me.lokka30.phantomworlds.commands.phantomworlds.parameters.sub.ReloadCommand; @@ -92,7 +93,7 @@ public void gamerule(BukkitCommandActor actor) { @Subcommand({"import", "im"}) @CommandPermission("phantomworlds.command.phantomworlds.import") public void importCMD(BukkitCommandActor actor, final World world) { - InfoCommand.onCommand(actor); + ImportCommand.onCommand(actor, world); } @Subcommand({"info", "i"}) diff --git a/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/parameters/sub/ImportCommand.java b/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/parameters/sub/ImportCommand.java new file mode 100644 index 0000000..5efefb9 --- /dev/null +++ b/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/parameters/sub/ImportCommand.java @@ -0,0 +1,55 @@ +package me.lokka30.phantomworlds.commands.phantomworlds.parameters.sub; +/* + * Phantom Worlds + * Copyright (C) 2023 Daniel "creatorfromhell" Vidmar + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import me.lokka30.phantomworlds.PhantomWorlds; +import me.lokka30.phantomworlds.world.PhantomWorld; +import org.bukkit.GameMode; +import org.bukkit.World; +import revxrsal.commands.bukkit.BukkitCommandActor; + +/** + * ImportCommand + * + * @author creatorfromhell + * @since 2.0.5.0 + */ +public class ImportCommand { + + public static void onCommand(final BukkitCommandActor actor, final World world) { + + if(world == null) { + //TODO: send message world doesn't exist, can't import. + return; + } + + final String cfgPath = "worlds-to-load." + world.getName() + "."; + if(PhantomWorlds.instance().data.getConfig().contains(cfgPath)) { + //TODO: Already a PhantomWorlds managed world. + return; + } + + final PhantomWorld pworld = new PhantomWorld( + world.getName(), world.getEnvironment(), world.canGenerateStructures(), null, + null, world.isHardcore(), world.getSeed(), world.getWorldType(), world.getAllowMonsters(), + world.getAllowAnimals(), world.getKeepSpawnInMemory(), world.getPVP(), world.getDifficulty(), GameMode.SURVIVAL + ); + pworld.save(); + //TODO: world imported and will be managed by phantomworlds + } +} \ No newline at end of file