Thread: All Shops Lag

Results 1 to 2 of 2
  1. #1 All Shops Lag 
    Registered Member
    Join Date
    Jul 2013
    Posts
    244
    Thanks given
    3
    Thanks received
    11
    Rep Power
    11
    All of my shops have like a 1 second lag before loading when you click on them. Can anyone tell me why this is happening and possibly a fix for it?
    Im using Rune-Evo Source, Matrix Client 718, and 742 Cache
    My Shop.java
    Code:
    package com.rs.game.player.content;
    
    import java.util.concurrent.CopyOnWriteArrayList;
    import java.util.concurrent.TimeUnit;
    
    import com.rs.cache.loaders.ItemDefinitions;
    import com.rs.content.exchange.ItemOffer;
    import com.rs.game.item.Item;
    import com.rs.game.player.Player;
    import com.rs.game.player.content.custom.PriceManager;
    import com.rs.utils.ItemExamines;
    import com.rs.utils.ItemSetsKeyGenerator;
    import com.rs.utils.Utils;
    
    public class Shop {
    	
    	private static final int MAIN_STOCK_ITEMS_KEY = ItemSetsKeyGenerator.generateKey();
    
    	private static final int MAX_SHOP_ITEMS = 40;
    	public static final int COINS = 995;
    
    	private String name;
    	private Item[] mainStock;
    	private int[] defaultQuantity;
    	private Item[] generalStock;
    	private int money;
    	private int amount;
    
    	private CopyOnWriteArrayList<Player> viewingPlayers;
    
    	public Shop(String name, int money, Item[] mainStock, boolean isGeneralStore) {
    		viewingPlayers = new CopyOnWriteArrayList<Player>();
    		this.name = name;
    		this.money = money;
    		this.mainStock = mainStock;
    		defaultQuantity = new int[mainStock.length];
    		for (int i = 0; i < defaultQuantity.length; i++)
    			defaultQuantity[i] = mainStock[i].getAmount();
    		if (isGeneralStore && mainStock.length < MAX_SHOP_ITEMS)
    			generalStock = new Item[MAX_SHOP_ITEMS - mainStock.length];
    	}
    
    	public boolean isGeneralStore() {
    		return generalStock != null;
    	}
    
    	public static int[][] loyaltyPrices = { { 20958, 5000 }, { 22268, 9000 },
    			{ 20962, 5000 }, { 22270, 10000 }, { 20967, 5000 },
    			{ 22272, 8000 }, { 22280, 5000 }, { 22282, 9000 }, { 22284, 5000 },
    			{ 22286, 8000 }, { 20966, 5000 }, { 22274, 10000 },
    			{ 20965, 5000 }, { 22276, 8000 }, { 22288, 5000 }, { 22290, 8000 },
    			{ 22292, 5000 }, { 22294, 10000 }, { 22300, 7000 },
    			{ 22296, 5000 }, { 22298, 10000 }, { 22302, 9000 },
    			{ 23846, 9000 }, { 23854, 9000 }, { 23874, 9000 }, { 23876, 9000 } };
    
    	public void addPlayer(final Player player) {
    		viewingPlayers.add(player);
    		player.getTemporaryAttributtes().put("Shop", this);
    		player.setCloseInterfacesEvent(new Runnable() {
    			@Override
    			public void run() {
    				viewingPlayers.remove(player);
    				player.getTemporaryAttributtes().remove("Shop");
    				player.getTemporaryAttributtes().remove("shop_buying");
    				player.getTemporaryAttributtes().remove("amount_shop");
    			}
    		});
    		player.getPackets().sendConfig(118, MAIN_STOCK_ITEMS_KEY);
    		player.getPackets().sendConfig(1496, -1);
    		player.getPackets().sendConfig(532, money);
    		player.getPackets().sendConfig(2565, 0);
    		sendStore(player);
    		player.getPackets().sendGlobalConfig(199, -1);
    		player.getInterfaceManager().sendInterface(1265);
    		for (int i = 0; i < MAX_SHOP_ITEMS; i++)
    			player.getPackets().sendGlobalConfig(946 + i, i < defaultQuantity.length ? defaultQuantity[i] : generalStock != null ? 0 : -1);// prices
    		player.getPackets().sendGlobalConfig(1241, 16750848);
    		player.getPackets().sendGlobalConfig(1242, 15439903);
    		player.getPackets().sendGlobalConfig(741, -1);
    		player.getPackets().sendGlobalConfig(743, -1);
    		player.getPackets().sendGlobalConfig(744, 0);
    			if (generalStock != null)
    				player.getPackets().sendHideIComponent(1265, 19, false);
    		player.getPackets().sendIComponentSettings(1265, 20, 0, getStoreSize() * 6, 1150);
    		player.getPackets().sendIComponentSettings(1265, 26, 0, getStoreSize() * 6, 82903066);
    		sendInventory(player);
    		player.getPackets().sendIComponentText(1265, 85, name);
    		player.getTemporaryAttributtes().put("shop_buying", true);
    		player.getTemporaryAttributtes().put("amount_shop", 1);
    	}
    
    	public void sendInventory(Player player) {
    		player.getInterfaceManager().sendInventoryInterface(1266);
    		player.getPackets().sendItems(93, player.getInventory().getItems());
    		player.getPackets().sendUnlockIComponentOptionSlots(1266, 0, 0, 27, 0, 1, 2, 3, 4, 5);
    		player.getPackets().sendInterSetItemsOptionsScript(1266, 0, 93, 4, 7, "Value", "Sell 1", "Sell 5", "Sell 10", "Sell 50", "Examine");
    	}
    
    	// cid 67
    
    	public void buy(Player player, int slotId, int quantity) {
    		if (slotId >= getStoreSize())
    			return;
    		Item item = slotId >= mainStock.length ? generalStock[slotId - mainStock.length] : mainStock[slotId];
    		if (item == null)
    			return;
    		if (item.getAmount() == 0) {
    			player.getPackets().sendGameMessage("There is no stock of that item at the moment.");
    			return;
    		}
    		int dq = slotId >= mainStock.length ? 0 : defaultQuantity[slotId];
    		int price = PriceManager.getBuyPrice(item);
    		int amountCoins = player.getInventory().getItems().getNumberOf(money);
    		int maxQuantity = amountCoins / price;
    		int buyQ = item.getAmount() > quantity ? quantity : item.getAmount();
    		boolean enoughCoins = maxQuantity >= buyQ;
    		if (money != 995) {
    			for (int i11 = 0; i11 < loyaltyPrices.length; i11++) {
    				loyaltyShop = 1;
    				if (item.getId() == loyaltyPrices[i11][0]) {
    					if (player.getLoyaltyPoints() < loyaltyPrices[i11][1] * quantity) {
    						player.getPackets().sendGameMessage("You need " + loyaltyPrices[i11][1] + " Loyalty Points to buy this item!");
    						return;
    					} else
    						loyaltyShop = 1;
    					player.getPackets().sendGameMessage("You have bought a " + item.getDefinitions().getName()+ " from the loyalty store.");
    					player.getInventory().addItem(loyaltyPrices[i11][0], 1);
    					player.setLoyaltyPoints(player.getLoyaltyPoints()
    							- loyaltyPrices[i11][1]);
    					return;
    				}
    			}
    		}
    		if (!enoughCoins) {
    			player.getPackets().sendGameMessage("You don't have enough coins.");
    			buyQ = maxQuantity;
    		} else if (quantity > buyQ)
    			player.getPackets().sendGameMessage("The shop has run out of stock.");
    		if (item.getDefinitions().isStackable()) {
    			if (player.getInventory().getFreeSlots() < 1) {
    				player.getPackets().sendGameMessage("Not enough space in your inventory.");
    				return;
    			}
    		} else {
    			int freeSlots = player.getInventory().getFreeSlots();
    			if (buyQ > freeSlots) {
    				buyQ = freeSlots;
    				player.getPackets().sendGameMessage("Not enough space in your inventory.");
    			}
    		}
    		if (buyQ != 0) {
    			int totalPrice = price * buyQ;
    			player.getInventory().deleteItem(money, totalPrice);
    			player.getInventory().addItem(item.getId(), buyQ);
    			item.setAmount(item.getAmount() - buyQ);
    			if (item.getAmount() <= 0 && slotId >= mainStock.length)
    				generalStock[slotId - mainStock.length] = null;
    			refreshShop();
    			sendInventory(player);
    		}
    		if (quantity == 500)
    		player.getTemporaryAttributtes().put("last_shop_purchase", Utils.currentTimeMillis() + 10000);
    	}
    
    	public void restoreItems() {
    		boolean needRefresh = false;
    		for (int i = 0; i < mainStock.length; i++) {
    			if (mainStock[i].getAmount() < defaultQuantity[i]) {
    				mainStock[i].setAmount(mainStock[i].getAmount() + 1);
    				needRefresh = true;
    			} else if (mainStock[i].getAmount() > defaultQuantity[i]) {
    				mainStock[i].setAmount(mainStock[i].getAmount() + -1);
    				needRefresh = true;
    			}
    		}
    		if (generalStock != null) {
    			for (int i = 0; i < generalStock.length; i++) {
    				Item item = generalStock[i];
    				if (item == null)
    					continue;
    				item.setAmount(item.getAmount() - 1);
    				if (item.getAmount() <= 0)
    					generalStock[i] = null;
    				needRefresh = true;
    			}
    		}
    		if (needRefresh)
    			refreshShop();
    	}
    
    	private boolean addItem(int itemId, int quantity) {
    		for (Item item : mainStock) {
    			if (item.getId() == itemId) {
    				item.setAmount(item.getAmount() + quantity);
    				refreshShop();
    				return true;
    			}
    		}
    		if (generalStock != null) {
    			for (Item item : generalStock) {
    				if (item == null)
    					continue;
    				if (item.getId() == itemId) {
    					item.setAmount(item.getAmount() + quantity);
    					refreshShop();
    					return true;
    				}
    			}
    			for (int i = 0; i < generalStock.length; i++) {
    				if (generalStock[i] == null) {
    					generalStock[i] = new Item(itemId, quantity);
    					refreshShop();
    					return true;
    				}
    			}
    		}
    		return false;
    	}
    
    	public void sell(Player player, int slotId, int quantity) {
    		if (player.getInventory().getItemsContainerSize() < slotId)
    			return;
    		Item item = player.getInventory().getItem(slotId);
    		if (item == null)
    			return;
    		int originalId = item.getId();
    		if (item.getDefinitions().isNoted())
    			item = new Item(item.getDefinitions().getCertId(), item.getAmount());
    		if (item.getDefinitions().isDestroyItem()
    				|| ItemConstants.getItemDefaultCharges(item.getId()) != -1
    				|| !ItemConstants.isTradeable(item) || item.getId() == money) {
    			player.getPackets().sendGameMessage("You can't sell this item.");
    			return;
    		}
    		int dq = getDefaultQuantity(item.getId());
    		if (dq == -1 && generalStock == null) {
    			player.getPackets().sendGameMessage("You can't sell this item to this shop.");
    			return;
    		}
    		int price = PriceManager.getSellPrice(item);
    		int numberOff = player.getInventory().getItems().getNumberOf(originalId);
    		if (quantity > numberOff)
    			quantity = numberOff;
    		if (!addItem(item.getId(), quantity)) {
    			player.getPackets().sendGameMessage("Shop is currently full.");
    			return;
    		}
    		player.getInventory().deleteItem(originalId, quantity);
    		player.getInventory().addItem(money, price * quantity);
    	}
    
    	public static int loyaltyShop = 0;
    
    	public void sendValue(Player player, int slotId) {
    		if (player.getInventory().getItemsContainerSize() < slotId)
    			return;
    		Item item = player.getInventory().getItem(slotId);
    		if (item == null)
    			return;
    		if (item.getDefinitions().isNoted())
    			item = new Item(item.getDefinitions().getCertId(), item.getAmount());
    		if (item.getDefinitions().isNoted() || !ItemConstants.isTradeable(item)
    				|| item.getId() == money) {
    			player.getPackets().sendGameMessage("You can't sell this item.");
    			return;
    		}
    		int dq = getDefaultQuantity(item.getId());
    		if (dq == -1 && generalStock == null) {
    			player.getPackets().sendGameMessage("You can't sell this item to this shop.");
    			return;
    		}
    		int price = PriceManager.getSellPrice(item);
    		if (money == 995)
    			player.getPackets().sendGameMessage(item.getDefinitions().getName() + ": shop will buy for: " + price+ " " + ItemDefinitions.getItemDefinitions(money).getName().toLowerCase() + ". Right-click the item to sell.");
    
    	}
    
    	public int getDefaultQuantity(int itemId) {
    		for (int i = 0; i < mainStock.length; i++)
    			if (mainStock[i].getId() == itemId)
    				return defaultQuantity[i];
    		return -1;
    	}
    
    	public void sendInfo(Player player, int slotId, boolean isBuying) {
    		if (slotId >= getStoreSize())
    			return;
    		Item[] stock = isBuying ? mainStock : player.getInventory().getItems().getItems();
    		Item item = slotId >= stock.length ? generalStock[slotId - stock.length] : stock[slotId];
    		if (item == null)
    			return;
    		int dq = slotId >= mainStock.length ? 0 : defaultQuantity[slotId];
    		int price = isBuying ? PriceManager.getBuyPrice(item) : PriceManager.getSellPrice(item);
    		for (int i = 0; i < loyaltyPrices.length; i++) {
    			if (item.getId() == loyaltyPrices[i][0]) {
    				player.getPackets().sendGameMessage("" + item.getDefinitions().getName() + " costs " + loyaltyPrices[i][1] + " loyalty points.");
    				player.getPackets().sendConfig(2564, loyaltyPrices[i][1]);
    				return;
    			}
    		}
    		player.getPackets().sendConfig(2564, price);
    		player.getPackets().sendGameMessage(item.getDefinitions().getName() + ": shop will " + (isBuying ? "sell" : "buy") + " for " + price + " " + ItemDefinitions.getItemDefinitions(money).getName().toLowerCase() + ".");
    	}
    
    	public void sendExamine(Player player, int slotId) {
    		if (slotId >= getStoreSize())
    			return;
    		Item item = slotId >= mainStock.length ? generalStock[slotId
    				- mainStock.length] : mainStock[slotId];
    		if (item == null)
    			return;
    		player.getPackets().sendGameMessage(ItemExamines.getExamine(item));
    	}
    
    	public void refreshShop() {
    		for (Player player : viewingPlayers) {
    			sendStore(player);
    			player.getPackets().sendIComponentSettings(620, 25, 0, getStoreSize() * 6, 1150);
    		}
    	}
    
    	public int getStoreSize() {
    		return mainStock.length + (generalStock != null ? generalStock.length : 0);
    	}
    
    	public void sendStore(Player player) {
    		Item[] stock = new Item[mainStock.length + (generalStock != null ? generalStock.length : 0)];
    		System.arraycopy(mainStock, 0, stock, 0, mainStock.length);
    		if (generalStock != null)
    			System.arraycopy(generalStock, 0, stock, mainStock.length, generalStock.length);
    		player.getPackets().sendItems(MAIN_STOCK_ITEMS_KEY, stock);
    	}
    
    	public void sendSellStore(Player player, Item[] inventory) {
    		Item[] stock = new Item[inventory.length + (generalStock != null ? generalStock.length : 0)];
    		System.arraycopy(inventory, 0, stock, 0, inventory.length);
    		if (generalStock != null)
    			System.arraycopy(generalStock, 0, stock, inventory.length, generalStock.length);
    		player.getPackets().sendItems(MAIN_STOCK_ITEMS_KEY, stock);
    	}
    
    	/**
    	 * Checks if the player is buying an item or selling it.
    	 * 
    	 * @param player
    	 *            The player
    	 * @param slotId
    	 *            The slot id
    	 * @param amount
    	 *            The amount
    	 */
    	public void handleShop(Player player, int slotId, int amount) {
    		boolean isBuying = player.getTemporaryAttributtes().get("shop_buying") != null;
    		if (isBuying)
    			buy(player, slotId, amount);
    		else
    			sell(player, slotId, amount);
    	}
    
    	public Item[] getMainStock() {
    		return this.mainStock;
    	}
    
    	public int getAmount() {
    		return this.amount;
    	}
    
    	public void setAmount(Player player, int amount) {
    		this.amount = amount;
    		player.getPackets().sendIComponentText(1265, 67, String.valueOf(amount)); 
    	}
    }
    And i will also post my PriceManager.java ( This is where the prices for my shops are)
    Code:
    package com.rs.game.player.content.custom;
    
    import com.rs.game.item.Item;
    
    /**
     * @author King Fox
     */
    public enum PriceManager 
    {
    
    	ITEM_1(10330, 65000000),
    	ITEM_2(10332, 65000000),
    	ITEM_3(10334, 65000000),
    	ITEM_4(10336, 40000000),
    	ITEM_5(10338, 65000000),
    	ITEM_6(10340, 65000000),
    	ITEM_7(10342, 65000000),
    	ITEM_8(10344, 40000000),
    	ITEM_9(10346, 65000000),
    	ITEM_10(10348, 65000000),
    	ITEM_11(10350, 65000000),
    	ITEM_12(10352, 65000000),
    	ITEM_13(18830, 65000),
    	ITEM_14(18830, 65000),
    	ITEM_15(24365, 50000000),
    	ITEM_16(24437, 70000000),
    	ITEM_17(24439, 70000000),
    	ITEM_18(24440, 70000000),
    	ITEM_19(24441, 70000000),
    	ITEM_20(18744, 100000000),
    	ITEM_21(18745, 100000000),
    	ITEM_22(18746, 100000000),
    	ITEM_23(3753, 750000),
    	ITEM_24(3755, 750000),
    	ITEM_25(3751, 750000),
    	ITEM_26(3749, 750000),
    	ITEM_27(6735, 5000000),
    	ITEM_28(6737, 5000000),
    	ITEM_29(6731, 5000000),
    	ITEM_30(6733, 5000000),
    	ITEM_31(15270, 10000),
    	ITEM_32(15271, 10000),
    	ITEM_33(15272, 10000),
    	ITEM_34(15273, 10000),
    	ITEM_35(20949, 50000000),
    	ITEM_36(20950, 50000000),
    	ITEM_37(20951, 50000000),
    	ITEM_38(20952, 50000000),
    	ITEM_39(22207, 50000000),
    	ITEM_40(22209, 50000000),
    	ITEM_41(22211, 50000000),
    	ITEM_42(22213, 50000000),
    	ITEM_43(15243, 15000),
    	ITEM_44(14497, 15000),
    	ITEM_45(14499, 15000),
    	ITEM_46(14501, 15000),
    	ITEM_47(15441, 500),
    	ITEM_48(15442, 500),
    	ITEM_49(15443, 500),
    	ITEM_50(15444, 500),
    	ITEM_51(10548, 500),
    	ITEM_52(15241, 70000000),
    	ITEM_53(24092, 2000000),
    	ITEM_54(24094, 2000000),
    	ITEM_55(24096, 2000000),
    	ITEM_56(24098, 2000000),
    	ITEM_57(22358, 1700),
    	ITEM_58(22359, 1700),
    	ITEM_59(22360, 1700),
    	ITEM_60(22361, 1700),
    	ITEM_61(22362, 1700),
    	ITEM_62(22364, 1700),
    	ITEM_63(22365, 1700),
    	ITEM_64(4675, 2000000),
    	ITEM_65(10551, 450),
    	ITEM_66(18335, 250000000),
    	ITEM_67(25202, 250000000),
    	ITEM_68(24167, 350000000),
    	ITEM_69(21773, 6000),
    	ITEM_70(22482, 35000000),
    	ITEM_71(22486, 35000000),
    	ITEM_72(22490, 35000000),
    	ITEM_73(22494, 35000000),
    	ITEM_74(22458, 75000),
    	ITEM_75(22462, 75000),
    	ITEM_76(22466, 75000),
    	ITEM_77(21777, 60000000),
    	ITEM_78(8850, 5000000),
    	ITEM_79(8849, 2500000),
    	ITEM_80(10828, 2500000),
    	ITEM_81(8848, 100000),
    	ITEM_82(8847, 100000),
    	ITEM_83(8846, 100000),
    	ITEM_84(8845, 100000),
    	ITEM_85(8844, 100000),
    	ITEM_86(7459, 100000),
    	ITEM_87(22470, 100000),
    	ITEM_88(22474, 100000),
    	ITEM_89(22478, 100000),
    	ITEM_90(2412, 100000),
    	ITEM_91(2413, 100000),
    	ITEM_92(2414, 100000),
    	ITEM_93(21790, 20000000),
    	ITEM_94(23531, 80000),
    	ITEM_95(23621, 10000),
    	ITEM_96(23351, 10000),
    	ITEM_97(6685, 10000),
    	ITEM_98(6686, 10000),
    	ITEM_99(12196, 1),
    	ITEM_100(21512, 1),
    	ITEM_101(22992, 1),
    	ITEM_102(24511, 1),
    	ITEM_103(24512, 1),
    	ITEM_104(4722, 10000000),
    	ITEM_105(4720, 10000000),
    	ITEM_106(4718, 10000000),
    	ITEM_107(4716, 10000000),
    	ITEM_108(4753, 10000000),
    	ITEM_109(4755, 10000000),
    	ITEM_110(4757, 10000000),
    	ITEM_111(4759, 10000000),
    	ITEM_112(4724, 10000000),
    	ITEM_113(4726, 10000000),
    	ITEM_114(4728, 10000000),
    	ITEM_115(4730, 10000000),
    	ITEM_116(4745, 10000000),
    	ITEM_117(4747, 10000000),
    	ITEM_118(4749, 10000000),
    	ITEM_119(4751, 10000000),
    	ITEM_120(4714, 7500000),
    	ITEM_121(4710, 7500000),
    	ITEM_122(4708, 7500000),
    	ITEM_123(4736, 7500000),
    	ITEM_124(4738, 7500000),
    	ITEM_125(4732, 7500000),
    	ITEM_126(4734, 7500000),
    	ITEM_127(6914, 10000000),
    	ITEM_128(7462, 10000000),
    	ITEM_129(20072, 10000000),
    	ITEM_130(8839, 10000000),
    	ITEM_131(8840, 10000000),
    	ITEM_132(8842, 10000000),
    	ITEM_133(10611, 10000000),
    	ITEM_134(11663, 10000000),
    	ITEM_135(11664, 10000000),
    	ITEM_136(11665, 10000000),
    	ITEM_137(6746, 100000000),
    	ITEM_138(13734, 100000000),
    	ITEM_139(3481, 300000),
    	ITEM_140(3483, 300000),
    	ITEM_141(3485, 300000),
    	ITEM_142(3486, 300000),
    	ITEM_143(3488, 300000),
    	ITEM_144(11716, 80000000),
    	ITEM_145(6889, 5500000),
    	ITEM_146(3105, 75000),
    	ITEM_147(15126, 500000),
    	ITEM_148(3842, 1000000),
    	ITEM_149(3840, 1000000),
    	ITEM_150(7460, 1000000),
    	ITEM_151(9244, 7500),
    	ITEM_152(1050, 2147483647),
    	ITEM_153(11720, 200000000),
    	ITEM_154(11722, 200000000),
    	ITEM_155(11724, 250000000),
    	ITEM_156(11726, 250000000),
    	ITEM_157(10008, 15000),
    	ITEM_158(10006, 15000),
    	ITEM_159(2577, 80000000),
    	ITEM_160(2581, 80000000),
    	ITEM_161(11235, 30000000),
    	ITEM_162(15486, 6000000),
    	ITEM_163(15332, 50000),
    	ITEM_164(6918, 1750000),
    	ITEM_165(6920, 1000000),
    	ITEM_166(6916, 1500000),
    	ITEM_167(324, 250000),
    	ITEM_168(1386, 250000),
    	ITEM_169(6922, 1000000),
    	ITEM_170(6924, 1250000),
    	ITEM_171(11335, 75000000),
    	ITEM_172(14479, 65000000),
    	ITEM_173(3140, 5000000),
    	ITEM_174(11732, 10000000),
    	ITEM_175(4087, 2500000),
    	ITEM_176(4585, 2500000),
    	ITEM_177(1187, 550000),
    	ITEM_178(4151, 15000000),
    	ITEM_179(20671, 350000),
    	ITEM_180(21371, 65000000),
    	ITEM_181(11696, 300000000),
    	ITEM_182(11700, 400000000),
    	ITEM_183(11698, 500000000),
    	ITEM_184(13754, 500000000),
    	ITEM_185(11694, 600000000),
    	ITEM_186(14484, 500),
    	ITEM_187(23659, 440),
    	ITEM_188(18349, 1500),
    	ITEM_189(18351, 1500),
    	ITEM_190(18353, 1500),
    	ITEM_191(18355, 1500),
    	ITEM_192(3024, 15000),
    	ITEM_193(3025, 15000),
    	ITEM_194(4153, 3500000),
    	ITEM_195(18357, 1500),
    	ITEM_196(11690, 20000000),
    	ITEM_197(18359, 1500),
    	ITEM_198(19784, 2000),
    	ITEM_199(21787, 18000000),
    	ITEM_200(11730, 65000000),
    	ITEM_201(11702, 500000000),
    	ITEM_202(11708, 300000000),
    	ITEM_203(11704, 200000000),
    	ITEM_204(11706, 400000000),
    	ITEM_205(15017, 30000000),
    	ITEM_206(15020, 30000000),
    	ITEM_207(15220, 30000000),
    	ITEM_208(15018, 30000000),
    	ITEM_209(15019, 30000000),
    	ITEM_210(1609, 5000),
    	ITEM_211(1611, 6000),
    	ITEM_212(1613, 7000),
    	ITEM_213(1607, 8000),
    	ITEM_214(1605, 9000),
    	ITEM_215(1603, 10000),
    	ITEM_216(1601, 11000),
    	ITEM_217(1615, 12000),
    	ITEM_218(19780, 330000000),
    	ITEM_219(6585, 27000000),
    	ITEM_220(21793, 18000000),
    	ITEM_221(1662, 200000),
    	ITEM_222(7650, 150000),
    	ITEM_223(1635, 100000),
    	ITEM_224(1739, 60000),
    	ITEM_225(950, 40000);
    	
    	int itemid;
    	int buyPrice;
    	
    	PriceManager(int itemId, int price) {
    		this.itemid = itemId;
    		this.buyPrice = price;
    	}
    	
    	public int getId() {
    		return itemid;
    	}
    	public int getPrice() {
    		return buyPrice;
    	}
    	
    	public static int getBuyPrice(Item item) {
    		int itemId = item.getId();
    		for (PriceManager get : PriceManager.values()) {
    			if (itemId == get.itemid) {
    				return get.buyPrice;
    			}
    		}
    		return item.getDefinitions().getValue();
    	}
    	
    	public static int getSellPrice(Item item) {
    		return (int) (getBuyPrice(item) / 1.3);
    	}
    }
    Reply With Quote  
     

  2. #2  
    Registered Member Rich guy's Avatar
    Join Date
    May 2013
    Posts
    759
    Thanks given
    33
    Thanks received
    30
    Rep Power
    43
    Quote Originally Posted by falloutscape View Post
    All of my shops have like a 1 second lag before loading when you click on them. Can anyone tell me why this is happening and possibly a fix for it?
    Im using Rune-Evo Source, Matrix Client 718, and 742 Cache
    My Shop.java
    Code:
    package com.rs.game.player.content;
    
    import java.util.concurrent.CopyOnWriteArrayList;
    import java.util.concurrent.TimeUnit;
    
    import com.rs.cache.loaders.ItemDefinitions;
    import com.rs.content.exchange.ItemOffer;
    import com.rs.game.item.Item;
    import com.rs.game.player.Player;
    import com.rs.game.player.content.custom.PriceManager;
    import com.rs.utils.ItemExamines;
    import com.rs.utils.ItemSetsKeyGenerator;
    import com.rs.utils.Utils;
    
    public class Shop {
    	
    	private static final int MAIN_STOCK_ITEMS_KEY = ItemSetsKeyGenerator.generateKey();
    
    	private static final int MAX_SHOP_ITEMS = 40;
    	public static final int COINS = 995;
    
    	private String name;
    	private Item[] mainStock;
    	private int[] defaultQuantity;
    	private Item[] generalStock;
    	private int money;
    	private int amount;
    
    	private CopyOnWriteArrayList<Player> viewingPlayers;
    
    	public Shop(String name, int money, Item[] mainStock, boolean isGeneralStore) {
    		viewingPlayers = new CopyOnWriteArrayList<Player>();
    		this.name = name;
    		this.money = money;
    		this.mainStock = mainStock;
    		defaultQuantity = new int[mainStock.length];
    		for (int i = 0; i < defaultQuantity.length; i++)
    			defaultQuantity[i] = mainStock[i].getAmount();
    		if (isGeneralStore && mainStock.length < MAX_SHOP_ITEMS)
    			generalStock = new Item[MAX_SHOP_ITEMS - mainStock.length];
    	}
    
    	public boolean isGeneralStore() {
    		return generalStock != null;
    	}
    
    	public static int[][] loyaltyPrices = { { 20958, 5000 }, { 22268, 9000 },
    			{ 20962, 5000 }, { 22270, 10000 }, { 20967, 5000 },
    			{ 22272, 8000 }, { 22280, 5000 }, { 22282, 9000 }, { 22284, 5000 },
    			{ 22286, 8000 }, { 20966, 5000 }, { 22274, 10000 },
    			{ 20965, 5000 }, { 22276, 8000 }, { 22288, 5000 }, { 22290, 8000 },
    			{ 22292, 5000 }, { 22294, 10000 }, { 22300, 7000 },
    			{ 22296, 5000 }, { 22298, 10000 }, { 22302, 9000 },
    			{ 23846, 9000 }, { 23854, 9000 }, { 23874, 9000 }, { 23876, 9000 } };
    
    	public void addPlayer(final Player player) {
    		viewingPlayers.add(player);
    		player.getTemporaryAttributtes().put("Shop", this);
    		player.setCloseInterfacesEvent(new Runnable() {
    			@Override
    			public void run() {
    				viewingPlayers.remove(player);
    				player.getTemporaryAttributtes().remove("Shop");
    				player.getTemporaryAttributtes().remove("shop_buying");
    				player.getTemporaryAttributtes().remove("amount_shop");
    			}
    		});
    		player.getPackets().sendConfig(118, MAIN_STOCK_ITEMS_KEY);
    		player.getPackets().sendConfig(1496, -1);
    		player.getPackets().sendConfig(532, money);
    		player.getPackets().sendConfig(2565, 0);
    		sendStore(player);
    		player.getPackets().sendGlobalConfig(199, -1);
    		player.getInterfaceManager().sendInterface(1265);
    		for (int i = 0; i < MAX_SHOP_ITEMS; i++)
    			player.getPackets().sendGlobalConfig(946 + i, i < defaultQuantity.length ? defaultQuantity[i] : generalStock != null ? 0 : -1);// prices
    		player.getPackets().sendGlobalConfig(1241, 16750848);
    		player.getPackets().sendGlobalConfig(1242, 15439903);
    		player.getPackets().sendGlobalConfig(741, -1);
    		player.getPackets().sendGlobalConfig(743, -1);
    		player.getPackets().sendGlobalConfig(744, 0);
    			if (generalStock != null)
    				player.getPackets().sendHideIComponent(1265, 19, false);
    		player.getPackets().sendIComponentSettings(1265, 20, 0, getStoreSize() * 6, 1150);
    		player.getPackets().sendIComponentSettings(1265, 26, 0, getStoreSize() * 6, 82903066);
    		sendInventory(player);
    		player.getPackets().sendIComponentText(1265, 85, name);
    		player.getTemporaryAttributtes().put("shop_buying", true);
    		player.getTemporaryAttributtes().put("amount_shop", 1);
    	}
    
    	public void sendInventory(Player player) {
    		player.getInterfaceManager().sendInventoryInterface(1266);
    		player.getPackets().sendItems(93, player.getInventory().getItems());
    		player.getPackets().sendUnlockIComponentOptionSlots(1266, 0, 0, 27, 0, 1, 2, 3, 4, 5);
    		player.getPackets().sendInterSetItemsOptionsScript(1266, 0, 93, 4, 7, "Value", "Sell 1", "Sell 5", "Sell 10", "Sell 50", "Examine");
    	}
    
    	// cid 67
    
    	public void buy(Player player, int slotId, int quantity) {
    		if (slotId >= getStoreSize())
    			return;
    		Item item = slotId >= mainStock.length ? generalStock[slotId - mainStock.length] : mainStock[slotId];
    		if (item == null)
    			return;
    		if (item.getAmount() == 0) {
    			player.getPackets().sendGameMessage("There is no stock of that item at the moment.");
    			return;
    		}
    		int dq = slotId >= mainStock.length ? 0 : defaultQuantity[slotId];
    		int price = PriceManager.getBuyPrice(item);
    		int amountCoins = player.getInventory().getItems().getNumberOf(money);
    		int maxQuantity = amountCoins / price;
    		int buyQ = item.getAmount() > quantity ? quantity : item.getAmount();
    		boolean enoughCoins = maxQuantity >= buyQ;
    		if (money != 995) {
    			for (int i11 = 0; i11 < loyaltyPrices.length; i11++) {
    				loyaltyShop = 1;
    				if (item.getId() == loyaltyPrices[i11][0]) {
    					if (player.getLoyaltyPoints() < loyaltyPrices[i11][1] * quantity) {
    						player.getPackets().sendGameMessage("You need " + loyaltyPrices[i11][1] + " Loyalty Points to buy this item!");
    						return;
    					} else
    						loyaltyShop = 1;
    					player.getPackets().sendGameMessage("You have bought a " + item.getDefinitions().getName()+ " from the loyalty store.");
    					player.getInventory().addItem(loyaltyPrices[i11][0], 1);
    					player.setLoyaltyPoints(player.getLoyaltyPoints()
    							- loyaltyPrices[i11][1]);
    					return;
    				}
    			}
    		}
    		if (!enoughCoins) {
    			player.getPackets().sendGameMessage("You don't have enough coins.");
    			buyQ = maxQuantity;
    		} else if (quantity > buyQ)
    			player.getPackets().sendGameMessage("The shop has run out of stock.");
    		if (item.getDefinitions().isStackable()) {
    			if (player.getInventory().getFreeSlots() < 1) {
    				player.getPackets().sendGameMessage("Not enough space in your inventory.");
    				return;
    			}
    		} else {
    			int freeSlots = player.getInventory().getFreeSlots();
    			if (buyQ > freeSlots) {
    				buyQ = freeSlots;
    				player.getPackets().sendGameMessage("Not enough space in your inventory.");
    			}
    		}
    		if (buyQ != 0) {
    			int totalPrice = price * buyQ;
    			player.getInventory().deleteItem(money, totalPrice);
    			player.getInventory().addItem(item.getId(), buyQ);
    			item.setAmount(item.getAmount() - buyQ);
    			if (item.getAmount() <= 0 && slotId >= mainStock.length)
    				generalStock[slotId - mainStock.length] = null;
    			refreshShop();
    			sendInventory(player);
    		}
    		if (quantity == 500)
    		player.getTemporaryAttributtes().put("last_shop_purchase", Utils.currentTimeMillis() + 10000);
    	}
    
    	public void restoreItems() {
    		boolean needRefresh = false;
    		for (int i = 0; i < mainStock.length; i++) {
    			if (mainStock[i].getAmount() < defaultQuantity[i]) {
    				mainStock[i].setAmount(mainStock[i].getAmount() + 1);
    				needRefresh = true;
    			} else if (mainStock[i].getAmount() > defaultQuantity[i]) {
    				mainStock[i].setAmount(mainStock[i].getAmount() + -1);
    				needRefresh = true;
    			}
    		}
    		if (generalStock != null) {
    			for (int i = 0; i < generalStock.length; i++) {
    				Item item = generalStock[i];
    				if (item == null)
    					continue;
    				item.setAmount(item.getAmount() - 1);
    				if (item.getAmount() <= 0)
    					generalStock[i] = null;
    				needRefresh = true;
    			}
    		}
    		if (needRefresh)
    			refreshShop();
    	}
    
    	private boolean addItem(int itemId, int quantity) {
    		for (Item item : mainStock) {
    			if (item.getId() == itemId) {
    				item.setAmount(item.getAmount() + quantity);
    				refreshShop();
    				return true;
    			}
    		}
    		if (generalStock != null) {
    			for (Item item : generalStock) {
    				if (item == null)
    					continue;
    				if (item.getId() == itemId) {
    					item.setAmount(item.getAmount() + quantity);
    					refreshShop();
    					return true;
    				}
    			}
    			for (int i = 0; i < generalStock.length; i++) {
    				if (generalStock[i] == null) {
    					generalStock[i] = new Item(itemId, quantity);
    					refreshShop();
    					return true;
    				}
    			}
    		}
    		return false;
    	}
    
    	public void sell(Player player, int slotId, int quantity) {
    		if (player.getInventory().getItemsContainerSize() < slotId)
    			return;
    		Item item = player.getInventory().getItem(slotId);
    		if (item == null)
    			return;
    		int originalId = item.getId();
    		if (item.getDefinitions().isNoted())
    			item = new Item(item.getDefinitions().getCertId(), item.getAmount());
    		if (item.getDefinitions().isDestroyItem()
    				|| ItemConstants.getItemDefaultCharges(item.getId()) != -1
    				|| !ItemConstants.isTradeable(item) || item.getId() == money) {
    			player.getPackets().sendGameMessage("You can't sell this item.");
    			return;
    		}
    		int dq = getDefaultQuantity(item.getId());
    		if (dq == -1 && generalStock == null) {
    			player.getPackets().sendGameMessage("You can't sell this item to this shop.");
    			return;
    		}
    		int price = PriceManager.getSellPrice(item);
    		int numberOff = player.getInventory().getItems().getNumberOf(originalId);
    		if (quantity > numberOff)
    			quantity = numberOff;
    		if (!addItem(item.getId(), quantity)) {
    			player.getPackets().sendGameMessage("Shop is currently full.");
    			return;
    		}
    		player.getInventory().deleteItem(originalId, quantity);
    		player.getInventory().addItem(money, price * quantity);
    	}
    
    	public static int loyaltyShop = 0;
    
    	public void sendValue(Player player, int slotId) {
    		if (player.getInventory().getItemsContainerSize() < slotId)
    			return;
    		Item item = player.getInventory().getItem(slotId);
    		if (item == null)
    			return;
    		if (item.getDefinitions().isNoted())
    			item = new Item(item.getDefinitions().getCertId(), item.getAmount());
    		if (item.getDefinitions().isNoted() || !ItemConstants.isTradeable(item)
    				|| item.getId() == money) {
    			player.getPackets().sendGameMessage("You can't sell this item.");
    			return;
    		}
    		int dq = getDefaultQuantity(item.getId());
    		if (dq == -1 && generalStock == null) {
    			player.getPackets().sendGameMessage("You can't sell this item to this shop.");
    			return;
    		}
    		int price = PriceManager.getSellPrice(item);
    		if (money == 995)
    			player.getPackets().sendGameMessage(item.getDefinitions().getName() + ": shop will buy for: " + price+ " " + ItemDefinitions.getItemDefinitions(money).getName().toLowerCase() + ". Right-click the item to sell.");
    
    	}
    
    	public int getDefaultQuantity(int itemId) {
    		for (int i = 0; i < mainStock.length; i++)
    			if (mainStock[i].getId() == itemId)
    				return defaultQuantity[i];
    		return -1;
    	}
    
    	public void sendInfo(Player player, int slotId, boolean isBuying) {
    		if (slotId >= getStoreSize())
    			return;
    		Item[] stock = isBuying ? mainStock : player.getInventory().getItems().getItems();
    		Item item = slotId >= stock.length ? generalStock[slotId - stock.length] : stock[slotId];
    		if (item == null)
    			return;
    		int dq = slotId >= mainStock.length ? 0 : defaultQuantity[slotId];
    		int price = isBuying ? PriceManager.getBuyPrice(item) : PriceManager.getSellPrice(item);
    		for (int i = 0; i < loyaltyPrices.length; i++) {
    			if (item.getId() == loyaltyPrices[i][0]) {
    				player.getPackets().sendGameMessage("" + item.getDefinitions().getName() + " costs " + loyaltyPrices[i][1] + " loyalty points.");
    				player.getPackets().sendConfig(2564, loyaltyPrices[i][1]);
    				return;
    			}
    		}
    		player.getPackets().sendConfig(2564, price);
    		player.getPackets().sendGameMessage(item.getDefinitions().getName() + ": shop will " + (isBuying ? "sell" : "buy") + " for " + price + " " + ItemDefinitions.getItemDefinitions(money).getName().toLowerCase() + ".");
    	}
    
    	public void sendExamine(Player player, int slotId) {
    		if (slotId >= getStoreSize())
    			return;
    		Item item = slotId >= mainStock.length ? generalStock[slotId
    				- mainStock.length] : mainStock[slotId];
    		if (item == null)
    			return;
    		player.getPackets().sendGameMessage(ItemExamines.getExamine(item));
    	}
    
    	public void refreshShop() {
    		for (Player player : viewingPlayers) {
    			sendStore(player);
    			player.getPackets().sendIComponentSettings(620, 25, 0, getStoreSize() * 6, 1150);
    		}
    	}
    
    	public int getStoreSize() {
    		return mainStock.length + (generalStock != null ? generalStock.length : 0);
    	}
    
    	public void sendStore(Player player) {
    		Item[] stock = new Item[mainStock.length + (generalStock != null ? generalStock.length : 0)];
    		System.arraycopy(mainStock, 0, stock, 0, mainStock.length);
    		if (generalStock != null)
    			System.arraycopy(generalStock, 0, stock, mainStock.length, generalStock.length);
    		player.getPackets().sendItems(MAIN_STOCK_ITEMS_KEY, stock);
    	}
    
    	public void sendSellStore(Player player, Item[] inventory) {
    		Item[] stock = new Item[inventory.length + (generalStock != null ? generalStock.length : 0)];
    		System.arraycopy(inventory, 0, stock, 0, inventory.length);
    		if (generalStock != null)
    			System.arraycopy(generalStock, 0, stock, inventory.length, generalStock.length);
    		player.getPackets().sendItems(MAIN_STOCK_ITEMS_KEY, stock);
    	}
    
    	/**
    	 * Checks if the player is buying an item or selling it.
    	 * 
    	 * @param player
    	 *            The player
    	 * @param slotId
    	 *            The slot id
    	 * @param amount
    	 *            The amount
    	 */
    	public void handleShop(Player player, int slotId, int amount) {
    		boolean isBuying = player.getTemporaryAttributtes().get("shop_buying") != null;
    		if (isBuying)
    			buy(player, slotId, amount);
    		else
    			sell(player, slotId, amount);
    	}
    
    	public Item[] getMainStock() {
    		return this.mainStock;
    	}
    
    	public int getAmount() {
    		return this.amount;
    	}
    
    	public void setAmount(Player player, int amount) {
    		this.amount = amount;
    		player.getPackets().sendIComponentText(1265, 67, String.valueOf(amount)); 
    	}
    }
    And i will also post my PriceManager.java ( This is where the prices for my shops are)
    Code:
    package com.rs.game.player.content.custom;
    
    import com.rs.game.item.Item;
    
    /**
     * @author King Fox
     */
    public enum PriceManager 
    {
    
    	ITEM_1(10330, 65000000),
    	ITEM_2(10332, 65000000),
    	ITEM_3(10334, 65000000),
    	ITEM_4(10336, 40000000),
    	ITEM_5(10338, 65000000),
    	ITEM_6(10340, 65000000),
    	ITEM_7(10342, 65000000),
    	ITEM_8(10344, 40000000),
    	ITEM_9(10346, 65000000),
    	ITEM_10(10348, 65000000),
    	ITEM_11(10350, 65000000),
    	ITEM_12(10352, 65000000),
    	ITEM_13(18830, 65000),
    	ITEM_14(18830, 65000),
    	ITEM_15(24365, 50000000),
    	ITEM_16(24437, 70000000),
    	ITEM_17(24439, 70000000),
    	ITEM_18(24440, 70000000),
    	ITEM_19(24441, 70000000),
    	ITEM_20(18744, 100000000),
    	ITEM_21(18745, 100000000),
    	ITEM_22(18746, 100000000),
    	ITEM_23(3753, 750000),
    	ITEM_24(3755, 750000),
    	ITEM_25(3751, 750000),
    	ITEM_26(3749, 750000),
    	ITEM_27(6735, 5000000),
    	ITEM_28(6737, 5000000),
    	ITEM_29(6731, 5000000),
    	ITEM_30(6733, 5000000),
    	ITEM_31(15270, 10000),
    	ITEM_32(15271, 10000),
    	ITEM_33(15272, 10000),
    	ITEM_34(15273, 10000),
    	ITEM_35(20949, 50000000),
    	ITEM_36(20950, 50000000),
    	ITEM_37(20951, 50000000),
    	ITEM_38(20952, 50000000),
    	ITEM_39(22207, 50000000),
    	ITEM_40(22209, 50000000),
    	ITEM_41(22211, 50000000),
    	ITEM_42(22213, 50000000),
    	ITEM_43(15243, 15000),
    	ITEM_44(14497, 15000),
    	ITEM_45(14499, 15000),
    	ITEM_46(14501, 15000),
    	ITEM_47(15441, 500),
    	ITEM_48(15442, 500),
    	ITEM_49(15443, 500),
    	ITEM_50(15444, 500),
    	ITEM_51(10548, 500),
    	ITEM_52(15241, 70000000),
    	ITEM_53(24092, 2000000),
    	ITEM_54(24094, 2000000),
    	ITEM_55(24096, 2000000),
    	ITEM_56(24098, 2000000),
    	ITEM_57(22358, 1700),
    	ITEM_58(22359, 1700),
    	ITEM_59(22360, 1700),
    	ITEM_60(22361, 1700),
    	ITEM_61(22362, 1700),
    	ITEM_62(22364, 1700),
    	ITEM_63(22365, 1700),
    	ITEM_64(4675, 2000000),
    	ITEM_65(10551, 450),
    	ITEM_66(18335, 250000000),
    	ITEM_67(25202, 250000000),
    	ITEM_68(24167, 350000000),
    	ITEM_69(21773, 6000),
    	ITEM_70(22482, 35000000),
    	ITEM_71(22486, 35000000),
    	ITEM_72(22490, 35000000),
    	ITEM_73(22494, 35000000),
    	ITEM_74(22458, 75000),
    	ITEM_75(22462, 75000),
    	ITEM_76(22466, 75000),
    	ITEM_77(21777, 60000000),
    	ITEM_78(8850, 5000000),
    	ITEM_79(8849, 2500000),
    	ITEM_80(10828, 2500000),
    	ITEM_81(8848, 100000),
    	ITEM_82(8847, 100000),
    	ITEM_83(8846, 100000),
    	ITEM_84(8845, 100000),
    	ITEM_85(8844, 100000),
    	ITEM_86(7459, 100000),
    	ITEM_87(22470, 100000),
    	ITEM_88(22474, 100000),
    	ITEM_89(22478, 100000),
    	ITEM_90(2412, 100000),
    	ITEM_91(2413, 100000),
    	ITEM_92(2414, 100000),
    	ITEM_93(21790, 20000000),
    	ITEM_94(23531, 80000),
    	ITEM_95(23621, 10000),
    	ITEM_96(23351, 10000),
    	ITEM_97(6685, 10000),
    	ITEM_98(6686, 10000),
    	ITEM_99(12196, 1),
    	ITEM_100(21512, 1),
    	ITEM_101(22992, 1),
    	ITEM_102(24511, 1),
    	ITEM_103(24512, 1),
    	ITEM_104(4722, 10000000),
    	ITEM_105(4720, 10000000),
    	ITEM_106(4718, 10000000),
    	ITEM_107(4716, 10000000),
    	ITEM_108(4753, 10000000),
    	ITEM_109(4755, 10000000),
    	ITEM_110(4757, 10000000),
    	ITEM_111(4759, 10000000),
    	ITEM_112(4724, 10000000),
    	ITEM_113(4726, 10000000),
    	ITEM_114(4728, 10000000),
    	ITEM_115(4730, 10000000),
    	ITEM_116(4745, 10000000),
    	ITEM_117(4747, 10000000),
    	ITEM_118(4749, 10000000),
    	ITEM_119(4751, 10000000),
    	ITEM_120(4714, 7500000),
    	ITEM_121(4710, 7500000),
    	ITEM_122(4708, 7500000),
    	ITEM_123(4736, 7500000),
    	ITEM_124(4738, 7500000),
    	ITEM_125(4732, 7500000),
    	ITEM_126(4734, 7500000),
    	ITEM_127(6914, 10000000),
    	ITEM_128(7462, 10000000),
    	ITEM_129(20072, 10000000),
    	ITEM_130(8839, 10000000),
    	ITEM_131(8840, 10000000),
    	ITEM_132(8842, 10000000),
    	ITEM_133(10611, 10000000),
    	ITEM_134(11663, 10000000),
    	ITEM_135(11664, 10000000),
    	ITEM_136(11665, 10000000),
    	ITEM_137(6746, 100000000),
    	ITEM_138(13734, 100000000),
    	ITEM_139(3481, 300000),
    	ITEM_140(3483, 300000),
    	ITEM_141(3485, 300000),
    	ITEM_142(3486, 300000),
    	ITEM_143(3488, 300000),
    	ITEM_144(11716, 80000000),
    	ITEM_145(6889, 5500000),
    	ITEM_146(3105, 75000),
    	ITEM_147(15126, 500000),
    	ITEM_148(3842, 1000000),
    	ITEM_149(3840, 1000000),
    	ITEM_150(7460, 1000000),
    	ITEM_151(9244, 7500),
    	ITEM_152(1050, 2147483647),
    	ITEM_153(11720, 200000000),
    	ITEM_154(11722, 200000000),
    	ITEM_155(11724, 250000000),
    	ITEM_156(11726, 250000000),
    	ITEM_157(10008, 15000),
    	ITEM_158(10006, 15000),
    	ITEM_159(2577, 80000000),
    	ITEM_160(2581, 80000000),
    	ITEM_161(11235, 30000000),
    	ITEM_162(15486, 6000000),
    	ITEM_163(15332, 50000),
    	ITEM_164(6918, 1750000),
    	ITEM_165(6920, 1000000),
    	ITEM_166(6916, 1500000),
    	ITEM_167(324, 250000),
    	ITEM_168(1386, 250000),
    	ITEM_169(6922, 1000000),
    	ITEM_170(6924, 1250000),
    	ITEM_171(11335, 75000000),
    	ITEM_172(14479, 65000000),
    	ITEM_173(3140, 5000000),
    	ITEM_174(11732, 10000000),
    	ITEM_175(4087, 2500000),
    	ITEM_176(4585, 2500000),
    	ITEM_177(1187, 550000),
    	ITEM_178(4151, 15000000),
    	ITEM_179(20671, 350000),
    	ITEM_180(21371, 65000000),
    	ITEM_181(11696, 300000000),
    	ITEM_182(11700, 400000000),
    	ITEM_183(11698, 500000000),
    	ITEM_184(13754, 500000000),
    	ITEM_185(11694, 600000000),
    	ITEM_186(14484, 500),
    	ITEM_187(23659, 440),
    	ITEM_188(18349, 1500),
    	ITEM_189(18351, 1500),
    	ITEM_190(18353, 1500),
    	ITEM_191(18355, 1500),
    	ITEM_192(3024, 15000),
    	ITEM_193(3025, 15000),
    	ITEM_194(4153, 3500000),
    	ITEM_195(18357, 1500),
    	ITEM_196(11690, 20000000),
    	ITEM_197(18359, 1500),
    	ITEM_198(19784, 2000),
    	ITEM_199(21787, 18000000),
    	ITEM_200(11730, 65000000),
    	ITEM_201(11702, 500000000),
    	ITEM_202(11708, 300000000),
    	ITEM_203(11704, 200000000),
    	ITEM_204(11706, 400000000),
    	ITEM_205(15017, 30000000),
    	ITEM_206(15020, 30000000),
    	ITEM_207(15220, 30000000),
    	ITEM_208(15018, 30000000),
    	ITEM_209(15019, 30000000),
    	ITEM_210(1609, 5000),
    	ITEM_211(1611, 6000),
    	ITEM_212(1613, 7000),
    	ITEM_213(1607, 8000),
    	ITEM_214(1605, 9000),
    	ITEM_215(1603, 10000),
    	ITEM_216(1601, 11000),
    	ITEM_217(1615, 12000),
    	ITEM_218(19780, 330000000),
    	ITEM_219(6585, 27000000),
    	ITEM_220(21793, 18000000),
    	ITEM_221(1662, 200000),
    	ITEM_222(7650, 150000),
    	ITEM_223(1635, 100000),
    	ITEM_224(1739, 60000),
    	ITEM_225(950, 40000);
    	
    	int itemid;
    	int buyPrice;
    	
    	PriceManager(int itemId, int price) {
    		this.itemid = itemId;
    		this.buyPrice = price;
    	}
    	
    	public int getId() {
    		return itemid;
    	}
    	public int getPrice() {
    		return buyPrice;
    	}
    	
    	public static int getBuyPrice(Item item) {
    		int itemId = item.getId();
    		for (PriceManager get : PriceManager.values()) {
    			if (itemId == get.itemid) {
    				return get.buyPrice;
    			}
    		}
    		return item.getDefinitions().getValue();
    	}
    	
    	public static int getSellPrice(Item item) {
    		return (int) (getBuyPrice(item) / 1.3);
    	}
    }
    when you click on any item it log out ur account?
    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.” ― Albert Einstein
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. PI all shop crash
    By sky skunk in forum Help
    Replies: 11
    Last Post: 08-01-2012, 01:11 PM
  2. All shops are empty
    By Blitzscape in forum Help
    Replies: 6
    Last Post: 01-05-2012, 11:43 PM
  3. shops lag
    By Cocaine in forum Help
    Replies: 2
    Last Post: 07-26-2011, 08:18 AM
  4. All Shop Frames : WORKING
    By peterbjornx in forum Snippets
    Replies: 71
    Last Post: 06-21-2009, 11:11 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •