Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit.inventory;
2
3import org.bukkit.Material;
4
5import java.util.HashMap;
6
7/**
8 * Interface to the various inventories
9 */
10public interface Inventory {
11
12 /**
13 * Returns the size of the inventory
14 *
15 * @return The inventory size
16 */
17 public int getSize();
18
19 /**
20 * Return the name of the inventory
21 *
22 * @return The inventory name
23 */
24 public String getName();
25
26 /**
27 * Get the ItemStack found in the slot at the given index
28 *
29 * @param index The index of the Slot's ItemStack to return
30 * @return The ItemStack in the slot
31 */
32 public ItemStack getItem(int index);
33
34 /**
35 * Stores the ItemStack at the given index
36 *
37 * @param index The index where to put the ItemStack
38 * @param item The ItemStack to set
39 */
40 public void setItem(int index, ItemStack item);
41
42 /**
43 * Stores the given ItemStacks in the inventory.
44 * <p>
45 * This will try to fill existing stacks and empty slots as good as it can.
46 * It will return a HashMap of what it couldn't fit.
47 *
48 * @param items The ItemStacks to add
49 * @return
50 */
51 public HashMap<Integer, ItemStack> addItem(ItemStack... items);
52
53 /**
54 * Removes the given ItemStacks from the inventory.
55 * <p>
56 * It will try to remove 'as much as possible' from the types and amounts you
57 * give as arguments. It will return a HashMap of what it couldn't remove.
58 *
59 * @param items The ItemStacks to remove
60 * @return
61 */
62 public HashMap<Integer, ItemStack> removeItem(ItemStack... items);
63
64 /**
65 * Get all ItemStacks from the inventory
66 *
67 * @return All the ItemStacks from all slots
68 */
69 public ItemStack[] getContents();
70
71 /**
72 * Set the inventory's contents
73 *
74 * @return All the ItemStacks from all slots
75 */
76 public void setContents(ItemStack[] items);
77
78 /**
79 * Check if the inventory contains any ItemStacks with the given materialId
80 *
81 * @param materialId The materialId to check for
82 * @return If any ItemStacks were found
83 */
84 public boolean contains(int materialId);
85
86 /**
87 * Check if the inventory contains any ItemStacks with the given material
88 *
89 * @param material The material to check for
90 * @return If any ItemStacks were found
91 */
92 public boolean contains(Material material);
93
94 /**
95 * Check if the inventory contains any ItemStacks matching the given ItemStack
96 * This will only match if both the type and the amount of the stack match
97 *
98 * @param item The ItemStack to match against
99 * @return If any matching ItemStacks were found
100 */
101 public boolean contains(ItemStack item);
102
103 /**
104 * Check if the inventory contains any ItemStacks with the given materialId and at least the minimum amount specified
105 *
106 * @param materialId The materialId to check for
107 * @param amount The minimum amount to look for
108 * @return If any ItemStacks were found
109 */
110 public boolean contains(int materialId, int amount);
111
112 /**
113 * Check if the inventory contains any ItemStacks with the given material and at least the minimum amount specified
114 *
115 * @param material The material to check for
116 * @return If any ItemStacks were found
117 */
118 public boolean contains(Material material, int amount);
119
120 /**
121 * Check if the inventory contains any ItemStacks matching the given ItemStack and at least the minimum amount specified
122 * This will only match if both the type and the amount of the stack match
123 *
124 * @param item The ItemStack to match against
125 * @return If any matching ItemStacks were found
126 */
127 public boolean contains(ItemStack item, int amount);
128
129 /**
130 * Find all slots in the inventory containing any ItemStacks with the given materialId
131 *
132 * @param materialId The materialId to look for
133 * @return The Slots found.
134 */
135 public HashMap<Integer, ? extends ItemStack> all(int materialId);
136
137 /**
138 * Find all slots in the inventory containing any ItemStacks with the given material
139 *
140 * @param materialId The material to look for
141 * @return The Slots found.
142 */
143 public HashMap<Integer, ? extends ItemStack> all(Material material);
144
145 /**
146 * Find all slots in the inventory containing any ItemStacks with the given ItemStack
147 * This will only match slots if both the type and the amount of the stack match
148 *
149 * @param item The ItemStack to match against
150 * @return The Slots found.
151 */
152 public HashMap<Integer, ? extends ItemStack> all(ItemStack item);
153
154 /**
155 * Find the first slot in the inventory containing an ItemStack with the given materialId
156 *
157 * @param materialId The materialId to look for
158 * @return The Slot found.
159 */
160 public int first(int materialId);
161
162 /**
163 * Find the first slot in the inventory containing an ItemStack with the given material
164 *
165 * @param materialId The material to look for
166 * @return The Slot found.
167 */
168 public int first(Material material);
169
170 /**
171 * Find the first slot in the inventory containing an ItemStack with the given stack
172 * This will only match a slot if both the type and the amount of the stack match
173 *
174 * @param item The ItemStack to match against
175 * @return The Slot found.
176 */
177 public int first(ItemStack item);
178
179 /**
180 * Find the first empty Slot.
181 *
182 * @return The first empty Slot found.
183 */
184 public int firstEmpty();
185
186 /**
187 * Remove all stacks in the inventory matching the given materialId.
188 *
189 * @param materialId The material to remove
190 */
191 public void remove(int materialId);
192
193 /**
194 * Remove all stacks in the inventory matching the given material.
195 *
196 * @param material The material to remove
197 */
198 public void remove(Material material);
199
200 /**
201 * Remove all stacks in the inventory matching the given stack.
202 * This will only match a slot if both the type and the amount of the stack match
203 *
204 * @param item The ItemStack to match against
205 */
206 public void remove(ItemStack item);
207
208 /**
209 * Clear out a particular slot in the index
210 *
211 * @param index The index to empty.
212 */
213 public void clear(int index);
214
215 /**
216 * Clear out the whole index
217 */
218 public void clear();
219}