1package com.runehive.game.world.items.containers.bank;
3import com.runehive.game.world.InterfaceConstants;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.entity.mob.player.PlayerRight;
6import com.runehive.game.world.items.Item;
7import com.runehive.game.world.items.ItemDefinition;
8import com.runehive.game.world.items.containers.ItemContainer;
9import com.runehive.game.world.items.containers.ItemContainerAdapter;
10import com.runehive.game.world.items.containers.pricechecker.PriceType;
11import com.runehive.net.packet.out.*;
12import com.runehive.util.Utility;
13import plugin.itemon.item.LootingBagPlugin;
15import java.util.Arrays;
16import java.util.Optional;
27 public static final int SIZE = 360;
51 this.placeHolder =
false;
61 if (
player.bankPin.hasPin() && !
player.bankPin.entered) {
67 player.attributes.set(
"BANK_KEY", Boolean.TRUE);
82 player.inventory.refresh();
97 if (item ==
null)
continue;
99 if (value >= Long.MAX_VALUE - price * item.
getAmount()) {
100 value = Long.MAX_VALUE;
109 player.attributes.set(
"BANK_KEY", Boolean.FALSE);
112 player.playerAssistant.setValueIcon();
129 boolean withinBank =
player.interfaceManager.isInterfaceOpen(60000) ||
player.interfaceManager.isInterfaceOpen(4465);
131 System.out.println(
"interface: " +
player.interfaceManager.getMain());
139 int id = item.
getId();
141 if (LootingBagPlugin.isLootingBag(item) && !
player.lootingBag.isEmpty()) {
142 player.interfaceManager.openInventory(60000, 26700);
146 int invAmount =
player.inventory.computeAmountForId(
id);
148 if (invAmount < amount) {
159 player.message(
"Your bank is full! You need to clear some items from your bank.");
168 swap(
true, from, to,
false);
171 if (Integer.MAX_VALUE - fucking.
getAmount() < amount) {
172 amount = Integer.MAX_VALUE - fucking.
getAmount();
173 player.send(
new SendMessage(
"Your bank didn't have enough space to deposit all that!"));
179 if(item.
getId() == 12791)
player.runePouch.clearInterface();
189 if (!
player.interfaceManager.isInterfaceOpen(60000)) {
193 if (itemId < 0)
return;
196 if (item ==
null || itemId != item.
getId())
216 int id = item.
getId();
226 if (!
new Item(
id).isStackable() && amount >
player.inventory.getFreeSlots()) {
227 amount =
player.inventory.getFreeSlots();
229 if (!
player.inventory.contains(
id)) {
231 }
else if (
player.inventory.computeAmountForId(
id) + amount > Integer.MAX_VALUE) {
232 amount = Integer.MAX_VALUE -
player.inventory.computeAmountForId(
id);
237 player.send(
new SendMessage(
"You do not have enough inventory spaces to withdraw this item."));
241 int fuckingSlot =
player.inventory.computeIndexForId(
id);
242 if (fuckingSlot != -1) {
243 Item fuckingStan =
player.inventory.get(fuckingSlot);
244 if (Integer.MAX_VALUE - fuckingStan.
getAmount() < amount) {
245 amount = Integer.MAX_VALUE - fuckingStan.
getAmount();
246 player.send(
new SendMessage(
"Your inventory didn't have enough space to withdraw all that!"));
251 if (
remove(item.
getId(), amount)) {
252 player.inventory.add(
id, amount);
253 if(
id == 12791)
player.runePouch.refresh();
270 public void collapse(
int tab,
boolean collapseAll) {
271 if (!
player.interfaceManager.isInterfaceOpen(60000)) {
274 if (tab == 0 && collapseAll) {
283 if (tabAmount > 0)
moveTab(tab, 0);
304 for (
int i = 0; i < tabAmount; i++) {
305 swap(
true, fromSlot, toSlot,
false);
340 swap(
true, from, to,
false);
355 while (tab > 0 &&
tabAmounts[tab - 1] <= 0) tab--;
357 for (
int index = 0; index <
items.length; index++) {
358 if (
items[index] ==
null)
continue;
361 if(item.
getId() == 12791)
player.runePouch.clearInterface();
363 player.inventory.remove(item, index,
false);
374 while (tab > 0 &&
tabAmounts[tab - 1] <= 0) tab--;
376 for (
int index = 0; index <
items.length; index++) {
377 if (
items[index] ==
null)
continue;
381 player.equipment.remove(item, index,
false);
394 if (fromTab == toTab)
return;
429 public void moveItem(
int opcode,
int from,
int to) {
432 }
else if (opcode == 1) {
433 swap(
true, from, to,
false);
436 if (fromTab != toTab) {
450 for (
int tab = 0; tab <
tabAmounts.length; tab++) {
460 for (
int index = tab; index >= 0; index--) {
476 amounts = Arrays.copyOf(amounts, amounts.length);
477 System.arraycopy(amounts, 0,
tabAmounts, 0, amounts.length);
498 return "Your bank is currently full!";
The class that contains helpful information on interfaces.
static final int WITHDRAW_BANK
static final int INVENTORY_STORE
This class represents a character controlled by a player.
Represents all of an in-game Item's attributes.
static ItemDefinition get(int id)
Gets an item definition.
The container class that represents an item that can be interacted with.
final void setAmount(int amount)
Sets the quantity of this item.
final int getId()
Gets the identification of this item.
final int getAmount()
Gets the quantity of this item.
Item copy()
A substitute for Object#clone() that creates another 'copy' of this instance.
int getValue(PriceType type)
Gets the value for this item.
final void incrementAmountBy(int amount)
Increments the amount by amount.
ItemContainerAdapter(Player player)
Creates a new ItemContainerAdapter.
final Player player
The Player instance.
ItemContainer(int capacity, StackPolicy policy, Item[] items)
Creates a new ItemContainer.
void setFiringEvents(boolean firingEvents)
Sets the value for firingEvents.
Item[] items
The Items within this container.
boolean add(Item item)
Attempts to deposit item into this container.
final int capacity
The capacity of this container.
final int computeIndexForId(int id)
Computes the first index found that id is in.
final boolean addListener(ItemContainerListener listener)
Adds an ItemContainerListener to this container.
boolean contains(int id)
Determines if this container contains id.
final Item[] toArray()
Returns a shallow copy of the backing array.
final void swap(int oldIndex, int newIndex)
Swaps the Items on oldIndex and newIndex.
String getCapacityExceededMsg()
void bulkItemsUpdated(ItemContainer container)
Fired when an Items are added, removed, or replaced in bulk.
void itemUpdated(ItemContainer container, Optional< Item > oldItem, Optional< Item > newItem, int index, boolean refresh, boolean login)
Fired when an Item is added, removed, or replaced.
void collapse(int tab, boolean collapseAll)
Collapses a tab and shifts other tabs one slot to the left.
int depositFromNothing(Item item, int tab)
static final int SIZE
The size of all equipment instances.
void depositeEquipment(boolean message)
Handles depositing all the equipment.
boolean placeHolder
The place holder flag.
int[] tabAmounts
The tab amount array.
void itemToTab(int slot, int toTab)
void depositeInventory(boolean message)
Handles depositing the entire inventory.
void moveItem(int opcode, int from, int to)
Moves an item within the bank.
void open()
Opens the bank itemcontainer.
void close()
Closes the bank itemcontainer.
void recursiveCollapse(int tab)
final Player player
The player instance.
int bankTab
The current bank tab.
Bank(Player player)
Constructs a new Bank.
void clear()
Removes all of the items from this container.
void moveTab(int tab, int toTab)
boolean inserting
The inserting flag.
void withdraw(int itemId, int slot, int amount)
Withdraws item from bank.
boolean noting
The noting flag.
void changeTabAmount(int tab, int amount)
Changes the amount of items stored in a tab.
void refresh()
Refreshes the bank itemcontainer.
void deposit(int slot, int amount)
Deposits item into bank.
void shift()
Percolates the null indices to the end of the stack.
void placeHolder(int item, int slot)
Handles the place holder option for the contianer.
The OutgoingPacket responsible for changing settings on a client.
The OutgoingPacket that sends a message to a Players chatbox in the client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
static String formatPrice(final long amount)
Formats a price for longs.
Holds all the player right data.
An enumerated type defining policies for stackable Items.
ALWAYS
The ALWAYS policy, items are always stacked regardless of their ItemDefinition table.
VALUE
The value price type.