diff --git a/src/main/java/world/bentobox/bentobox/BentoBox.java b/src/main/java/world/bentobox/bentobox/BentoBox.java index 11437eaad..5584f4757 100644 --- a/src/main/java/world/bentobox/bentobox/BentoBox.java +++ b/src/main/java/world/bentobox/bentobox/BentoBox.java @@ -1,5 +1,7 @@ package world.bentobox.bentobox; +import java.util.Optional; + import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.plugin.PluginManager; @@ -30,8 +32,6 @@ import world.bentobox.bentobox.managers.RanksManager; import world.bentobox.bentobox.managers.SchemsManager; import world.bentobox.bentobox.util.heads.HeadGetter; -import java.util.Optional; - /** * Main BentoBox class * @author tastybento, Poslovitch @@ -78,6 +78,12 @@ public class BentoBox extends JavaPlugin { // Load settings from config.yml. This will check if there are any issues with it too. settings = new Config<>(this, Settings.class).loadConfigObject(""); + if (settings == null) { + // Settings did no load correctly. Disable plugin. + logError("Settings did not load correctly - disabling plugin - please check config.yml"); + getPluginLoader().disablePlugin(this); + return; + } // Start Database managers playersManager = new PlayersManager(this); // Check if this plugin is now disabled (due to bad database handling) diff --git a/src/main/java/world/bentobox/bentobox/Settings.java b/src/main/java/world/bentobox/bentobox/Settings.java index 00bf46f76..ffacb0330 100644 --- a/src/main/java/world/bentobox/bentobox/Settings.java +++ b/src/main/java/world/bentobox/bentobox/Settings.java @@ -89,7 +89,7 @@ public class Settings implements DataObject { @ConfigComment("island unnecessarily.") @ConfigEntry(path = "general.allow-obsidian-scooping") private boolean allowObsidianScooping = true; - + @ConfigComment("Rank required to use a command. e.g., use the invite command. Default is owner rank is required.") @ConfigEntry(path = "general.rank-command") private Map rankCommand = new HashMap<>(); diff --git a/src/main/java/world/bentobox/bentobox/database/DatabaseSetup.java b/src/main/java/world/bentobox/bentobox/database/DatabaseSetup.java index 6544e03d5..e24f2d80f 100644 --- a/src/main/java/world/bentobox/bentobox/database/DatabaseSetup.java +++ b/src/main/java/world/bentobox/bentobox/database/DatabaseSetup.java @@ -1,10 +1,10 @@ package world.bentobox.bentobox.database; import world.bentobox.bentobox.BentoBox; -import world.bentobox.bentobox.database.yaml.YamlDatabase; import world.bentobox.bentobox.database.json.JSONDatabase; import world.bentobox.bentobox.database.mongodb.MongoDBDatabase; import world.bentobox.bentobox.database.mysql.MySQLDatabase; +import world.bentobox.bentobox.database.yaml.YamlDatabase; public interface DatabaseSetup { @@ -15,8 +15,9 @@ public interface DatabaseSetup { * @return Database type */ static DatabaseSetup getDatabase() { + BentoBox plugin = BentoBox.getInstance(); for(DatabaseType type : DatabaseType.values()){ - if(type == BentoBox.getInstance().getSettings().getDatabaseType()) { + if(type == plugin.getSettings().getDatabaseType()) { return type.database; } }