mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-12-23 09:31:46 +00:00
Reduced amount of log messages
This commit is contained in:
parent
ed4a14dfa5
commit
fd9c6beea4
@ -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) {
|
||||
|
@ -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 {
|
||||
|
@ -513,7 +513,7 @@ public class ShopInteractListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
shop.create();
|
||||
shop.create(true);
|
||||
|
||||
plugin.debug("Shop created");
|
||||
shopUtils.addShop(shop, true);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user