mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-10 18:28:28 +01:00
Merge pull request #2899 from Multiverse/remove-serverfolder
refactor: Remove serverFolder value
This commit is contained in:
commit
8a05b3b815
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -109,13 +109,8 @@ public class SimpleMVWorldManager implements MVWorldManager {
|
||||
*/
|
||||
@Override
|
||||
public void getDefaultWorldGenerators() {
|
||||
this.defaultGens = new HashMap<String, String>();
|
||||
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")) {
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user