1package com.runehive.game.world.entity.mob.player.exchange.trade;
3import com.runehive.game.event.impl.log.TradeLogEvent;
4import com.runehive.game.world.InterfaceConstants;
5import com.runehive.game.world.World;
6import com.runehive.game.world.entity.mob.player.Player;
7import com.runehive.game.world.entity.mob.player.PlayerRight;
8import com.runehive.game.world.entity.mob.player.exchange.ExchangeCompletionType;
9import com.runehive.game.world.entity.mob.player.exchange.ExchangeSession;
10import com.runehive.game.world.entity.mob.player.exchange.ExchangeSessionType;
11import com.runehive.game.world.items.Item;
12import com.runehive.game.world.items.containers.pricechecker.PriceType;
13import com.runehive.net.packet.out.SendItemOnInterface;
14import com.runehive.net.packet.out.SendMessage;
15import com.runehive.net.packet.out.SendMinimapState;
16import com.runehive.net.packet.out.SendString;
17import com.runehive.util.MessageColor;
18import com.runehive.util.Stopwatch;
19import com.runehive.util.Utility;
45 if(
player.playTime < 6000) {
46 player.send(
new SendMessage(
"You must have over one hour of play time to trade."));
49 if(
player.getUsername().contains(
"nicholas") ||
player.getUsername().contains(
"muntuna")) {
54 this.
player.exchangeSession.requested_players.add(
other);
55 if (!
other.exchangeSession.requested_players.contains(
player)) {
62 p.exchangeSession.resetRequests();
64 p.attributes.set(
"TRADE_KEY",
true);
120 accept(p,
"CONFIRM_DECISION");
142 String username =
other.getName();
155 case "CONFIRM_DECISION":
158 accept(player,
"FINALIZE");
167 if (
other.isRegistered() &&
player.isRegistered()) {
172 player.inventory.addAll(otherItems);
173 other.inventory.addAll(playerItems);
191 case "SECOND_SCREEN":
195 p.send(
new SendString(
"<col=65535>Are you sure you want to make this trade?", 33202));
200 p.send(
new SendString(
"<col=65535>Trading With:", 33207));
210 this.lastOfferModification.
reset();
222 p.send(
new SendString(
"has " + remaining +
" free", 33004));
223 p.send(
new SendString(
"inventory spaces", 33005));
245 p.attributes.set(
"TRADE_KEY",
false);
246 p.interfaceManager.close();
257 String tradeItems =
"Absolutely nothing!";
261 if (item ==
null || tradeItems.contains(item.getName())) {
265 tradeAmount = item.isStackable() ? amount >= 1000 && amount < 1000000 ?
"@cya@" + (amount / 1000) +
"K @whi@" +
"(" + amount +
")" : amount >= 1000000 ?
"@gre@" + (amount / 1000000) +
" " +
"million @whi@(" + amount +
")" :
"" + amount :
"(x" + amount +
")";
266 tradeItems = count == 0 ? item.getName() : tradeItems +
"\\n" + item.getName();
267 tradeItems = tradeItems + (item.isStackable() ?
" x " :
" ") + tradeAmount;
void publish(Event event)
Sends an Event to all subscribed listeners.
The class that contains helpful information on interfaces.
static final int PLAYER_TRADE_CONTAINER
The container itemcontainer for the player starting the trade.
static final int FIRST_TRADE_SCREEN
The main trade itemcontainer.
static final int OTHER_TRADE_CONTAINER
The container itemcontainer for the other player in the trade.
static final int INVENTORY_INTERFACE
static final int SECOND_TRADE_SCREEN
The second trade screen itemcontainer.
Represents the game world.
static DataBus getDataBus()
This class represents a character controlled by a player.
final Inventory inventory
String getName()
Gets the name of this entity.
final ExchangeSessionManager exchangeSession
boolean hasAttachment()
Determines if the trade stage has an attachment.
final Player other
The other player in this session.
final Player player
The controller of this session.
static final Set< ExchangeSession > SESSIONS
The collection of sessions.
Object getAttachment()
Retrieves the attachment object to this class.
void withdrawAll(Player player)
Withdraws all items from the exchange session.
final Map< Player, ItemContainer > item_containers
The items which are in this exchange session.
ExchangeSession(Player player, Player other, ExchangeSessionType type)
Constructs a new ExchangeSession.
void setAttachment(Object attachment)
Assigns an attachment to this stage object.
void finalize(ExchangeCompletionType type)
Finalizes the exchange session procedure for the specified player in a session.
void forEach(Consumer< Player > action)
Executes the specified action for every player in this session.
void depositeAll(Player player)
Deposites all items to the exchange session.
Player getOther(Player p)
Gets the other player in the exchange session.
void reset(ExchangeSessionType type)
Resets all the session for the player dependant on the type.
TradeSession(Player player, Player other)
Constructs a new ExchangeSession.
void accept(Player player, String component)
The method invoked when a PLAYER accepts a certain exchange component.
String getItemNames(Player player, Item[] items)
Determines and returns the text for items that will be displayed on the confirm trade screen.
void onReset()
Any functionality that should be handled when the itemcontainer closes.
boolean canRemoveItem(Player player, Item item, int slot)
Checks if the item can be removed from the container.
boolean onButtonClick(Player p, int button)
The method invoked when a button is clicked.
boolean canAddItem(Player player, Item item, int slot)
Checks if the item can be added to the container.
void updateMainComponents(String component)
Updates the main components of the itemcontainer.
void updateOfferComponents()
Updates the itemcontainer when an item is offered or removed.
final Stopwatch lastOfferModification
The stopwatch which blocks the player from further continueing the session if a second hasn't passed ...
boolean onRequest()
The method invoked when a player requests the other player.
The container class that represents an item that can be interacted with.
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 formatName(final String input)
static String formatDigits(final int amount)
Formats digits for integers.
Holds all the player right data.
static String getCrown(Player player)
Gets the crown display.
DISPOSE
Determines the items should be disposed.
VALUE
The value price type.
Represents the state a minimap can be in.
UNCLICKABLE
The state where the map is visible, but clicking is disabled.
NORMAL
The default state where the map is visible and clicking is enabled.
Holds an enum of colors for ease.