diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index f4dc5563..bcc32c3b 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -402,43 +402,6 @@ public class MultiverseCore extends JavaPlugin implements MVCore { //TODO: REMOVE THIS STATIC CRAP - END - // For testing purposes only // - - private File serverFolder = new File(System.getProperty("user.dir")); - - /** - * This is for unit testing. - * - * @param loader The PluginLoader to use. - * @param description The Description file to use. - * @param dataFolder The folder that other datafiles can be found in. - * @param file The location of the plugin. - */ - public MultiverseCore(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) { - super(loader, description, dataFolder, file); - } - - /** - * Gets the server's root-folder as {@link File}. - * - * @return The server's root-folder - */ - public File getServerFolder() { - return serverFolder; - } - - /** - * Sets this server's root-folder. - * - * @param newServerFolder The new server-root - */ - public void setServerFolder(File newServerFolder) { - if (!newServerFolder.isDirectory()) - throw new IllegalArgumentException("That's not a folder!"); - - this.serverFolder = newServerFolder; - } - /** * Gets the best service from this plugin that implements the given contract or has the given implementation. * @@ -477,4 +440,16 @@ public class MultiverseCore extends JavaPlugin implements MVCore { .map(ServiceHandle::getService) .collect(Collectors.toList()); } + + /** + * This is for unit testing ONLY. Do not use this constructor. + * + * @param loader The PluginLoader to use. + * @param description The Description file to use. + * @param dataFolder The folder that other datafiles can be found in. + * @param file The location of the plugin. + */ + public MultiverseCore(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) { + super(loader, description, dataFolder, file); + } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/world/SimpleMVWorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/world/SimpleMVWorldManager.java index d37a59b2..209a40a0 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/world/SimpleMVWorldManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/world/SimpleMVWorldManager.java @@ -109,13 +109,8 @@ public class SimpleMVWorldManager implements MVWorldManager { */ @Override public void getDefaultWorldGenerators() { - this.defaultGens = new HashMap(); - File[] files = this.plugin.getServerFolder().listFiles(new FilenameFilter() { - @Override - public boolean accept(File file, String s) { - return s.equalsIgnoreCase("bukkit.yml"); - } - }); + this.defaultGens = new HashMap<>(); + File[] files = server.getWorldContainer().listFiles((file, s) -> s.equalsIgnoreCase("bukkit.yml")); if (files != null && files.length == 1) { FileConfiguration bukkitConfig = YamlConfiguration.loadConfiguration(files[0]); if (bukkitConfig.isConfigurationSection("worlds")) { diff --git a/src/old-test/java/com/onarandombox/MultiverseCore/TestDebugMode.java b/src/old-test/java/com/onarandombox/MultiverseCore/TestDebugMode.java index 53dd5c88..4ec5d539 100644 --- a/src/old-test/java/com/onarandombox/MultiverseCore/TestDebugMode.java +++ b/src/old-test/java/com/onarandombox/MultiverseCore/TestDebugMode.java @@ -56,7 +56,7 @@ public class TestDebugMode { assertTrue(plugin.isEnabled()); // Make a fake server folder to fool MV into thinking a world folder exists. - File serverDirectory = new File(creator.getCore().getServerFolder(), "world"); + File serverDirectory = new File(mockServer.getWorldContainer(), "world"); serverDirectory.mkdirs(); // Initialize a fake command diff --git a/src/old-test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java b/src/old-test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java index 7e5b9d7c..55110a51 100644 --- a/src/old-test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java +++ b/src/old-test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java @@ -87,7 +87,6 @@ public class TestInstanceCreator { doReturn(true).when(core).isEnabled(); doReturn(Util.logger).when(core).getLogger(); - core.setServerFolder(serverDirectory); // Add Core to the list of loaded plugins JavaPlugin[] plugins = new JavaPlugin[] { core }; @@ -101,13 +100,13 @@ public class TestInstanceCreator { when(mockPluginManager.getPermission("Vault")).thenReturn(null); // Make some fake folders to fool the fake MV into thinking these worlds exist - File worldNormalFile = new File(core.getServerFolder(), "world"); + File worldNormalFile = new File(mockServer.getWorldContainer(), "world"); Util.log("Creating world-folder: " + worldNormalFile.getAbsolutePath()); worldNormalFile.mkdirs(); - File worldNetherFile = new File(core.getServerFolder(), "world_nether"); + File worldNetherFile = new File(mockServer.getWorldContainer(), "world_nether"); Util.log("Creating world-folder: " + worldNetherFile.getAbsolutePath()); worldNetherFile.mkdirs(); - File worldSkylandsFile = new File(core.getServerFolder(), "world_the_end"); + File worldSkylandsFile = new File(mockServer.getWorldContainer(), "world_the_end"); Util.log("Creating world-folder: " + worldSkylandsFile.getAbsolutePath()); worldSkylandsFile.mkdirs();