Improve performance while reloading shops

This commit is contained in:
Eric 2016-11-24 22:00:49 +01:00
parent d4a88a2a9b
commit a522197112
2 changed files with 12 additions and 20 deletions

View File

@ -324,15 +324,9 @@ public class ShopChest extends JavaPlugin {
debug("Disabling ShopChest...");
if (database != null) {
int highestId = database.getHighestID();
for (int i = 1; i <= highestId; i++) {
for (Shop shop : shopUtils.getShops()) {
if (shop.getID() == i) {
shopUtils.removeShop(shop, false);
debug("Removed shop (#" + shop.getID() + ")");
}
}
for (Shop shop : shopUtils.getShops()) {
shopUtils.removeShop(shop, false);
debug("Removed shop (#" + shop.getID() + ")");
}
database.disconnect();

View File

@ -4,14 +4,16 @@ import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.sql.Database;
import org.bukkit.*;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Chest;
import org.bukkit.block.DoubleChest;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.permissions.PermissionAttachmentInfo;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
public class ShopUtils {
@ -184,17 +186,13 @@ public class ShopUtils {
if (reloadConfig) plugin.getShopChestConfig().reload(false, true, showConsoleMessages);
int highestId = plugin.getShopDatabase().getHighestID();
for (int i = 1; i <= highestId; i++) {
for (Shop shop : getShops()) {
if (shop.getID() == i) {
removeShop(shop, false);
plugin.debug("Removed shop (#" + shop.getID() + ")");
}
}
for (Shop shop : getShops()) {
removeShop(shop, false);
plugin.debug("Removed shop (#" + shop.getID() + ")");
}
int highestId = plugin.getShopDatabase().getHighestID();
int count = 0;
for (int id = 1; id <= highestId; id++) {