1package com.runehive.content.store.impl;
4import com.runehive.content.store.*;
5import com.runehive.content.store.currency.CurrencyType;
6import com.runehive.game.world.entity.mob.player.Player;
7import com.runehive.game.world.items.Item;
8import com.runehive.game.world.items.containers.ItemContainer;
9import com.runehive.net.packet.out.SendItemOnInterface;
10import com.runehive.net.packet.out.SendScrollbar;
11import com.runehive.net.packet.out.SendString;
13import java.util.Arrays;
14import java.util.Objects;
15import java.util.Optional;
16import java.util.OptionalInt;
41 Arrays.stream(
items).filter(Objects::nonNull).forEach(item ->
itemCache.put(item.getId(), item.getAmount()));
53 int amount = action == 2 ? 1 : action == 3 ? 10 : action == 4 ? 100 : -100;
55 throw new IllegalArgumentException(
"The action given was invalid. [ACTION=" + action +
"]");
85 for (
int index = 0; index < unlocked; index++) {
88 storeItems[index] =
items[index];
91 for (
int i = 0; i < unlocked; i++) {
98 final int scrollBarSize = lastItem <= 32 ? 0 : (lastItem / 8) * 72;
Class to execute all constants for Shops.
static final int INTERFACE_ID
The identification for the shop itemcontainer.
void sendPurchaseValue(Player player, int slot)
final String name
The name of this shop.
Store(String name, ItemContainer.StackPolicy policy, CurrencyType currencyType, int capacity)
final Set< Player > players
The set of players that are currently viewing this shop.
Map< Integer, Integer > itemCache
The map of cached shop item identifications and their amounts.
static Map< String, Store > STORES
A mapping of each shop by it's name.
final CurrencyType currencyType
The currency for this shop.
ItemContainer container
The current item container which contains the current items from this shop.
boolean purchase(Player player, Item item, int slot)
A simple wrapper class which holds extra attributes for the item object.
void refresh(Player player)
void close(Player player)
void itemContainerAction(Player player, int id, int slot, int action, boolean purchase)
final GenericAttributes attributes
void openInventory(int identification, int overlay)
Opens an inventory interface for the player.
This class represents a character controlled by a player.
final Inventory inventory
final InterfaceManager interfaceManager
void send(OutgoingPacket encoder)
The container class that represents an item that can be interacted with.
An abstraction game representing a group of Items.
final Item[] toArray()
Returns a shallow copy of the backing array.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
public< K > void remove(K key)
Removes a generic attribute.
public< K, E > void set(K key, E attribute)
Sets a generic attribute.
Represents ways items can be sold in a shop.
NONE
No items can be sold in the shop.
The enumerated type whose elements represent constants that are used to differ between shops.
DEFAULT
The default shop which is commonly owned by the server.
The enumerated type whom holds all the currencies usable for a server.
static String getValue(Player player, CurrencyType currency)
An enumerated type defining policies for stackable Items.
ALWAYS
The ALWAYS policy, items are always stacked regardless of their ItemDefinition table.