1package com.osroyale.game.world.entity.mob.player.exchange.trade;
3import com.osroyale.game.event.impl.log.TradeLogEvent;
4import com.osroyale.game.world.InterfaceConstants;
5import com.osroyale.game.world.World;
6import com.osroyale.game.world.entity.mob.player.Player;
7import com.osroyale.game.world.entity.mob.player.PlayerRight;
8import com.osroyale.game.world.entity.mob.player.exchange.ExchangeCompletionType;
9import com.osroyale.game.world.entity.mob.player.exchange.ExchangeSession;
10import com.osroyale.game.world.entity.mob.player.exchange.ExchangeSessionType;
11import com.osroyale.game.world.items.Item;
12import com.osroyale.game.world.items.containers.pricechecker.PriceType;
13import com.osroyale.net.packet.out.SendItemOnInterface;
14import com.osroyale.net.packet.out.SendMessage;
15import com.osroyale.net.packet.out.SendMinimapState;
16import com.osroyale.net.packet.out.SendString;
17import com.osroyale.util.MessageColor;
18import com.osroyale.util.Stopwatch;
19import com.osroyale.util.Utility;
80 if(
player.playTime < 6000) {
81 player.send(
new SendMessage(
"You must have over one hour of play time to trade."));
84 if(
player.getUsername().contains(
"nicholas") ||
player.getUsername().contains(
"muntuna")) {
89 this.
player.exchangeSession.requested_players.add(
other);
90 if (!
other.exchangeSession.requested_players.contains(
player)) {
97 p.exchangeSession.resetRequests();
99 p.attributes.set(
"TRADE_KEY",
true);
155 accept(p,
"CONFIRM_DECISION");
167 if (!lastOfferModification.elapsed(1_000)) {
177 String username =
other.getName();
190 case "CONFIRM_DECISION":
193 accept(player,
"FINALIZE");
202 if (
other.isRegistered() &&
player.isRegistered()) {
207 player.inventory.addAll(otherItems);
208 other.inventory.addAll(playerItems);
226 case "SECOND_SCREEN":
230 p.send(
new SendString(
"<col=65535>Are you sure you want to make this trade?", 33202));
235 p.send(
new SendString(
"<col=65535>Trading With:", 33207));
245 this.lastOfferModification.reset();
249 int remaining = recipient.inventory.
remaining();
257 p.send(
new SendString(
"has " + remaining +
" free", 33004));
258 p.send(
new SendString(
"inventory spaces", 33005));
280 p.attributes.set(
"TRADE_KEY",
false);
281 p.interfaceManager.close();
291 private String getItemNames(
Player player, Item[] items) {
292 String tradeItems =
"Absolutely nothing!";
295 for (Item item : items) {
296 if (item ==
null || tradeItems.contains(item.getName())) {
299 int amount = this.
item_containers.get(player).computeAmountForId(item.getId());
300 tradeAmount = item.isStackable() ? amount >= 1000 && amount < 1000000 ?
"@cya@" + (amount / 1000) +
"K @whi@" +
"(" + amount +
")" : amount >= 1000000 ?
"@gre@" + (amount / 1000000) +
" " +
"million @whi@(" + amount +
")" :
"" + amount :
"(x" + amount +
")";
301 tradeItems = count == 0 ? item.getName() : tradeItems +
"\\n" + item.getName();
302 tradeItems = tradeItems + (item.isStackable() ?
" x " :
" ") + tradeAmount;
void publish(Event event)
static final int FIRST_TRADE_SCREEN
static final int OTHER_TRADE_CONTAINER
static final int PLAYER_TRADE_CONTAINER
static final int SECOND_TRADE_SCREEN
final Map< Player, ItemContainer > item_containers
ExchangeSession(Player player, Player other, ExchangeSessionType type)
static final Set< ExchangeSession > SESSIONS
void depositeAll(Player player)
Player getOther(Player p)
void finalize(ExchangeCompletionType type)
void forEach(Consumer< Player > action)
void withdrawAll(Player player)
void setAttachment(Object attachment)
void reset(ExchangeSessionType type)
boolean onButtonClick(Player p, int button)
void updateOfferComponents()
boolean canRemoveItem(Player player, Item item, int slot)
TradeSession(Player player, Player other)
boolean canAddItem(Player player, Item item, int slot)
void updateMainComponents(String component)
void accept(Player player, String component)
static String formatDigits(final int amount)
static String getCrown(Player player)