Skip to content

Commit 0f6225c

Browse files
authored
Merge pull request #7 from GroupeZ-dev/codex/add-javadoc-comments-for-api-interfaces
Add detailed Javadoc to API interfaces
2 parents ceafefb + 47f9844 commit 0f6225c

8 files changed

Lines changed: 695 additions & 0 deletions

File tree

API/src/main/java/fr/maxlego08/zauctionhouse/api/AuctionManager.java

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,69 +16,281 @@
1616
import java.util.concurrent.CompletableFuture;
1717
import java.util.function.Predicate;
1818

19+
/**
20+
* Central entry point for manipulating the auction house state. Implementations coordinate UI
21+
* opening, item storage, cache management, and asynchronous item lifecycle actions so that other
22+
* plugins can interact with the marketplace without duplicating logic.
23+
*/
1924
public interface AuctionManager {
2025

26+
/**
27+
* Opens the main auction house inventory for the provided player using the default first page
28+
* configuration.
29+
*
30+
* @param player viewer who should see the main auction interface
31+
*/
2132
void openMainAuction(Player player);
2233

34+
/**
35+
* Opens the main auction house inventory at a specific page for pagination-aware UIs.
36+
*
37+
* @param player viewer who should see the main auction interface
38+
* @param page zero or one based page index depending on the configured inventory provider
39+
*/
2340
void openMainAuction(Player player, int page);
2441

42+
/**
43+
* Forces the currently opened auction inventory of the player to refresh its contents and UI
44+
* components. Implementations typically re-run pagination and sorting logic before redrawing
45+
* the view.
46+
*
47+
* @param player player whose auction inventory should be updated
48+
*/
2549
void updateInventory(Player player);
2650

51+
/**
52+
* @return service responsible for processing purchases and related validations
53+
*/
2754
AuctionPurchaseService getPurchaseService();
2855

56+
/**
57+
* @return service used to list items for sale and validate prices or player limits
58+
*/
2959
AuctionSellService getSellService();
3060

61+
/**
62+
* @return service coordinating removal of items from storage or live listings
63+
*/
3164
AuctionRemoveService getRemoveService();
3265

66+
/**
67+
* @return service that moves items into expired storage and notifies owners when applicable
68+
*/
3369
AuctionExpireService getExpireService();
3470

71+
/**
72+
* Retrieves every item stored under the given bucket (listed, expired, purchased, etc.).
73+
*
74+
* @param storageType logical container to read from
75+
* @return immutable or defensive copy list of items currently recorded for that storage type
76+
*/
3577
List<Item> getItems(StorageType storageType);
3678

79+
/**
80+
* Retrieves items from the given storage type and filters them before returning. Filtering is
81+
* executed synchronously on the current thread and should remain inexpensive.
82+
*
83+
* @param storageType logical container to read from
84+
* @param predicate filter applied to each candidate item
85+
* @return list of items that satisfy the predicate
86+
*/
3787
List<Item> getItems(StorageType storageType, Predicate<Item> predicate);
3888

89+
/**
90+
* Retrieves, filters, and sorts items from the given storage type in one pass to support
91+
* inventory rendering and API consumers that require deterministic ordering.
92+
*
93+
* @param storageType logical container to read from
94+
* @param predicate filter applied to each candidate item
95+
* @param comparator ordering applied to the filtered results
96+
* @return sorted list of items that satisfy the predicate
97+
*/
3998
List<Item> getItems(StorageType storageType, Predicate<Item> predicate, Comparator<Item> comparator);
4099

100+
/**
101+
* Adds a new item into the specified storage bucket. Implementations are responsible for
102+
* persisting the item and updating any caches or live inventory views.
103+
*
104+
* @param storageType logical container to add the item to
105+
* @param item item instance to store
106+
*/
41107
void addItem(StorageType storageType, Item item);
42108

109+
/**
110+
* Removes the provided item reference from the specified storage type if it exists.
111+
*
112+
* @param storageType storage bucket the item should be removed from
113+
* @param item item instance to delete
114+
*/
43115
void removeItem(StorageType storageType, Item item);
44116

117+
/**
118+
* Removes an item identified by its unique ID from the specified storage type without
119+
* requiring a full item instance.
120+
*
121+
* @param storageType storage bucket the item should be removed from
122+
* @param itemId unique identifier of the item to delete
123+
*/
45124
void removeItem(StorageType storageType, int itemId);
46125

126+
/**
127+
* Retrieves every item currently listed for sale by the given player, excluding expired or
128+
* purchased entries.
129+
*
130+
* @param player player who listed the items
131+
* @return list of active listings created by the player
132+
*/
47133
List<Item> getItemsListedForSale(Player player);
48134

135+
/**
136+
* Retrieves expired listings that belong to the specified player so they can reclaim them.
137+
*
138+
* @param player player owner of the expired items
139+
* @return expired items awaiting reclamation
140+
*/
49141
List<Item> getExpiredItems(Player player);
50142

143+
/**
144+
* Retrieves items currently owned by the player but still within the auction house storage
145+
* (for example, unsold items or items awaiting delivery).
146+
*
147+
* @param player player owner to search for
148+
* @return items belonging to the player across storage types
149+
*/
51150
List<Item> getPlayerOwnedItems(Player player);
52151

152+
/**
153+
* Retrieves items the player successfully purchased and that are held in storage until
154+
* collected.
155+
*
156+
* @param player player who purchased the items
157+
* @return purchased items awaiting delivery
158+
*/
53159
List<Item> getPurchasedItems(Player player);
54160

161+
/**
162+
* Version of {@link #getExpiredItems(Player)} using a UUID for offline player compatibility.
163+
*
164+
* @param uniqueId unique identifier of the player
165+
* @return expired items awaiting reclamation
166+
*/
55167
List<Item> getExpiredItems(java.util.UUID uniqueId);
56168

169+
/**
170+
* Version of {@link #getPlayerOwnedItems(Player)} using a UUID for offline player support.
171+
*
172+
* @param uniqueId unique identifier of the player
173+
* @return items belonging to the player across storage types
174+
*/
57175
List<Item> getPlayerOwnedItems(java.util.UUID uniqueId);
58176

177+
/**
178+
* Version of {@link #getPurchasedItems(Player)} using a UUID for offline player support.
179+
*
180+
* @param uniqueId unique identifier of the player
181+
* @return purchased items awaiting delivery
182+
*/
59183
List<Item> getPurchasedItems(java.util.UUID uniqueId);
60184

185+
/**
186+
* Retrieves or initializes the cache entry associated with the given player, exposing
187+
* frequently accessed player-specific data.
188+
*
189+
* @param player player whose cache should be retrieved
190+
* @return cache wrapper providing quick access to player metadata
191+
*/
61192
PlayerCache getCache(Player player);
62193

194+
/**
195+
* Clears the requested cache keys for every tracked player, forcing the values to be recomputed
196+
* on next access.
197+
*
198+
* @param keys cache keys to reset; when empty all caches remain untouched
199+
*/
63200
void clearPlayersCache(PlayerCacheKey... keys);
64201

202+
/**
203+
* Clears the requested cache keys for a specific player so the information will be recalculated
204+
* the next time it is requested.
205+
*
206+
* @param player player whose cache should be purged
207+
* @param keys cache keys to reset; when empty no keys are cleared
208+
*/
65209
void clearPlayerCache(Player player, PlayerCacheKey... keys);
66210

211+
/**
212+
* Removes the entire cache entry for a player, typically when they disconnect or no longer need
213+
* to be tracked.
214+
*
215+
* @param player player whose cache should be removed
216+
*/
67217
void removeCache(Player player);
68218

219+
/**
220+
* Asynchronously removes an item the player listed for sale, executing required storage and
221+
* refund operations.
222+
*
223+
* @param player player requesting the removal
224+
* @param item listing to remove
225+
* @return future completing once the removal has been processed
226+
*/
69227
CompletableFuture<Void> removeListedItem(Player player, Item item);
70228

229+
/**
230+
* Asynchronously removes an item owned by the player from their storage, for example when they
231+
* discard a reclaimed item.
232+
*
233+
* @param player player requesting the removal
234+
* @param item owned item to delete
235+
* @return future completing once the removal has been processed
236+
*/
71237
CompletableFuture<Void> removeOwnedItem(Player player, Item item);
72238

239+
/**
240+
* Asynchronously removes an expired item from the player's expired storage.
241+
*
242+
* @param player player requesting the removal
243+
* @param item expired item to delete
244+
* @return future completing once the removal has been processed
245+
*/
73246
CompletableFuture<Void> removeExpiredItem(Player player, Item item);
74247

248+
/**
249+
* Asynchronously removes a purchased item from the player's purchased storage.
250+
*
251+
* @param player player requesting the removal
252+
* @param item purchased item to delete
253+
* @return future completing once the removal has been processed
254+
*/
75255
CompletableFuture<Void> removePurchasedItem(Player player, Item item);
76256

257+
/**
258+
* Allows an administrator to remove an item that belongs to another player from any storage
259+
* type. Implementations should log the action and respect configured permissions.
260+
*
261+
* @param admin administrator performing the removal
262+
* @param targetUniqueId owner of the item
263+
* @param item item to remove
264+
* @param storageType storage bucket the item currently resides in
265+
*/
77266
void adminRemoveItem(Player admin, java.util.UUID targetUniqueId, Item item, StorageType storageType);
78267

268+
/**
269+
* Attempts to purchase the provided item on behalf of the player. The returned future completes
270+
* once validations, economy transactions, storage updates, and notifications are finished.
271+
*
272+
* @param player buyer initiating the purchase
273+
* @param item listing to buy
274+
* @return future completing after the purchase workflow finishes
275+
*/
79276
CompletableFuture<Void> purchaseItem(Player player, Item item);
80277

278+
/**
279+
* Sends a localized or parameterized message to the player using the plugin's messaging system.
280+
*
281+
* @param player recipient of the message
282+
* @param message message descriptor to send
283+
* @param args optional parameters inserted into the message template
284+
*/
81285
void message(Player player, Message message, Object... args);
82286

287+
/**
288+
* Propagates changes to an item currently listed for sale so viewers can see the update without
289+
* reopening the interface.
290+
*
291+
* @param item listing that changed
292+
* @param added {@code true} when the item was added, {@code false} when removed
293+
* @param ignoredPlayer optional player who should not receive the update (e.g., action initiator)
294+
*/
83295
void updateListedItems(Item item, boolean added, Player ignoredPlayer);
84296
}

0 commit comments

Comments
 (0)