Fixed shops not loading on start

This commit is contained in:
Niels Vergucht 2018-12-07 19:53:10 +01:00
parent 4d71cd492f
commit 38f0bd5873
3 changed files with 8 additions and 7 deletions

View File

@ -44,6 +44,8 @@ public class EpicBuckets extends ExtendedJavaPlugin {
return;
}
saveDefaultConfig();
Locale.init(this);
Locale.saveDefaultLocale("en_US");
this.locale = Locale.getLocale(getConfig().getString("Locale", "en_US"));
@ -51,7 +53,7 @@ public class EpicBuckets extends ExtendedJavaPlugin {
debugger = new Debugger();
configManager = new ConfigManager();
shopManager = new ShopManager();
shopManager.init();
configManager.setup();
genbucketManager = new GenbucketManager();
commandManager = new PaperCommandManager(this);

View File

@ -53,17 +53,15 @@ public class ConfigManager {
public ConfigManager() {
this.epicBuckets = EpicBuckets.getInstance();
setup();
}
private void setup() {
epicBuckets.saveDefaultConfig();
public void setup() {
configDatabase = new HashMap<>();
loadData();
createConfig("shops", true);
loadData();
setupBackButton();
setupFillItem();
epicBuckets.getShopManager().init();
}
public void reload() {

View File

@ -91,13 +91,14 @@ public class ShopManager {
}
private void loadShops() {
System.out.println("Loading shops..");
for (String key : epicBuckets.getConfig().getConfigurationSection(epicBuckets.getConfigManager().getMenuItemsPath()).getKeys(false)) {
if (!epicBuckets.getConfig().isConfigurationSection(epicBuckets.getConfigManager().getMenuItemsPath() + "." + key)) {
continue;
}
shopDatabase.put(key, new Shop(key, epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getMenuItemsPath() + "." + key + ".shop"), epicBuckets.getConfigManager().getMenuItemsPath() + "." + key));
}
System.out.println("Loaded " + shopDatabase.size() + " shop(s)");
}
public boolean inventoryFull(Player buyer) {