1package com.osroyale.game.world.items.containers.impl;
3import com.osroyale.Config;
4import com.osroyale.game.world.InterfaceConstants;
5import com.osroyale.game.world.entity.mob.player.Player;
6import com.osroyale.game.world.items.Item;
7import com.osroyale.game.world.items.containers.ItemContainer;
8import com.osroyale.game.world.items.containers.ItemContainerAdapter;
9import com.osroyale.game.world.items.containers.pricechecker.PriceType;
10import com.osroyale.game.world.position.Area;
11import com.osroyale.net.packet.out.*;
12import com.osroyale.util.Utility;
13import plugin.itemon.item.LootingBagPlugin;
62 private final Player player;
75 player.interfaceManager.setSidebar(
Config.INVENTORY_TAB, 26700);
83 if (player.attributes.get(
"BANK_KEY", Boolean.class)) {
87 player.interfaceManager.setSidebar(
Config.INVENTORY_TAB, 3213);
93 private boolean allowed(Item item) {
94 if (!
Area.inWilderness(player)) {
95 player.send(
new SendMessage(
"You can't put items in the bag unless you're in the Wilderness."));
98 if (!item.isTradeable()) {
99 player.send(
new SendMessage(
"You can't deposit un-tradeable items into the looting bag."));
102 if (!player.inventory.
contains(item)) {
103 player.send(
new SendMessage(
"You can not deposit an item that you do not have!"));
109 public Item[] getDeathItems() {
110 if (!player.inventory.
contains(LootingBagPlugin.OPENED_ID) && !player.inventory.
contains(LootingBagPlugin.CLOSED_ID)) {
113 return toNonNullArray();
120 player.dialogueFactory.sendOption(
121 "Deposit 1", () ->
deposit(item, 1),
122 "Deposit 5", () ->
deposit(item, 5),
123 "Deposit All", () ->
deposit(item, item.getAmount()),
125 player.dialogueFactory.onAction(() -> player.send(
new SendInputMessage(
"Enter the amount you would like to deposit into the looting bag:", 12, input -> {
126 player.dialogueFactory.clear();
127 deposit(item, Integer.parseInt(input));
134 public boolean deposit(Item item,
int amount) {
135 if (!allowed(item)) {
138 int contain = player.inventory.computeAmountForId(item.getId());
139 if (contain < amount) {
142 Item current =
new Item(item.getId(), amount);
146 player.inventory.remove(current);
147 player.send(
new SendMessage(
"You have deposited " + amount +
" " + current.getName() +
" into the looting bag."));
157 if (item.getAmount() > amount) {
158 item = item.createWithAmount(amount);
161 if (item.isStackable()) {
162 removed = player.bank.depositFromNothing(item, player.bank.bankTab);
164 while (removed < item.getAmount()) {
165 int deposited = player.bank.depositFromNothing(item, player.bank.bankTab);
166 if (deposited == 0) {
169 removed += deposited;
173 remove(item.createWithAmount(removed), slot,
false);
175 player.bank.refresh();
190 LootingBagListener(
Player player) {
201 return "You do not have enough space in your looting bag.";
abstract String getCapacityExceededMsg()
abstract int getWidgetId()
ItemContainer(int capacity, StackPolicy policy, Item[] items)
long containerValue(PriceType type)
final int computeAmountForId(int id)
final boolean addListener(ItemContainerListener listener)
void depositMenu(Item item)
boolean deposit(Item item, int amount)
LootingBag(Player player)
void withdrawBank(Item item, int slot)
static String formatDigits(final int amount)