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

View File

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

View File

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