diff --git a/src/main/java/de/epiceric/shopchest/ShopChest.java b/src/main/java/de/epiceric/shopchest/ShopChest.java index 4cca688..54c9e6f 100644 --- a/src/main/java/de/epiceric/shopchest/ShopChest.java +++ b/src/main/java/de/epiceric/shopchest/ShopChest.java @@ -355,13 +355,12 @@ public class ShopChest extends JavaPlugin { } } - /** * Initializes the shops */ private void initializeShops() { debug("Initializing Shops..."); - shopUtils.reloadShops(false, false, new Callback(this) { + shopUtils.reloadShops(false, true, new Callback(this) { @Override public void onResult(Object result) { if (result instanceof Integer) { diff --git a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java index c848db4..5ba0469 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java @@ -64,7 +64,7 @@ public class ChestProtectListener implements Listener { public void run() { Location loc = (b.getLocation().equals(l.getLocation()) ? r.getLocation() : l.getLocation()); Shop newShop = new Shop(shop.getID(), plugin, shop.getVendor(), shop.getProduct(), loc, shop.getBuyPrice(), shop.getSellPrice(), shop.getShopType()); - newShop.create(); + newShop.create(true); shopUtils.addShop(newShop, true); } }, 1L); @@ -178,7 +178,7 @@ public class ChestProtectListener implements Listener { if (b.getRelative(BlockFace.UP).getType() == Material.AIR) { shopUtils.removeShop(shop, true); Shop newShop = new Shop(shop.getID(), ShopChest.getInstance(), shop.getVendor(), shop.getProduct(), shop.getLocation(), shop.getBuyPrice(), shop.getSellPrice(), shop.getShopType()); - newShop.create(); + newShop.create(true); shopUtils.addShop(newShop, true); plugin.debug(String.format("%s extended %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID())); } else { diff --git a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java index 06144e9..78ceb5c 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java @@ -513,7 +513,7 @@ public class ShopInteractListener implements Listener { return; } - shop.create(); + shop.create(true); plugin.debug("Shop created"); shopUtils.addShop(shop, true); diff --git a/src/main/java/de/epiceric/shopchest/shop/Shop.java b/src/main/java/de/epiceric/shopchest/shop/Shop.java index 29d7bcc..061e24d 100644 --- a/src/main/java/de/epiceric/shopchest/shop/Shop.java +++ b/src/main/java/de/epiceric/shopchest/shop/Shop.java @@ -48,7 +48,7 @@ public class Shop { this(-1, plugin, vendor, product, location, buyPrice, sellPrice, shopType); } - public boolean create() { + public boolean create(boolean showConsoleMessages) { if (created) return false; plugin.debug("Creating shop (#" + id + ")"); @@ -57,14 +57,14 @@ public class Shop { if (b.getType() != Material.CHEST && b.getType() != Material.TRAPPED_CHEST) { ChestNotFoundException ex = new ChestNotFoundException("No Chest found at location: " + b.getX() + "; " + b.getY() + "; " + b.getZ()); plugin.getShopUtils().removeShop(this, plugin.getShopChestConfig().remove_shop_on_error); - plugin.getLogger().severe(ex.getMessage()); + if (showConsoleMessages) plugin.getLogger().severe(ex.getMessage()); plugin.debug("Failed to create shop (#" + id + ")"); plugin.debug(ex); return false; } else if ((b.getRelative(BlockFace.UP).getType() != Material.AIR) && plugin.getShopChestConfig().show_shop_items) { NotEnoughSpaceException ex = new NotEnoughSpaceException("No space above chest at location: " + b.getX() + "; " + b.getY() + "; " + b.getZ()); plugin.getShopUtils().removeShop(this, plugin.getShopChestConfig().remove_shop_on_error); - plugin.getLogger().severe(ex.getMessage()); + if (showConsoleMessages) plugin.getLogger().severe(ex.getMessage()); plugin.debug("Failed to create shop (#" + id + ")"); plugin.debug(ex); return false; diff --git a/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java b/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java index 6152f5d..b8d5213 100644 --- a/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java +++ b/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java @@ -199,7 +199,7 @@ public class ShopUtils { * @param showConsoleMessages Whether messages about the language file should be shown in the console * @param callback Callback that - if succeeded - returns the amount of shops that were reloaded (as {@code int}) */ - public void reloadShops(boolean reloadConfig, boolean showConsoleMessages, final Callback callback) { + public void reloadShops(boolean reloadConfig, final boolean showConsoleMessages, final Callback callback) { plugin.debug("Reloading shops..."); if (reloadConfig) { @@ -216,13 +216,13 @@ public class ShopUtils { plugin.debug("Removed shop (#" + shop.getID() + ")"); } - plugin.getShopDatabase().getShops(new Callback(plugin) { + plugin.getShopDatabase().getShops(showConsoleMessages, new Callback(plugin) { @Override public void onResult(Object result) { if (result instanceof Shop[]) { Shop[] shops = (Shop[]) result; for (Shop shop : shops) { - if (shop.create()) { + if (shop.create(showConsoleMessages)) { addShop(shop, false); } }