From 6ea8537049e4a4a2fadc95d11092296048cc960b Mon Sep 17 00:00:00 2001 From: creatorfromhell Date: Tue, 28 Nov 2023 19:23:02 -0500 Subject: [PATCH] Create PhantomWorld.save for ease-of use. --- .../commands/phantomworlds/PWCommand.java | 6 +++++ .../subcommands/CreateSubcommand.java | 21 +--------------- .../phantomworlds/world/PhantomWorld.java | 25 +++++++++++++++++++ 3 files changed, 32 insertions(+), 20 deletions(-) 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 d2dd90f..2782940 100644 --- a/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/PWCommand.java +++ b/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/PWCommand.java @@ -89,6 +89,12 @@ public void gamerule(BukkitCommandActor actor) { //todo: port gamerule command } + @Subcommand({"import", "im"}) + @CommandPermission("phantomworlds.command.phantomworlds.import") + public void importCMD(BukkitCommandActor actor, final World world) { + InfoCommand.onCommand(actor); + } + @Subcommand({"info", "i"}) @CommandPermission("phantomworlds.command.phantomworlds.info") public void info(BukkitCommandActor actor) { diff --git a/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/subcommands/CreateSubcommand.java b/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/subcommands/CreateSubcommand.java index 7e8f3ab..264688f 100644 --- a/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/subcommands/CreateSubcommand.java +++ b/src/main/java/me/lokka30/phantomworlds/commands/phantomworlds/subcommands/CreateSubcommand.java @@ -333,26 +333,7 @@ public void parseCommand(CommandSender sender, Command cmd, String label, String new MultiMessage.Placeholder("world", worldName, false) ))).send(sender); - final String cfgPath = "worlds-to-load." + worldName + "."; - PhantomWorlds.instance().data.getConfig().set(cfgPath + "environment", environment.toString()); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "generateStructures", generateStructures); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "generator", generator); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "generatorSettings", generatorSettings); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "hardcore", hardcore); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "seed", seed); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "worldType", worldType.toString()); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "spawnMobs", spawnMobs); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "spawnAnimals", spawnAnimals); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "keepSpawnInMemory", keepSpawnInMemory); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "allowPvP", allowPvP); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "difficulty", difficulty.toString()); - PhantomWorlds.instance().data.getConfig().set(cfgPath + "gameMode", mode.name()); - - try { - PhantomWorlds.instance().data.save(); - } catch(final IOException ex) { - throw new RuntimeException(ex); - } + pworld.save(); (new MultiMessage( PhantomWorlds.instance().messages.getConfig().getStringList( diff --git a/src/main/java/me/lokka30/phantomworlds/world/PhantomWorld.java b/src/main/java/me/lokka30/phantomworlds/world/PhantomWorld.java index d1e7d1e..603ee17 100644 --- a/src/main/java/me/lokka30/phantomworlds/world/PhantomWorld.java +++ b/src/main/java/me/lokka30/phantomworlds/world/PhantomWorld.java @@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -146,6 +147,30 @@ public void create() { } } + public void save() { + + final String cfgPath = "worlds-to-load." + name + "."; + PhantomWorlds.instance().data.getConfig().set(cfgPath + "environment", environment.toString()); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "generateStructures", generateStructures); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "generator", generator); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "generatorSettings", generatorSettings); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "hardcore", hardcore); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "seed", seed); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "worldType", worldType.toString()); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "spawnMobs", spawnMobs); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "spawnAnimals", spawnAnimals); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "keepSpawnInMemory", keepSpawnInMemory); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "allowPvP", allowPvP); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "difficulty", difficulty.toString()); + PhantomWorlds.instance().data.getConfig().set(cfgPath + "gameMode", gameMode.name()); + + try { + PhantomWorlds.instance().data.save(); + } catch(final IOException ex) { + throw new RuntimeException(ex); + } + } + public void loadGameRules() { }