-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathInventory.java
More file actions
241 lines (204 loc) · 7.4 KB
/
Inventory.java
File metadata and controls
241 lines (204 loc) · 7.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
package fr.maxlego08.menu.api;
import fr.maxlego08.menu.api.animation.TitleAnimation;
import fr.maxlego08.menu.api.button.Button;
import fr.maxlego08.menu.api.engine.InventoryEngine;
import fr.maxlego08.menu.api.engine.InventoryResult;
import fr.maxlego08.menu.api.pattern.Pattern;
import fr.maxlego08.menu.api.requirement.Action;
import fr.maxlego08.menu.api.requirement.ConditionalName;
import fr.maxlego08.menu.api.requirement.Requirement;
import fr.maxlego08.menu.api.utils.ClearInvType;
import fr.maxlego08.menu.api.utils.InventoryReplacement;
import fr.maxlego08.menu.api.utils.OpenWithItem;
import fr.maxlego08.menu.api.utils.Placeholders;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* The `Inventory` interface defines the structure and behavior of inventory-related operations.
* <br>
* Documentation: <a href="https://docs.zmenu.dev/api/create-inventory">Inventory documentation</a>
* <p>This class encapsulates information about an inventory, including its size, buttons, patterns, and associated requirements.</p>
*/
public interface Inventory {
/**
* Returns the size of the inventory.
*
* @return The size of the inventory. This value is the number of slots in the inventory.
*/
int size();
/**
* Returns the name of the inventory.
*
* @return The name of the inventory. This name is used internally by zMenu and can be used to identify the inventory.
*/
String getName();
/**
* Returns the translated name of the inventory.
*
* @return The name of the inventory, translated to the player's language.
*/
String getName(Player player, InventoryEngine InventoryEngine, Placeholders placeholders);
/**
* Returns the type of the inventory.
*
* @return The type of the inventory.
*/
InventoryType getType();
/**
* Indicates whether the inventory prevents the player from picking up items from the ground.
* @return true if item pickup is blocked while this inventory is open, false otherwise.
*/
boolean shouldCancelItemPickup();
/**
* Returns the name of the file associated with the inventory.
*
* @return The file name. This name is the name of the configuration file.
*/
String getFileName();
/**
* Returns a collection of buttons present in the inventory.
*
* @return A collection of buttons. This collection contains all the buttons present in the inventory, including the ones in the patterns.
*/
Collection<Button> getButtons();
/**
* Returns a collection of patterns associated with the inventory.
*
* @return A collection of patterns. This collection contains all the patterns associated with the inventory.
*/
Collection<Pattern> getPatterns();
/**
* Returns a list of buttons of a specific type.
*
* @param type The class type of the button.
* @param <T> The button type.
* @return A list of buttons with the specified type.
*/
<T extends Button> List<T> getButtons(Class<T> type);
/**
* Returns the plugin from which the inventory originates.
*
* @return The plugin.
*/
Plugin getPlugin();
/**
* Returns the maximum number of pages for the inventory.
*
* @param patterns Pattern list
* @param player The player for whom the page count is determined.
* @param objects Additional elements.
* @return The maximum number of pages.
*/
int getMaxPage(Collection<Pattern> patterns, Player player, Object... objects);
/**
* Sorts the buttons based on the current page and additional elements.
*
* @param page The current page.
* @param objects Additional elements.
* @return A list of sorted buttons.
*/
List<Button> sortButtons(int page, Object... objects);
/**
* Sorts the pattern buttons based on the current page and additional elements.
*
* @param pattern The pattern
* @param page The current page.
* @param objects Additional elements.
* @return A list of sorted buttons.
*/
List<Button> sortPatterns(Pattern pattern, int page, Object... objects);
/**
* Opens the inventory for a player and returns the result of the operation.
*
* @param player The player opening the inventory.
* @param InventoryEngine The inventory to be opened.
* @return The result of the inventory opening.
*/
InventoryResult openInventory(Player player, InventoryEngine InventoryEngine);
/**
* Performs post-opening actions for the inventory.
*
* @param player The player for whom post-opening actions are performed.
* @param InventoryEngine The default inventory object.
*/
void postOpenInventory(Player player, InventoryEngine InventoryEngine);
/**
* Closes the inventory for a player.
*
* @param player The player closing the inventory.
* @param InventoryEngine The inventory to be closed.
*/
void closeInventory(Player player, InventoryEngine InventoryEngine);
/**
* Returns the item stack used to fill empty slots in the inventory.
*
* @return The fill item stack.
*/
MenuItemStack getFillItemStack();
/**
* Returns the interval for updating buttons in the inventory.
*
* @return The update interval.
*/
int getUpdateInterval();
/**
* Returns the configuration file associated with the inventory.
*
* @return The configuration file.
*/
File getFile();
/**
* Determines whether the player's inventory should be cleared upon closing the inventory.
*
* @return True if the player's inventory should be cleaned, false otherwise.
*/
boolean cleanInventory();
/**
* Returns the requirement for opening the inventory.
*
* @return The opening requirement.
*/
Requirement getOpenRequirement();
/**
* Returns the item that can be used to open the inventory. (Left or rick click)
*
* @return The OpenWithItem
*/
OpenWithItem getOpenWithItem();
/**
* Returns the translated name of the inventory.
*
* @return The translated name, a map of locale to translated name.
*/
Map<String, String> getTranslatedNames();
/**
* Retrieves a list of all conditional names associated with this inventory.
*
* <p>These conditional names are used to determine whether a player can access the inventory, based on a
* set of permissions.</p>
*
* @return A list of all conditional names associated with this inventory.
*/
List<ConditionalName> getConditionalNames();
/**
* Returns the player name placeholder used in the inventory.
* Placeholders are parsed by this player name.
* @return The player name placeholder.
*/
String getTargetPlayerNamePlaceholder();
void setTitleAnimation(TitleAnimation load);
TitleAnimation getTitleAnimation();
List<Action> getOpenActions();
List<Action> getCloseActions();
ClearInvType getClearInvType();
boolean isClickLimiterEnabled();
@Nullable
InventoryReplacement getInventoryReplacement();
void setInventoryReplacement(InventoryReplacement inventoryReplacement);
}