|
16 | 16 | import java.util.concurrent.CompletableFuture; |
17 | 17 | import java.util.function.Predicate; |
18 | 18 |
|
| 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 | + */ |
19 | 24 | public interface AuctionManager { |
20 | 25 |
|
| 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 | + */ |
21 | 32 | void openMainAuction(Player player); |
22 | 33 |
|
| 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 | + */ |
23 | 40 | void openMainAuction(Player player, int page); |
24 | 41 |
|
| 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 | + */ |
25 | 49 | void updateInventory(Player player); |
26 | 50 |
|
| 51 | + /** |
| 52 | + * @return service responsible for processing purchases and related validations |
| 53 | + */ |
27 | 54 | AuctionPurchaseService getPurchaseService(); |
28 | 55 |
|
| 56 | + /** |
| 57 | + * @return service used to list items for sale and validate prices or player limits |
| 58 | + */ |
29 | 59 | AuctionSellService getSellService(); |
30 | 60 |
|
| 61 | + /** |
| 62 | + * @return service coordinating removal of items from storage or live listings |
| 63 | + */ |
31 | 64 | AuctionRemoveService getRemoveService(); |
32 | 65 |
|
| 66 | + /** |
| 67 | + * @return service that moves items into expired storage and notifies owners when applicable |
| 68 | + */ |
33 | 69 | AuctionExpireService getExpireService(); |
34 | 70 |
|
| 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 | + */ |
35 | 77 | List<Item> getItems(StorageType storageType); |
36 | 78 |
|
| 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 | + */ |
37 | 87 | List<Item> getItems(StorageType storageType, Predicate<Item> predicate); |
38 | 88 |
|
| 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 | + */ |
39 | 98 | List<Item> getItems(StorageType storageType, Predicate<Item> predicate, Comparator<Item> comparator); |
40 | 99 |
|
| 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 | + */ |
41 | 107 | void addItem(StorageType storageType, Item item); |
42 | 108 |
|
| 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 | + */ |
43 | 115 | void removeItem(StorageType storageType, Item item); |
44 | 116 |
|
| 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 | + */ |
45 | 124 | void removeItem(StorageType storageType, int itemId); |
46 | 125 |
|
| 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 | + */ |
47 | 133 | List<Item> getItemsListedForSale(Player player); |
48 | 134 |
|
| 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 | + */ |
49 | 141 | List<Item> getExpiredItems(Player player); |
50 | 142 |
|
| 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 | + */ |
51 | 150 | List<Item> getPlayerOwnedItems(Player player); |
52 | 151 |
|
| 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 | + */ |
53 | 159 | List<Item> getPurchasedItems(Player player); |
54 | 160 |
|
| 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 | + */ |
55 | 167 | List<Item> getExpiredItems(java.util.UUID uniqueId); |
56 | 168 |
|
| 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 | + */ |
57 | 175 | List<Item> getPlayerOwnedItems(java.util.UUID uniqueId); |
58 | 176 |
|
| 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 | + */ |
59 | 183 | List<Item> getPurchasedItems(java.util.UUID uniqueId); |
60 | 184 |
|
| 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 | + */ |
61 | 192 | PlayerCache getCache(Player player); |
62 | 193 |
|
| 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 | + */ |
63 | 200 | void clearPlayersCache(PlayerCacheKey... keys); |
64 | 201 |
|
| 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 | + */ |
65 | 209 | void clearPlayerCache(Player player, PlayerCacheKey... keys); |
66 | 210 |
|
| 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 | + */ |
67 | 217 | void removeCache(Player player); |
68 | 218 |
|
| 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 | + */ |
69 | 227 | CompletableFuture<Void> removeListedItem(Player player, Item item); |
70 | 228 |
|
| 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 | + */ |
71 | 237 | CompletableFuture<Void> removeOwnedItem(Player player, Item item); |
72 | 238 |
|
| 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 | + */ |
73 | 246 | CompletableFuture<Void> removeExpiredItem(Player player, Item item); |
74 | 247 |
|
| 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 | + */ |
75 | 255 | CompletableFuture<Void> removePurchasedItem(Player player, Item item); |
76 | 256 |
|
| 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 | + */ |
77 | 266 | void adminRemoveItem(Player admin, java.util.UUID targetUniqueId, Item item, StorageType storageType); |
78 | 267 |
|
| 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 | + */ |
79 | 276 | CompletableFuture<Void> purchaseItem(Player player, Item item); |
80 | 277 |
|
| 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 | + */ |
81 | 285 | void message(Player player, Message message, Object... args); |
82 | 286 |
|
| 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 | + */ |
83 | 295 | void updateListedItems(Item item, boolean added, Player ignoredPlayer); |
84 | 296 | } |
0 commit comments