### Example: Get Player Balance Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Shows how to asynchronously retrieve a player's balance using CompletableFuture and display it to the player. ```java economy.get(player.getUniqueId()) .thenAccept(balance -> { player.sendMessage("Balance: " + balance); }); ``` -------------------------------- ### Get Item Price Example Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Demonstrates how to retrieve an item's price and perform a comparison. Ensure the Item object is obtained from a manager. ```java Item item = manager.getItems(StorageType.LISTED).get(0); BigDecimal price = item.getPrice(); if (price.compareTo(BigDecimal.valueOf(1000)) > 0) { // Item is expensive } ``` -------------------------------- ### Example: Get Economy by Name Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Illustrates how to retrieve a specific economy, like 'Vault', by its name and check if it exists before using it. ```java Optional vault = manager.getEconomy("Vault"); if (vault.isPresent()) { // Use vault economy } ``` -------------------------------- ### Example: Iterate Through Registered Economies Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Shows how to get all registered economies using EconomyManager and log their names. Requires an EconomyManager instance. ```java EconomyManager manager = plugin.getEconomyManager(); for (AuctionEconomy economy : manager.getEconomies()) { logger.info("Economy: " + economy.getName()); } ``` -------------------------------- ### Example: Set Auction Cluster Bridge Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-plugin.md Example demonstrating how to set a custom cluster bridge implementation for the auction plugin. ```java CustomClusterBridge bridge = new CustomClusterBridge(); plugin.setAuctionClusterBridge(bridge); ``` -------------------------------- ### Handle AuctionLoadEconomyEvent Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Example of how to handle the AuctionLoadEconomyEvent to log available economies. ```java @EventHandler public void onEconomyLoad(AuctionLoadEconomyEvent event) { EconomyManager manager = event.getEconomyManager(); // Log which economies are available for (AuctionEconomy economy : manager.getEconomies()) { logger.info("Loaded economy: " + economy.getName()); } } ``` -------------------------------- ### Standard Event Listener Registration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Basic example of registering an event listener for AuctionPreSellEvent. ```java @EventHandler public void onAuctionSell(AuctionPreSellEvent event) { // Handle event } ``` -------------------------------- ### Getting the Plugin Instance Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/README.md Retrieves the zAuctionHouse plugin instance from the Bukkit plugin manager. ```APIDOC ## Getting the Plugin Instance ### Description Retrieves the zAuctionHouse plugin instance from the Bukkit plugin manager. ### Method `Bukkit.getPluginManager().getPlugin("zAuctionHouse")` ### Response - **AuctionPlugin** - The instance of the zAuctionHouse plugin. ``` -------------------------------- ### ITEM_TYPE Rule Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Example configuration for an ITEM_TYPE rule, matching items by their Material. ```yaml rules: - type: "ITEM_TYPE" values: - "DIAMOND_SWORD" - "IRON_SWORD" - "NETHERITE_SWORD" ``` -------------------------------- ### Get Tax Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves the tax rules applicable to the economy. ```java TaxConfiguration getTaxConfiguration(); ``` -------------------------------- ### ItemRuleContext Usage Example Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Demonstrates how to create an ItemRuleContext and use it with a rule's matches method. ```java ItemRuleContext context = new ItemRuleContext(itemStack); boolean matches = rule.matches(context); ``` -------------------------------- ### Example: Format Price Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Demonstrates how to use the format method to display a price with currency symbol and quantity. The output depends on the economy's configuration. ```java String formatted = economy.format("1,234.50", 64); // Output: "1,234.50 dollars" or similar ``` -------------------------------- ### Accessing ZAuctionHouse Services Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/services.md Example of how to access various services from the AuctionManager instance. Ensure the AuctionManager is obtained from the plugin instance. ```java AuctionManager manager = plugin.getAuctionManager(); // Access services AuctionSellService sellService = manager.getSellService(); AuctionPurchaseService purchaseService = manager.getPurchaseService(); AuctionRemoveService removeService = manager.getRemoveService(); AuctionExpireService expireService = manager.getExpireService(); AuctionClaimService claimService = manager.getClaimService(); AuctionHistoryService historyService = manager.getHistoryService(); AuctionOptionService optionService = manager.getOptionService(); ``` -------------------------------- ### REGEX Rule Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Example for a REGEX rule, matching item names using a regular expression pattern. ```yaml rules: - type: "REGEX" pattern: ".*Legendary.*" # Any item with "Legendary" in name ``` -------------------------------- ### Example: Calculate and Display Sell Tax Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Demonstrates how to calculate the sell tax for an item and display the tax amount to the player if it's greater than zero. ```java TaxResult tax = economy.calculateSellTax(player, price, itemStack); if (tax.amount().compareTo(BigDecimal.ZERO) > 0) { player.sendMessage("Tax: " + tax.amount()); } ``` -------------------------------- ### Get Option Service Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieve the `AuctionOptionService` for managing player-specific options and preferences. ```java AuctionOptionService getOptionService(); ``` -------------------------------- ### Custom Sales Logging Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Example of an event listener that logs details of every sale, including the player, price, and economy name. ```java @EventHandler public void logAllSales(AuctionPreSellEvent event) { logger.info(String.format( "%s listed item for %s in %s", event.getPlayer().getName(), event.getPrice(), event.getEconomy().getName() )); } ``` -------------------------------- ### Custom Rule Configuration Example Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Shows how to reference a custom rule type ('CUSTOM') in the rules.yml configuration file, along with its specific parameters. ```yaml rules: - type: "CUSTOM" pattern: "my_pattern" ``` -------------------------------- ### startSearch(Player, String) Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Starts a search for the given player, storing the query and opening the auction inventory with filtered results. ```APIDOC ## startSearch(Player, String) ### Description Starts a search for the given player, storing the query in cache and opening the auction inventory with filtered results. ### Method void ### Parameters #### Path Parameters - **player** (Player) - Required - Player initiating the search - **query** (String) - Required - Search query string ### Request Example ```java manager.startSearch(player, "diamond"); // Opens auction with only items matching "diamond" ``` ``` -------------------------------- ### ItemRuleManager isBlacklisted() Example Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Checks if an item is blacklisted. An item cannot be sold if it matches any blacklist rule. ```java ItemRuleContext context = new ItemRuleContext(itemStack); if (ruleManager.isBlacklisted(context)) { player.sendMessage("This item cannot be sold!"); } ``` -------------------------------- ### Integration with Clan System Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Example of integrating with another plugin (Clan System) to prevent purchases between warring clans. ```java @EventHandler(priority = EventPriority.HIGH) public void integrateWithClanSystem(AuctionPrePurchaseItemEvent event) { UUID buyerId = event.getPlayer().getUniqueId(); UUID sellerId = event.getItem().getSellerUniqueId(); // Check if player's clan is at war with seller's clan if (clanSystem.isAtWar(buyerId, sellerId)) { event.setCancelled(true); event.getPlayer().sendMessage("Cannot trade during war!"); } } ``` -------------------------------- ### PLUGIN_ITEM Rule Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Examples for matching custom items from plugins like ItemsAdder and Oraxen. Specify the plugin and the custom item ID. ```yaml rules: - type: "PLUGIN_ITEM" plugin: "itemsadder" item: "custom_sword" - type: "PLUGIN_ITEM" plugin: "oraxen" item: "custom_item_id" ``` -------------------------------- ### Get Price Formatting Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves the settings for how prices are formatted, including decimal places and suffix usage. ```java PriceFormat getPriceFormat(); ``` -------------------------------- ### Create and Register Custom Rule Loader Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Provides an example of creating a custom RuleLoader for a 'CUSTOM' rule type. It defines the type and a load method for custom configuration, then registers it. ```java public class CustomRuleLoader implements RuleLoader { @Override public String getType() { return "CUSTOM"; } @Override public Rule load(Map config) { String pattern = (String) config.get("pattern"); return context -> { // Custom matching logic return matches(context, pattern); }; } } // Register auctionHouse.getRuleLoaderRegistry() .register(new CustomRuleLoader()); ``` -------------------------------- ### Example: Deposit Proceeds Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Illustrates depositing sales proceeds to a seller's account, including the player's UUID, the amount, and a descriptive reason for the transaction. ```java economy.deposit(seller.getUniqueId(), sellerProceeds, "Auction sale: " + item.getId()); ``` -------------------------------- ### Get Sell Service Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieve the `AuctionSellService` for listing items for sale and validating prices or player limits. ```java AuctionSellService getSellService(); ``` -------------------------------- ### Handle Auction Events Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/INDEX.md An example of listening to an `AuctionPreSellEvent` to potentially cancel the item listing based on custom logic. ```java @EventHandler public void onAuctionSell(AuctionPreSellEvent event) { if (shouldBlock(event)) { event.setCancelled(true); } } ``` -------------------------------- ### Get Price Format Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves the format template for displaying prices, including placeholders for the formatted number and pluralization. ```java String getFormat(); ``` -------------------------------- ### Example Usage: Check Expiration and Remaining Time Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Demonstrates how to check if an item has expired and display its remaining time to a player. ```java if (item.isExpired()) { player.sendMessage("Item expired!"); } else { player.sendMessage("Expires in: " + item.getRemainingTime()); } ``` -------------------------------- ### AuctionPrePurchaseItemEvent Example Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Fired before a player purchases an item. Use this to implement custom purchase restrictions. Setting cancelled prevents the purchase. ```java public class AuctionPrePurchaseItemEvent extends CancelledAuctionEvent ``` ```java Player getPlayer(); // Buyer Item getItem(); // Item being purchased BigDecimal getPrice(); // Purchase price AuctionEconomy getEconomy(); // Economy used ``` ```java @EventHandler public void onAuctionPrePurchase(AuctionPrePurchaseItemEvent event) { Player buyer = event.getPlayer(); Item item = event.getItem(); // Prevent buying from enemies (if you have a clan system) if (isEnemyPlayer(buyer, item.getSellerUniqueId())) { event.setCancelled(true); plugin.sendMessage(buyer, MyMessages.CANNOT_BUY_FROM_ENEMY); } } ``` -------------------------------- ### CategoryManager matchCategories() Example Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Categorizes an item by evaluating it against all registered categories. Always includes the misc category. ```java Set categories = categoryManager.matchCategories(itemStack); for (Category cat : categories) { logger.info("Item matches: " + cat.getDisplayName()); } ``` -------------------------------- ### Message Configuration Examples Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Customize messages displayed to players for various events like successful sales, purchases, or errors. Supports different display types. ```yaml messages: sell_success: type: "CHAT" content: "Item listed for {price}" purchase_success: type: "TITLE" title: "Purchase Successful!" subtitle: "You bought {item_display} for {price}" error_insufficient_funds: type: "ACTION_BAR" content: "✗ You need {required} coins" listing_limit_reached: type: "CHAT" content: "You've reached your listing limit of {limit} items" ``` -------------------------------- ### Statistics Collection on Item Removal Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Example of an event listener that records sales statistics when an item is removed from the auction. ```java @EventHandler(ignoreCancelled = true) public void recordStatistics(AuctionRemoveListedItemEvent event) { statistics.recordSale( event.getItem().getSellerUniqueId(), event.getItem().getPrice() ); } ``` -------------------------------- ### Start Player Search Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Initiates a search for a player, caching the query and opening the auction inventory with filtered results. Requires a player and a search query. ```java void startSearch(Player player, String query); ``` ```java manager.startSearch(player, "diamond"); // Opens auction with only items matching "diamond" ``` -------------------------------- ### zauctionhouse_category Permissible Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/changelogs.md Example of configuring the 'zauctionhouse_category' permissible to control button visibility based on the player's selected category. ```yaml requirements: - type: zauctionhouse_category category: "weapons" ``` -------------------------------- ### AuctionExpireEvent Example Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Fired when an item automatically expires. Use this to log expiration details or trigger follow-up actions. ```java public class AuctionExpireEvent extends AuctionEvent ``` ```java Item getItem(); // Expired item UUID getSellerUniqueId(); // Seller UUID String getSellerName(); // Seller name ``` ```java @EventHandler public void onAuctionExpire(AuctionExpireEvent event) { // Log expiration for statistics logger.info("Item " + event.getItem().getId() + " expired for seller " + event.getSellerName()); } ``` -------------------------------- ### Get StorageManager Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-plugin.md Access the StorageManager to interact with the persistence layer. Use it to get repositories for querying or manipulating stored data. ```java StorageManager storage = plugin.getStorageManager(); Repository itemRepo = storage.getRepository(ItemDTO.class); ``` -------------------------------- ### AuctionPreSellEvent Example Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Fired before an item is listed for sale. Use this to validate or reject the transaction based on price or other conditions. Setting cancelled prevents the listing. ```java public class AuctionPreSellEvent extends CancelledAuctionEvent ``` ```java Player getPlayer(); // Seller ItemStack getItem(); // Item being sold BigDecimal getPrice(); // Listing price AuctionEconomy getEconomy(); // Economy used long getExpiredAt(); // Expiration timestamp ``` ```java @EventHandler public void onAuctionPreSell(AuctionPreSellEvent event) { Player seller = event.getPlayer(); BigDecimal price = event.getPrice(); // Prevent free listings if (price.compareTo(BigDecimal.ZERO) <= 0) { event.setCancelled(true); plugin.sendMessage(seller, MyMessages.PRICE_TOO_LOW); } // Prevent sales during maintenance if (isMaintenanceWindow()) { event.setCancelled(true); plugin.sendMessage(seller, MyMessages.MAINTENANCE_MODE); } } ``` -------------------------------- ### Get Item Categories Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Retrieves and displays the categories associated with an item using the CategoryManager. It streams the categories to get their display names. ```java CategoryManager catManager = auctionHouse.getCategoryManager(); Set categories = catManager.matchCategories(item); String categoryNames = categories.stream() .map(Category::getDisplayName) .collect(Collectors.joining(", ")); player.sendMessage("Item categories: " + categoryNames); ``` -------------------------------- ### PlayerCacheKey Enum and Usage Example Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/types.md Keys used for caching player-specific data to improve performance. Demonstrates how to retrieve cached values. ```java public enum PlayerCacheKey { ITEMS_LISTED, ITEMS_PURCHASED, ITEMS_EXPIRED, SELLING_ITEMS, // Limits LISTING_LIMIT, // Permissions HAS_PERMISSION_SELL, HAS_PERMISSION_BUY, HAS_PERMISSION_REMOVE, // Configuration PLAYER_TAX_REDUCTION, AUTO_CLAIM_ENABLED, // Search SEARCH_QUERY, SEARCH_RESULTS } ``` ```java PlayerCache cache = manager.getCache(player); Integer limitCount = cache.get(PlayerCacheKey.LISTING_LIMIT); ``` -------------------------------- ### Event Priority Best Practices Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Demonstrates the use of HIGHEST, NORMAL, and LOWEST priorities for event handling, with explanations for each. ```java // HIGHEST: Override other plugins' decisions @EventHandler(priority = EventPriority.HIGHEST) public void securityCheck(AuctionPreSellEvent event) { } // NORMAL: Standard processing @EventHandler(priority = EventPriority.NORMAL) public void logEvent(AuctionPreSellEvent event) { } // LOWEST: Cleanup, don't prevent @EventHandler(priority = EventPriority.LOWEST) public void cleanupIfCancelled(AuctionPreSellEvent event) { } ``` -------------------------------- ### Get Item Amount Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Retrieves the quantity of items represented by this listing. ```java int getAmount(); ``` -------------------------------- ### Get Plugin Instance Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/README.md Retrieve the AuctionPlugin instance from the Bukkit plugin manager. ```java AuctionPlugin auctionHouse = (AuctionPlugin) Bukkit.getPluginManager() .getPlugin("zAuctionHouse"); ``` -------------------------------- ### Get Claim Service Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieve the `AuctionClaimService` responsible for claiming pending money from transactions. ```java AuctionClaimService getClaimService(); ``` -------------------------------- ### Get Expire Service Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieve the `AuctionExpireService` to manage expired items and notify owners. ```java AuctionExpireService getExpireService(); ``` -------------------------------- ### getPriceDecimalFormat Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Gets the standard DecimalFormat used for formatting all prices within the economy system. ```APIDOC ## getPriceDecimalFormat() ### Description Gets the standard DecimalFormat used for formatting all prices within the economy system. ### Method ```java DecimalFormat getPriceDecimalFormat() ``` ### Returns #### Success Response - **DecimalFormat** - Standard decimal formatter for all prices. ``` -------------------------------- ### Get Price Decimal Format Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves the standard DecimalFormat used for all price displays. ```java DecimalFormat getPriceDecimalFormat(); ``` -------------------------------- ### Get Formatted Price Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Formats the item's price. Use the version with PriceFormat to specify a custom format instead of the economy's default. ```java String getFormattedPrice(); ``` ```java String getFormattedPrice(PriceFormat priceFormat); ``` -------------------------------- ### Import AuctionSellService Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/services.md Import the AuctionSellService class to access its functionalities for listing items. ```java import fr.maxlego08.zauctionhouse.api.services.AuctionSellService; ``` -------------------------------- ### Category getId() Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Gets the unique identifier for the category. Used in configuration files and commands. ```java String getId(); ``` -------------------------------- ### getConfiguration() Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-plugin.md Fetches a snapshot of the current runtime configuration, including economy settings, message templates, tax rules, and feature flags. ```APIDOC ## getConfiguration() ### Description Fetches a snapshot of the current runtime configuration, including economy settings, message templates, tax rules, and feature flags. ### Method Configuration ### Endpoint N/A ### Response #### Success Response (200) - **Configuration** (`Configuration`) - Snapshot of current runtime configuration containing economy settings, message templates, tax rules, and feature flags. ``` -------------------------------- ### Whitelist Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Enable and configure a whitelist to restrict sales to only specified items. ```yaml rules: whitelist: enabled: false # Only these items can be sold items: - "DIAMOND" - "EMERALD" - "IRON_INGOT" ``` -------------------------------- ### Paginate Large Item Lists Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/README.md Retrieve item IDs and then resolve items for specific pages to handle large datasets efficiently. This example shows fetching the first two pages. ```java IntList ids = manager.getItemIdsListedForSale(player); List page1 = manager.resolveItemsForPage( StorageType.LISTED, ids, 0, 45); List page2 = manager.resolveItemsForPage( StorageType.LISTED, ids, 1, 45); ``` -------------------------------- ### Get Player Selling Items Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieves items currently being sold by the player in the auction house. ```java List getPlayerSellingItems(Player player); ``` -------------------------------- ### Get Expired Items for Player Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieves expired listings that belong to the specified player so they can reclaim them. ```java List getExpiredItems(Player player); ``` -------------------------------- ### Access Core Services Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/README.md Obtain instances of core services like AuctionManager, SellService, PurchaseService, Configuration, and EconomyManager. ```java // Item management AuctionManager manager = auctionHouse.getAuctionManager(); // Business logic services AuctionSellService sellService = manager.getSellService(); AuctionPurchaseService purchaseService = manager.getPurchaseService(); // Configuration and economy Configuration config = auctionHouse.getConfiguration(); EconomyManager economyManager = auctionHouse.getEconomyManager(); ``` -------------------------------- ### Initialize Sorted Items Cache Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Call `setupSortedItemsCache()` during plugin startup to initialize the cache for efficient item browsing. This must be done before opening any inventory views. ```java void setupSortedItemsCache(); ``` -------------------------------- ### Get History Service Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieve the `AuctionHistoryService` for managing sales history and offline sales notifications. ```java AuctionHistoryService getHistoryService(); ``` -------------------------------- ### Run Custom Migration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Execute a registered custom migration using the admin command. Ensure the correct migration provider name is used. ```bash /ah admin migrate oldauctionhouse confirm ``` -------------------------------- ### Get Remove Service Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieve the `AuctionRemoveService` to coordinate the removal of items from storage or live listings. ```java AuctionRemoveService getRemoveService(); ``` -------------------------------- ### Import AuctionPurchaseService Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/services.md Import the AuctionPurchaseService class to handle item purchases. ```java import fr.maxlego08.zauctionhouse.api.services.AuctionPurchaseService; ``` -------------------------------- ### Get Currency Symbol Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves the currency symbol used for displaying prices, such as '$', '€', or '¥'. ```java String getSymbol(); ``` -------------------------------- ### Create Custom Item Lore Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Illustrates how to build a custom list of strings to be used as lore for an ItemStack, including item-specific details like price and seller. ```java List customLore = Arrays.asList( "Price: " + item.getFormattedPrice(), "Seller: " + item.getSellerName(), "Remaining: " + item.getRemainingTime() ); ItemStack display = item.buildItemStack(player, customLore); ``` -------------------------------- ### Get Item Status Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Retrieves the current lifecycle status of the item, such as AVAILABLE, PURCHASED, or REMOVED. ```java ItemStatus getStatus(); ``` -------------------------------- ### Category getDisplayName() Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Gets the user-facing name shown in menus. Supports color codes and placeholders. ```java String getDisplayName(); ``` -------------------------------- ### CategoryManager getCategoryById() Example Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Retrieves a category by its unique identifier. Returns an Optional containing the category if found. ```java Optional weapons = manager.getCategoryById("weapons"); if (weapons.isPresent()) { // Use category } ``` -------------------------------- ### Get Purchased Items for Player Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieves items the player successfully purchased and that are held in storage until collected. ```java List getPurchasedItems(Player player); ``` -------------------------------- ### getOptionService() Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieves the service responsible for managing player-specific options and preferences. ```APIDOC ## getOptionService() ### Description Retrieves the service responsible for managing player-specific options and preferences. ### Method AuctionOptionService ### Endpoint N/A (Java method) ### Parameters None ### Response #### Success Response - **AuctionOptionService** — Service responsible for managing player-specific options and preferences. ``` -------------------------------- ### Get Minimum Item Price Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves the minimum allowed price for a given item type in an auction. ```java BigDecimal getMinPrice(ItemType itemType); ``` -------------------------------- ### Checking Sell Service Results Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/errors.md Demonstrates how to asynchronously retrieve and check the success of a sell operation, handling both success and failure cases. ```java SellResult result = sellService.sellAuctionItems(player, price, expiredAt, items, economy) .get(); // Wait for async completion if (result.isSuccess()) { player.sendMessage("Item listed successfully!"); Item created = result.getAuctionItem().get(); } else { player.sendMessage("Error: " + result.getMessage()); SellFailReason reason = result.getFailReason(); // Handle specific failure } ``` -------------------------------- ### Get Maximum Item Price Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves the maximum allowed price for a given item type in an auction. ```java BigDecimal getMaxPrice(ItemType itemType); ``` -------------------------------- ### User Experience Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Configure auction expiration duration and tax settings for player experience. ```yaml expiration: default-duration: 2592000 # 30 days extend-command: true # Let players extend tax: sell-tax: amount: "50" # Flat amount is clearer than percentage ``` -------------------------------- ### Get Economy Name Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves the internal identifier for the economy. Used for distinguishing between different currency providers. ```java String getName(); ``` -------------------------------- ### Security Limits Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Configure limits for listings and prices to prevent market flooding and price manipulation. ```yaml limits: listing: default: 50 # Prevent single player from flooding market price: default-max: 1000000 # Prevent price manipulation ``` -------------------------------- ### Get Item Categories Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Retrieves the set of categories that the item belongs to. This can be used for filtering or organizing items. ```java Set getCategories(); ``` -------------------------------- ### setupSortedItemsCache() Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Initializes the sorted items cache during plugin startup. This must be called before opening any inventory views to ensure efficient item browsing. ```APIDOC ## setupSortedItemsCache() ### Description Initializes the sorted items cache during plugin startup. This must be called before opening any inventory views to ensure efficient item browsing. ### Method void ### Endpoint N/A (Java method) ### Parameters None ### Response None ``` -------------------------------- ### Get Buyer Name Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Retrieves the last known username of the buyer. This is useful for displaying buyer information. ```java String getBuyerName(); ``` -------------------------------- ### Get Player Option Method Signature Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/services.md Signature for the getPlayerOption method, which retrieves a player-specific option value. ```java Optional getPlayerOption(UUID playerId, String optionKey); ``` -------------------------------- ### Performance Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Optimize plugin performance by enabling caching and lazy loading for items, and setting an appropriate update interval. ```yaml performance: cache-sorted-items: true # Enable for 100+ items lazy-load-items: true # Load items on demand update-interval: 1000 # Balance responsiveness vs CPU ``` -------------------------------- ### Economy Price Limit Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/types.md Retrieves the minimum and maximum price limits configured for the economy. ```java BigDecimal getMinPrice(); BigDecimal getMaxPrice(); ``` -------------------------------- ### Handling Async Events Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Example of an event handler that submits a long-running operation to an executor service for asynchronous processing. ```java @EventHandler public void onAsyncEvent(AuctionEvent event) { // This runs on the main thread // For async work, use the executor service: plugin.getExecutorService().submit(() -> { // Long-running operation here }); } ``` -------------------------------- ### Event Listener with Priority Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Demonstrates registering event listeners with different priorities (HIGHEST, NORMAL, LOWEST) to control execution order. ```java @EventHandler(priority = EventPriority.HIGHEST) public void checkPermissions(AuctionPreSellEvent event) { // Run first - custom permission checks } @EventHandler(priority = EventPriority.NORMAL) public void logTransaction(AuctionPreSellEvent event) { // Run after permission checks - logging } @EventHandler(priority = EventPriority.LOWEST) public void cleanupResources(AuctionPreSellEvent event) { // Run last - cleanup } ``` -------------------------------- ### getSellService() Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieves the service used to list items for sale and validate prices or player limits. ```APIDOC ## getSellService() ### Description Retrieves the service used to list items for sale and validate prices or player limits. ### Method AuctionSellService ### Endpoint N/A (Java method) ### Parameters None ### Response #### Success Response - **AuctionSellService** — Service used to list items for sale and validate prices or player limits. ``` -------------------------------- ### openMainAuction(Player, int) Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Opens the main auction house inventory at a specific page for pagination-aware UIs. ```APIDOC ## openMainAuction(Player, int) ### Description Opens the main auction house inventory at a specific page for pagination-aware UIs. ### Method void ### Endpoint N/A (Java method) ### Parameters #### Path Parameters - **player** (Player) - Required - Player who should see the main auction interface - **page** (int) - Required - Zero or one-based page index (depends on configuration) ### Response None ``` -------------------------------- ### Get Purchase Service Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieve the `AuctionPurchaseService` to handle item purchases, including validations, economy transactions, and notifications. ```java AuctionPurchaseService getPurchaseService(); ``` -------------------------------- ### Get Economy by Name Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves a specific economy by its internal name. Returns an Optional containing the economy if found. ```java Optional getEconomy(String economyName); ``` -------------------------------- ### Get All Registered Economies Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves a collection of all economies currently registered with the EconomyManager. Used for iterating through available economies. ```java Collection getEconomies(); ``` -------------------------------- ### Economy Settings Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Define default economy providers for auction, bid, and rent items. Configure auto-claim settings for money from sales. ```yaml economy: default-economy: auction: "Vault" # Default for AUCTION items bid: "Vault" # Default for BID items (planned) rent: "Vault" # Default for RENT items (planned) # Auto-claim money from sales auto-claim: enabled: true # If false, players must use /ah claim ``` -------------------------------- ### Get Item Display Name Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Retrieves a human-friendly display name for the item, suitable for use in menus and messages. ```java String getItemDisplay(); ``` -------------------------------- ### Database Settings Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Configure database connection details, supporting SQLite and MySQL. For MySQL, specify host, port, database name, username, password, SSL, and timezone. ```yaml database: type: "SQLite" # SQLite or MySQL # SQLite uses plugins/zAuctionHouse/data.db # MySQL Configuration (if type: MySQL) host: "localhost" port: 3306 database: "zauctionhouse" username: "root" password: "password" ssl: false timezone: "UTC" ``` -------------------------------- ### Query Items Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/README.md Retrieve lists of items from storage, with options to filter by seller or sort by price. ```java // All items listed for sale List allListings = manager.getItems(StorageType.LISTED); // Items from specific seller List sellerItems = manager.getItems(StorageType.LISTED, item -> item.getSellerUniqueId().equals(playerId)); // Sorted by price (ascending) List byPrice = manager.getItems(StorageType.LISTED, item -> true, Comparator.comparing(Item::getPrice)); ``` -------------------------------- ### Get Item Translation Key Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Retrieves the translation key used to fetch localized display strings for the item. ```java String getTranslationKey(); ``` -------------------------------- ### Open Sell Command Inventory Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/services.md Opens the sell confirmation inventory for a player with a pre-configured price and economy. Allows the player to confirm or cancel the listing. ```java void openSellCommandInventory( Player player, BigDecimal price, AuctionEconomy auctionEconomy ); ``` -------------------------------- ### Get PlatformScheduler Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-plugin.md Obtain the Folia-compatible scheduler for dispatching synchronous and asynchronous operations. Useful for offloading long-running tasks. ```java AuctionPlugin plugin = (AuctionPlugin) Bukkit.getPluginManager().getPlugin("zAuctionHouse"); plugin.getScheduler().runAsync(() -> { // Long-running operation like database queries }); ``` -------------------------------- ### Listing Limits Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Set the default maximum concurrent listings per player and define permission-based overrides for higher limits. ```yaml limits: listing: # Maximum concurrent listings per player default: 20 # Permission-based overrides permissions: "zauctionhouse.limit.50": 50 "zauctionhouse.limit.100": 100 price: # Price range per economy (override per-economy in economy.yml) default-min: "1.00" default-max: "1000000.00" ``` -------------------------------- ### Category getBannedRules() Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Gets an immutable list of exclusion rules. If an item matches any banned rule, it is excluded from this category. ```java List getBannedRules(); ``` -------------------------------- ### Set Buyer with Player Reference Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Records the buyer of the item using a live Player object. This is typically used when the purchase is made by an online player. ```java void setBuyer(Player player); ``` -------------------------------- ### getPriceFormat() Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves the price formatting configuration for the economy. ```APIDOC ## getPriceFormat() ### Description Retrieves the price formatting configuration for the economy. ### Method ```java PriceFormat getPriceFormat() ``` ### Returns - **PriceFormat** — Configuration for formatting prices in this economy. Contains: - `format: String` — Format template - `decimalPlaces: int` — Decimal precision - `useReductions: boolean` — Apply K/M/B suffixes ``` -------------------------------- ### Calculate Purchase Tax Method Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/types.md Calculates the tax for a purchase transaction. Requires player, price, and item stack information. ```java TaxResult calculatePurchaseTax(Player player, BigDecimal price, ItemStack itemStack); ``` -------------------------------- ### Get Items with Predicate Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieves items from a specified storage type and filters them using a predicate. Filtering is performed synchronously. ```java List getItems(StorageType storageType, Predicate predicate); ``` ```java // Get all items from a specific seller List sellerItems = manager.getItems(StorageType.LISTED, item -> item.getSellerUniqueId().equals(playerId)); ``` -------------------------------- ### Tax Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Configure various taxes including sell tax, purchase tax, and VAT. Define tax types (FLAT/PERCENTAGE) and amounts, with support for permission-based reductions. ```yaml tax: # Tax deducted when listing items sell-tax: enabled: true type: "FLAT" # FLAT or PERCENTAGE amount: "10" # If PERCENTAGE: amount out of 100 # If FLAT: fixed currency amount # Tax deducted from buyer (capitalism style) purchase-tax: enabled: false type: "PERCENTAGE" amount: "5" # Tax deducted from seller proceeds (VAT) vat-tax: enabled: false type: "PERCENTAGE" amount: "10" # Permission-based tax reductions reductions: "zauctionhouse.tax-reduction.50": 50 # 50% reduction "zauctionhouse.tax-reduction.exempt": 0 # No tax ``` -------------------------------- ### Get Withdrawal Reason Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves the standard reason text used for logging withdrawal transactions, ensuring consistency in records. ```java String getWithdrawReason(); ``` -------------------------------- ### Get Deposit Reason Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Retrieves the standard reason text used for logging deposit transactions, ensuring consistency in records. ```java String getDepositReason(); ``` -------------------------------- ### registerEconomy(AuctionEconomy) Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Registers a custom economy provider with the system. Returns true if successful, false if the economy name already exists. ```APIDOC ## registerEconomy(AuctionEconomy) ### Description Registers a custom economy provider with the system. ### Method ```java boolean registerEconomy(AuctionEconomy economy) ``` ### Parameters #### Path Parameters - **economy** (AuctionEconomy) - Yes - Economy to register ### Returns - **boolean** — True if registered, false if name already exists. ``` -------------------------------- ### Get Player Balance Asynchronously Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/economy.md Asynchronously retrieves a player's current balance as a BigDecimal. This method returns a CompletableFuture. ```java CompletableFuture get(UUID playerId); ``` -------------------------------- ### Get Buyer Unique ID Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Retrieves the unique identifier of the buyer who purchased the item. Returns null if the item has not been purchased. ```java UUID getBuyerUniqueId(); ``` -------------------------------- ### Register Custom Economy Implementation Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Register a custom economy implementation with the EconomyManager. Ensure the custom economy class is properly instantiated. ```java AuctionEconomy custom = new CustomEconomy(/* ... */); auctionHouse.getEconomyManager().registerEconomy(custom); ``` -------------------------------- ### Get Formatted Expiration Date Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/item.md Returns the expiration date formatted according to the plugin's date format configuration. ```java String getFormattedExpireDate(); ``` -------------------------------- ### Enable Debug Logging Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/README.md Enables detailed debug logging for performance monitoring. Set 'profile-methods' to true to profile method execution, but be aware of potential performance impacts. ```yaml performance: debug: enabled: true log-operations: true profile-methods: false # May impact performance ``` -------------------------------- ### Preventing Sales Based on Price Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/events.md Example of an event listener that cancels a sale if the item's price exceeds a specified limit. ```java @EventHandler public void blockExpensiveItems(AuctionPreSellEvent event) { if (event.getPrice().compareTo(BigDecimal.valueOf(1000000)) > 0) { event.setCancelled(true); plugin.sendMessage(event.getPlayer(), MyMessages.PRICE_LIMIT); } } ``` -------------------------------- ### Per-Item Tax Rules Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Configure taxes based on item price, type, or player permissions. Supports percentage and flat amounts. ```yaml tax: rules: expensive-items: condition: "price > 100000" tax-type: "VAT" amount-type: "PERCENTAGE" amount: 15 # 15% tax for expensive items certain-items: condition: "item_type == DIAMOND" tax-type: "SELL" amount-type: "FLAT" amount: 50 vip-reduction: condition: "has_permission zauctionhouse.tax-reduction.50" reduction: 50 # 50% off all taxes ``` -------------------------------- ### NBT_TAG Rule Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/category-rules.md Example configurations for NBT_TAG rules. One checks for the existence of 'Enchantments', another for a specific 'CustomModelData' value. ```yaml rules: - type: "NBT_TAG" tag: "Enchantments" # Any enchanted item - type: "NBT_TAG" tag: "CustomModelData" value: 12345 # Specific custom model data ``` -------------------------------- ### Plugin Features Configuration Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/configuration.md Enable and configure various plugin features including cluster synchronization, performance optimizations, sales notifications, item expiration, and Discord webhooks. ```yaml features: # Cluster synchronization cluster: enabled: false bridge: "default" # "default" or custom implementation redis: host: "localhost" port: 6379 password: "" # Performance performance: cache-sorted-items: true lazy-load-items: true update-interval: 1000 # ms # Notifications sales-notifications: enabled: true show-offline: true max-history: 100 # Expiration expiration: enabled: true default-duration: 604800 # 7 days in seconds check-interval: 300 # seconds extend-command: true # Discord Webhooks discord: enabled: false webhook-url: "https://discordapp.com/api/webhooks/..." embed-color: "#FFD700" ``` -------------------------------- ### Import AuctionPlugin Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-plugin.md Import the AuctionPlugin class to use its functionalities. ```java import fr.maxlego08.zauctionhouse.api.AuctionPlugin; ``` -------------------------------- ### Open Main Auction Interface Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Use `openMainAuction(Player)` to open the main auction house inventory for a player. This method respects the player's current sort order and category filter preferences. ```java void openMainAuction(Player player); ``` ```java AuctionManager manager = plugin.getAuctionManager(); manager.openMainAuction(player); ``` -------------------------------- ### Import AuctionOptionService Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/services.md Import statement for the AuctionOptionService. ```java import fr.maxlego08.zauctionhouse.api.services.AuctionOptionService; ``` -------------------------------- ### Get Player Cache Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieves or initializes the cache entry associated with the given player. This provides quick access to player metadata. ```java PlayerCache getCache(Player player); ``` -------------------------------- ### Get Purchased Items by UUID Source: https://github.com/groupez-dev/zauctionhouse/blob/main/_autodocs/api-reference/auction-manager.md Retrieves purchased items using a player's UUID. This version supports offline players. ```java List getPurchasedItems(UUID uniqueId); ```