mirror of
https://github.com/BentoBoxWorld/Greenhouses.git
synced 2024-11-22 02:25:50 +01:00
Improves config.yml reading and saving.
Can handle lower-case game mode naming. May help https://github.com/BentoBoxWorld/Greenhouses/issues/64
This commit is contained in:
parent
26ef3d3a24
commit
25277a09c7
@ -63,20 +63,28 @@ public class Greenhouses extends Addon {
|
||||
recipes = new RecipeManager(this);
|
||||
// Load manager
|
||||
manager = new GreenhouseManager(this);
|
||||
// Clear
|
||||
this.activeWorlds.clear();
|
||||
// Register commands for
|
||||
getPlugin().getAddonsManager().getGameModeAddons().stream()
|
||||
.filter(gm -> settings.getGameModes().contains(gm.getDescription().getName()))
|
||||
.filter(gm -> settings.getGameModes().stream().anyMatch(gm.getDescription().getName()::equalsIgnoreCase))
|
||||
.forEach(gm -> {
|
||||
// Register command
|
||||
gm.getPlayerCommand().ifPresent(playerCmd -> new UserCommand(this, playerCmd));
|
||||
// Log
|
||||
this.log("Hooking into " + gm.getDescription().getName());
|
||||
// Store active world
|
||||
activeWorlds.add(gm.getOverWorld());
|
||||
});
|
||||
// Register greenhouse manager
|
||||
this.registerListener(manager);
|
||||
// Register protection flag with BentoBox
|
||||
getPlugin().getFlagsManager().registerFlag(this, GREENHOUSES);
|
||||
|
||||
if (this.activeWorlds.isEmpty()) {
|
||||
this.logError("Greenhouses could not hook into any game modes! Check config.yml");
|
||||
this.setState(State.DISABLED);
|
||||
} else {
|
||||
// Register greenhouse manager
|
||||
this.registerListener(manager);
|
||||
// Register protection flag with BentoBox
|
||||
getPlugin().getFlagsManager().registerFlag(this, GREENHOUSES);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -88,9 +96,6 @@ public class Greenhouses extends Addon {
|
||||
manager.saveGreenhouses();
|
||||
if (manager.getEcoMgr() != null) manager.getEcoMgr().cancel();
|
||||
}
|
||||
if (settings != null) {
|
||||
new Config<>(this, Settings.class).saveConfigObject(settings);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user