1package com.runehive.game.world.items.containers.pricechecker;
3import com.runehive.game.world.InterfaceConstants;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.items.Item;
6import com.runehive.game.world.items.ItemDefinition;
7import com.runehive.game.world.items.containers.ItemContainer;
8import com.runehive.game.world.items.containers.ItemContainerAdapter;
9import com.runehive.net.packet.out.*;
10import com.runehive.util.Utility;
12import java.text.NumberFormat;
13import java.util.Optional;
23 private final int[]
STRINGS = {48550, 48551, 48552, 48553, 48554, 48555, 48556, 48557, 48558, 48559, 48560, 48561, 48562, 48563, 48564, 48565, 48566, 48567, 48568, 48569, 48570, 48571, 48572, 48573, 48574, 48575, 48576, 48577,};
51 player.attributes.set(
"PRICE_CHECKER_KEY",
true);
52 player.interfaceManager.openInventory(48500, 5063);
59 player.attributes.set(
"PRICE_CHECKER_KEY",
false);
67 if (definition ==
null)
69 String searched = definition.
getName().toLowerCase().replace(
"'",
"");
70 if (!searched.contains(name.toLowerCase()))
77 player.dialogueFactory.sendStatement(
"There were no results found for",
"<col=255>" + name).execute();
97 if (item !=
null && (item.
getName().equalsIgnoreCase(name) && !item.
isNoted())) {
103 if (searched ==
null) {
104 player.send(
new SendMessage(
"There was no item found under the name of " + name +
"."));
124 int id = item.
getId();
126 int invAmount =
player.inventory.computeAmountForId(
id);
128 if (invAmount < amount) {
142 if (itemId < 0)
return;
145 if (item ==
null || itemId != item.
getId()) {
155 int id = item.
getId();
157 if (!
new Item(
id).isStackable() && amount >
player.inventory.getFreeSlots()) {
158 amount =
player.inventory.getFreeSlots();
161 int fuckingSlot =
player.inventory.computeIndexForId(
id);
162 if (fuckingSlot != -1) {
163 Item fuckingStan =
player.inventory.get(fuckingSlot);
164 if (Integer.MAX_VALUE - fuckingStan.
getAmount() < amount) {
165 amount = Integer.MAX_VALUE - fuckingStan.
getAmount();
166 player.send(
new SendMessage(
"Your inventory didn't have enough space to withdraw all that!"));
171 if (
remove(item.
getId(), amount)) {
172 player.inventory.add(
id, amount);
198 if (this.
remove(item)) {
199 player.inventory.add(item, -1,
false);
212 for (
int index = 0; index <
STRINGS.length; index++) {
225 player.inventory.refresh();
249 return "Your price checker is currently full!";
The class that contains helpful information on interfaces.
static final int INVENTORY_STORE
This class represents a character controlled by a player.
Represents all of an in-game Item's attributes.
boolean isNoted()
Gets the item note state.
int getId()
Gets the item id.
String getName()
Gets the item name.
static ItemDefinition[] DEFINITIONS
An array of item definitions.
The container class that represents an item that can be interacted with.
final int getId()
Gets the identification of this item.
final int getAmount()
Gets the quantity of this item.
int getValue(PriceType type)
Gets the value for this item.
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.
final int computeAmountForId(int id)
Computes the total quantity of the Items in this container with id.
Item[] items
The Items within this container.
boolean add(Item item)
Attempts to deposit item into 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.
void shift()
Percolates the null indices to the end of the stack.
long containerValue(PriceType type)
Gets the total worth of the container using the item's values.
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.
PriceType priceType
The price type.
static final int PRICE_CHECKER_DISPLAY_ID
The price checker display widget identifier.
PriceChecker(Player player)
Creates a new PriceChecker.
void open()
Opens the price checker interface.
void withdrawAll()
Withdraw all the items from the price checker.
void depositAll()
Deposits all the items into the price checker.
void onRefresh()
Any functionality that should occur when refreshed.
void deposit(int slot, int amount)
Deposits an item into the price checker.
void withdraw(int itemId, int amount)
Withdraws an item from the price checker.
void searchItem(String name)
Searches for an item.
void search(String name)
Searches for an item.
Player player
The player instance.
Item searchedItem
The item being searched.
void close()
Closes the price checker interface.
void setValue(PriceType type)
Sets the calculating value of the price checker.
final int[] STRINGS
Holds all the string identifications.
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 formatDigits(final int amount)
Formats digits for integers.
An enumerated type defining policies for stackable Items.
STANDARD
The STANDARD policy, items are only stacked if they are defined as stackable in their ItemDefinition ...
HIGH_ALCH_VALUE
The high alchemy price type.
VALUE
The value price type.