From 6effeacd1b1257ea67c3f7c4f2e52ea7bf527b53 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 1 Sep 2023 11:20:25 +0800 Subject: [PATCH] Add getWorldConfig method --- .../onarandombox/MultiverseCore/worldnew/WorldManager.java | 6 ++---- .../MultiverseCore/worldnew/config/WorldsConfigFile.java | 4 ++++ .../mvplugins/multiverse/core/world/WorldConfigFileTest.kt | 4 ++-- .../org/mvplugins/multiverse/core/world/WorldConfigTest.kt | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java index 097950bb..4a0211b3 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java @@ -29,15 +29,13 @@ public class WorldManager { } public void addWorld(String worldName) { - ConfigurationSection worldConfigSection = worldsConfigFile.getWorldConfigSection(worldName); - WorldConfig worldConfig = new WorldConfig(worldConfigSection); + WorldConfig worldConfig = worldsConfigFile.getWorldConfig(worldName); //todo saveWorldsConfig(); } public void loadWorld(String worldName) { - ConfigurationSection worldConfigSection = worldsConfigFile.getWorldConfigSection(worldName); - WorldConfig worldConfig = new WorldConfig(worldConfigSection); + WorldConfig worldConfig = worldsConfigFile.getWorldConfig(worldName); //todo } diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigFile.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigFile.java index a51a986b..1c67c5a8 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigFile.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigFile.java @@ -49,6 +49,10 @@ public class WorldsConfigFile { ? worldConfig.getConfigurationSection(worldName) : worldConfig.createSection(worldName); } + public WorldConfig getWorldConfig(String worldName) { + return new WorldConfig(getWorldConfigSection(worldName)); + } + public void deleteWorldConfigSection(String worldName) { worldConfig.set(worldName, null); } diff --git a/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigFileTest.kt b/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigFileTest.kt index 8bef3703..646e5b07 100644 --- a/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigFileTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigFileTest.kt @@ -38,14 +38,14 @@ class WorldConfigFileTest : TestWithMockBukkit() { @Test fun `Add a new world to config`() { - val worldConfig = WorldConfig(worldConfigFile.getWorldConfigSection("newworld")) + val worldConfig = worldConfigFile.getWorldConfig("newworld") worldConfigFile.save() compareConfigFile("worlds2.yml", "/newworld_worlds.yml") } @Test fun `Updating existing world properties`() { - val worldConfig = WorldConfig(worldConfigFile.getWorldConfigSection("world")) + val worldConfig = worldConfigFile.getWorldConfig("world") worldConfig.setProperty("adjust-spawn", true) worldConfig.setProperty("alias", "newalias") worldConfigFile.save() diff --git a/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigTest.kt b/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigTest.kt index 5d57836b..3adc24d8 100644 --- a/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigTest.kt @@ -25,7 +25,7 @@ class WorldConfigTest : TestWithMockBukkit() { worldConfigFile = WorldsConfigFile(multiverseCore) worldConfigFile.load() - worldConfig = WorldConfig(worldConfigFile.getWorldConfigSection("world")) + worldConfig = worldConfigFile.getWorldConfig("world") } @Test