|
15 | 15 | import com.skyblockexp.ezauction.history.AuctionTransactionHistoryService; |
16 | 16 | import org.bukkit.entity.Player; |
17 | 17 | import org.bukkit.inventory.ItemStack; |
| 18 | +import org.bukkit.inventory.meta.ItemMeta; |
| 19 | +import org.bukkit.ChatColor; |
18 | 20 | import org.bukkit.plugin.java.JavaPlugin; |
19 | 21 | import org.bukkit.scheduler.BukkitTask; |
20 | 22 |
|
|
26 | 28 | import com.skyblockexp.ezauction.service.AuctionExpiryService; |
27 | 29 | import com.skyblockexp.ezauction.service.AuctionQueryService; |
28 | 30 | import com.skyblockexp.ezauction.util.AuctionValidationUtils; |
| 31 | +import com.skyblockexp.ezauction.util.DateUtil; |
29 | 32 |
|
30 | 33 | public class AuctionManager { |
31 | 34 | // Services |
@@ -342,4 +345,37 @@ public long countActiveOrders() { |
342 | 345 | public AuctionConfiguration getConfiguration() { |
343 | 346 | return configuration; |
344 | 347 | } |
| 348 | + |
| 349 | + /** |
| 350 | + * Returns a list of ItemStacks representing all active orders placed by the given player. |
| 351 | + * |
| 352 | + * @param player the player whose orders to fetch |
| 353 | + * @return a list of ItemStacks for the player's active orders |
| 354 | + */ |
| 355 | + public List<ItemStack> getOpenOrdersForPlayer(Player player) { |
| 356 | + List<ItemStack> result = new ArrayList<>(); |
| 357 | + if (player == null) return result; |
| 358 | + UUID buyerId = player.getUniqueId(); |
| 359 | + long now = System.currentTimeMillis(); |
| 360 | + for (AuctionOrder order : queryService.listActiveOrders()) { |
| 361 | + if (buyerId.equals(order.buyerId()) && order.expiryEpochMillis() > now) { |
| 362 | + ItemStack item = order.requestedItem(); |
| 363 | + if (item != null) { |
| 364 | + ItemMeta meta = item.getItemMeta(); |
| 365 | + List<String> lore = new ArrayList<>(); |
| 366 | + lore.add(ChatColor.GOLD + "Order ID: " + order.id()); |
| 367 | + lore.add(ChatColor.GRAY + "Price per Item: " + ChatColor.GOLD + order.pricePerItem()); |
| 368 | + lore.add(ChatColor.GRAY + "Quantity: " + ChatColor.AQUA + order.quantity()); |
| 369 | + lore.add(ChatColor.GRAY + "Total Price: " + ChatColor.GOLD + order.offeredPrice()); |
| 370 | + lore.add(ChatColor.GRAY + "Expires: " + ChatColor.YELLOW + DateUtil.formatDate(order.expiryEpochMillis())); |
| 371 | + if (meta != null) { |
| 372 | + meta.setLore(lore); |
| 373 | + item.setItemMeta(meta); |
| 374 | + } |
| 375 | + result.add(item); |
| 376 | + } |
| 377 | + } |
| 378 | + } |
| 379 | + return result; |
| 380 | + } |
345 | 381 | } |
0 commit comments