Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void sendBuy(Player player, int itemId, int amount) {
- Integer TYPE = (Integer) player.getTemporaryAttributtes().get("CUSTOM_STORE_TYPE");
- int price = -1;
- int points = -1;
- if (TYPE != null) {
- switch (TYPE) {
- case PKP:
- for (int i = 0; i < PKPointsData.ITEMS.length; i++)
- if (itemId == PKPointsData.ITEMS[i][0]) {
- price = PKPointsData.ITEMS[i][2];
- points = player.getPKP();
- if (amount * price > points) {
- amount = points / price;
- price = price * amount;
- System.out.println("New amount: " + amount);
- System.out.println("New price: " + price);
- } else
- price = price * amount;
- if (price > points || amount < 1) {
- player.getPackets().sendGameMessage("You don't have enough points to buy this.");
- return;
- }
- ItemDefinitions defs = ItemDefinitions.getItemDefinitions(itemId);
- if (defs.canBeNoted() && !defs.isStackable())
- itemId = amount > 1 ? defs.getCertId() : itemId;
- defs = ItemDefinitions.getItemDefinitions(itemId);
- if (!player.getInventory().hasFreeSlots() && !defs.isStackable()
- || (!player.getInventory().hasFreeSlots() && defs.isStackable() && !player.getInventory().containsOneItem(itemId))) {
- player.sm("You don't have enough inventory space to buy this.");
- return;
- }
- player.addItem(itemId, amount);
- player.setPKP(player.getPKP() - (price));
- player.sm("You bought " + amount + " x "
- + defs.getName() + " for "
- + price + " pk points.");
- player.closeInterfaces();
- sendInterface(player, TYPE);
- }
- break;
- }
- } else
- player.sm("NULL");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement