1package com.osroyale.game.world.items.containers.bank;
3import com.osroyale.game.world.InterfaceConstants;
4import com.osroyale.game.world.entity.mob.player.Player;
5import com.osroyale.game.world.entity.mob.player.PlayerRight;
6import com.osroyale.game.world.items.Item;
7import com.osroyale.game.world.items.containers.ItemContainer;
8import com.osroyale.net.packet.out.SendItemOnInterface;
9import com.osroyale.net.packet.out.SendMessage;
10import com.osroyale.net.packet.out.SendString;
12import java.util.Arrays;
13import java.util.Objects;
59 private static final int DONATOR_DEPOSIT_BOX_DISPLAY_ID = 57207;
62 private final Player player;
75 player.dialogueFactory.sendStatement(
"You need to be a donator to use this feature!",
"The donator deposit allows donators to deposit a certain amount",
"of items into their banks every 2 minutes.").execute();
79 player.attributes.set(
"DONATOR_DEPOSIT_KEY", Boolean.TRUE);
80 player.interfaceManager.openInventory(57200, 5063);
89 player.inventory.add(item);
93 player.attributes.set(
"DONATOR_DEPOSIT_KEY", Boolean.FALSE);
98 if (!player.interfaceManager.isInterfaceOpen(57200)) {
102 player.send(
new SendMessage(
"There are no items to deposit!"));
105 if (player.bank.getFreeSlots() <
this.size()) {
106 player.message(
"You do not have enough space in your bank to deposit these items.");
110 player.send(
new SendMessage(
"You have deposited " + this.
size() +
" items into your bank."));
112 Arrays.stream(this.
getItems()).filter(Objects::nonNull).forEach(item -> {
113 if(player.bank.depositFromNothing(item, 0) > 0) {
114 remove(item, -1,
false);
123 public boolean deposit(
int id,
int slot,
int amount) {
124 if (!player.interfaceManager.isInterfaceOpen(57200)) {
128 Item item = player.inventory.get(slot);
130 if (item ==
null || item.getId() !=
id) {
133 int contain = player.inventory.computeAmountForId(
id);
135 if (contain < amount) {
140 if (
size() >= allowedSize) {
141 player.dialogueFactory.sendStatement(
"You can only deposit up to " + allowedSize +
" items.",
"The higher your donator rank the more spaces unlocked!").execute();
145 if(!
add(item.getId(), amount)) {
149 Item current =
new Item(item.getId(), amount);
151 if (item.isStackable() || amount == 1) {
152 player.inventory.remove(current, slot,
false);
154 player.inventory.remove(current, -1,
false);
163 public boolean withdraw(
int id,
int slot,
int amount) {
164 if (!player.interfaceManager.isInterfaceOpen(57200)) {
168 Item item =
get(slot);
170 if (item ==
null || item.getId() !=
id) {
176 if (contain < amount) {
180 Item current =
new Item(
id, amount);
182 if(!player.inventory.add(current)) {
186 if (item.isStackable() || amount == 1) {
187 remove(current, slot,
false);
189 remove(current, slot,
false);
198 private void refresh() {
199 refresh(player, DONATOR_DEPOSIT_BOX_DISPLAY_ID);
204 player.inventory.refresh();
ItemContainer(int capacity, StackPolicy policy, Item[] items)
final int computeAmountForId(int id)
boolean withdraw(int id, int slot, int amount)
boolean deposit(int id, int slot, int amount)
DonatorDeposit(Player player)
static boolean isDonator(Player player)
static int getDepositAmount(Player player)