mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-25 18:48:15 +01:00
Added safety checking to config.yml
If there is an enum setting, e.g. FLATFILE instead of YAML in a config, the config will not load and the resulting object will be null. This adds a check to the main config.yml load and disables the plugin if there is a problem.
This commit is contained in:
parent
49fa079f13
commit
935704d7dd
@ -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)
|
||||
|
@ -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<String, Integer> rankCommand = new HashMap<>();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user