RuneHive-Game
Loading...
Searching...
No Matches
LostUntradeables.java
Go to the documentation of this file.
1package com.runehive.game.world.items.containers.impl;
2
3import com.runehive.game.world.InterfaceConstants;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.items.Item;
6import com.runehive.game.world.items.containers.ItemContainer;
7import com.runehive.game.world.items.containers.pricechecker.PriceChecker;
8import com.runehive.net.packet.out.SendItemOnInterface;
9import com.runehive.net.packet.out.SendMessage;
10import com.runehive.net.packet.out.SendString;
11
12/**
13 * Handles the donator deposit box.
14 *
15 * @author DanielDonatorDeposit
16 */
17public class LostUntradeables extends ItemContainer {
18 private static final int DONATOR_DEPOSIT_BOX_DISPLAY_ID = 57307;
19
20 private final Player player;
21
23 super(30, StackPolicy.ALWAYS);
24 this.player = player;
25 }
26
27 public void open() {
28 refresh();
29 player.interfaceManager.open(57300);
30 }
31
32 public void close() {
33 clear(false);
34 refresh();
35 }
36
37 public boolean deposit(Item item) {
38 int id = item.getId();
39 setFiringEvents(false);
40 add(id, item.getAmount());
41 setFiringEvents(true);
42 refresh();
43 return true;
44 }
45
46 public boolean claim(int slot, int id) {
47 if (!player.interfaceManager.isInterfaceOpen(57300)) {
48 return false;
49 }
50
51 Item item = get(slot);
52
53 if (item == null || item.getId() != id) {
54 return false;
55 }
56
57 if (player.inventory.getFreeSlots() == 0) {
58 player.message("You do not have enough free inventory space!");
59 return false;
60 }
61
62 if (!player.inventory.contains(13307, 350)) {
63 player.message("You need 350 blood money to re-claim this item!");
64 return false;
65 }
66
67 if (remove(item.getId(), 1)) {
68 player.inventory.add(id, 1);
69 player.inventory.remove(13307, 350);
70 shift();
71 refresh();
72 }
73 return true;
74 }
75
79
80 @Override
81 public void onRefresh() {
82 player.inventory.refresh();
83 player.send(new SendString(this.size() + "/" + this.capacity(), 57306));
85 }
86}
This class represents a character controlled by a player.
Definition Player.java:125
The container class that represents an item that can be interacted with.
Definition Item.java:21
final int getId()
Gets the identification of this item.
Definition Item.java:324
final int getAmount()
Gets the quantity of this item.
Definition Item.java:342
ItemContainer(int capacity, StackPolicy policy, Item[] items)
Creates a new ItemContainer.
void setFiringEvents(boolean firingEvents)
Sets the value for firingEvents.
boolean add(Item item)
Attempts to deposit item into this container.
final int capacity
The capacity of this container.
void shift()
Percolates the null indices to the end of the stack.
void clear()
Removes all of the items from this container.
void onRefresh()
Any functionality that should occur when refreshed.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
An enumerated type defining policies for stackable Items.
ALWAYS
The ALWAYS policy, items are always stacked regardless of their ItemDefinition table.