mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-13 19:11:38 +01:00
Fix config tests
This commit is contained in:
parent
4ff1663353
commit
55b21bf17e
@ -54,7 +54,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
|
||||
private ServiceLocator serviceLocator;
|
||||
@Inject
|
||||
private MVCoreConfig config;
|
||||
private Provider<MVCoreConfig> configProvider;
|
||||
@Inject
|
||||
private Provider<MVWorldManager> worldManagerProvider;
|
||||
@Inject
|
||||
@ -101,7 +101,8 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
initializeDependencyInjection();
|
||||
|
||||
// Load our configs first as we need them for everything else.
|
||||
if (config == null || !config.isLoaded()) {
|
||||
var config = configProvider.get();
|
||||
if (!config.isLoaded()) {
|
||||
Logging.severe("Your configs were not loaded.");
|
||||
Logging.severe("Please check your configs and restart the server.");
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
@ -169,7 +170,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
}
|
||||
|
||||
private boolean shouldShowConfig() {
|
||||
return !config.getSilentStart();
|
||||
return !configProvider.get().getSilentStart();
|
||||
}
|
||||
|
||||
private void loadEconomist() {
|
||||
@ -273,14 +274,14 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
private void logEnableMessage() {
|
||||
Logging.config("Version %s (API v%s) Enabled - By %s", this.getDescription().getVersion(), PROTOCOL, getAuthors());
|
||||
|
||||
if (config.isShowingDonateMessage()) {
|
||||
if (configProvider.get().isShowingDonateMessage()) {
|
||||
Logging.config("Help dumptruckman keep this project alive. Become a patron! https://www.patreon.com/dumptruckman");
|
||||
Logging.config("One time donations are also appreciated: https://www.paypal.me/dumptruckman");
|
||||
}
|
||||
}
|
||||
|
||||
private void loadPlaceholderAPIIntegration() {
|
||||
if (config.isRegisterPapiHook()
|
||||
if (configProvider.get().isRegisterPapiHook()
|
||||
&& getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
Try.run(() -> serviceLocator.createAndInitialize(MultiverseCorePlaceholders.class))
|
||||
.onFailure(e -> {
|
||||
@ -365,7 +366,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
*/
|
||||
@Override
|
||||
public boolean saveAllConfigs() {
|
||||
return config.save()
|
||||
return configProvider.get().save()
|
||||
&& worldManagerProvider.get().saveWorldsConfig()
|
||||
&& anchorManagerProvider.get().saveAnchors();
|
||||
}
|
||||
|
@ -107,9 +107,6 @@ abstract class FileConfigHandle<C extends FileConfiguration> extends GenericConf
|
||||
public static abstract class Builder<C extends FileConfiguration, B extends Builder<C, B>> extends GenericConfigHandle.Builder<C, B> {
|
||||
|
||||
protected @NotNull Path configPath;
|
||||
protected @Nullable Logger logger;
|
||||
protected @Nullable NodeGroup nodes;
|
||||
protected @Nullable ConfigMigrator migrator;
|
||||
|
||||
protected Builder(@NotNull Path configPath) {
|
||||
this.configPath = configPath;
|
||||
|
@ -39,7 +39,7 @@ class ConfigTest : TestWithMockBukkit() {
|
||||
fun `Old config is migrated`() {
|
||||
val oldConfig = getResourceAsText("/old_config.yml")
|
||||
assertNotNull(oldConfig)
|
||||
File(Path.of(multiverseCore.dataFolder.absolutePath, "config.yml").absolutePathString()).writeText(oldConfig)
|
||||
multiverseCore.dataFolder.toPath().resolve("config.yml").toFile().writeText(oldConfig)
|
||||
assertTrue(config.load())
|
||||
assertTrue(config.save())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user