API interface for interacting with EssentialsC's shop system. The shop system provides GUI-based buying and selling with category organization, stock management, and transaction logging to SQLite.
Retrieve an instance via EssentialsCAPI.getShopApi().
ShopApi shop = APIProvider.getAPI().getShopApi();
shop.getCategory("farming").ifPresent(cat -> {
player.sendMessage("Category: " + cat.displayName());
});
The ShopCategoryEntry and ShopItemEntry records live in the
net.godlycow.org.essc.api.shop sub-package.
Method Summary
| boolean |
isEnabled() Returns whether the shop system is globally enabled. |
| List<String> |
getCategoryIds() Returns a list of all loaded category IDs. |
| Optional<ShopCategoryEntry> |
getCategory(String id) Returns the category with the given ID, if it exists and is enabled. |
| List<ShopCategoryEntry> |
getAllCategories() Returns all loaded categories. |
| Optional<ShopItemEntry> |
getItem(String categoryId, String itemId) Returns the item from the specified category and item ID. |
| List<ShopItemEntry> |
getItemsInCategory(String categoryId) Returns all items in the specified category. |
| void |
openMainShop(Player player) Opens the main shop menu for the given player. |
| void |
openCategory(Player player, String categoryId, int page) Opens a specific category page for the given player. |
| CompletableFuture<Boolean> |
purchase(Player player, String itemId, int amount) Processes a purchase for the given player (async). |
| CompletableFuture<Boolean> |
sell(Player player, String itemId, int amount) Processes a sale for the given player (async). |
| void |
reload() Reloads all shop configuration from disk. |
Returns whether the shop system is globally enabled.
Returns:| boolean | true if shops are enabled in config |
Returns a list of all loaded category IDs.
Returns:| List<String> | an unmodifiable list of category IDs; never null |
Returns the category with the given ID, if it exists and is enabled.
Parameters:| id | the category ID; must not be null |
| Optional<ShopCategoryEntry> | an Optional containing the category, or empty if not found |
Returns all loaded categories.
Returns:| List<ShopCategoryEntry> | an unmodifiable list of categories; never null |
Returns the item from the specified category and item ID.
Parameters:| categoryId | the category ID; must not be null |
| itemId | the item ID; must not be null |
| Optional<ShopItemEntry> | an Optional containing the item, or empty if not found |
Returns all items in the specified category.
Parameters:| categoryId | the category ID; must not be null |
| List<ShopItemEntry> | an unmodifiable list of items; never null |
Opens the main shop menu for the given player. Displays all enabled categories the player has permission to view.
| player | the player to open the menu for; must not be null |
Opens a specific category page for the given player.
| player | the player to open the menu for; must not be null |
| categoryId | the category ID to open; must not be null |
| page | the page number to open (1-based) |
Processes a purchase for the given player. Checks permissions, stock, inventory space, and balance before completing the transaction. Sends appropriate messages to the player.
| player | the player buying the item; must not be null |
| itemId | the item ID to purchase; must not be null |
| amount | the amount to purchase; must be positive |
| CompletableFuture<Boolean> | a future resolving to true if the purchase was successful |
Processes a sale for the given player. Checks inventory for matching items before completing the transaction. Sends appropriate messages to the player.
| player | the player selling the item; must not be null |
| itemId | the item ID to sell; must not be null |
| amount | the amount to sell; must be positive |
| CompletableFuture<Boolean> | a future resolving to true if the sale was successful |
Reloads all shop configuration from disk. Re-reads main.yml and all category files, clearing and rebuilding the category cache. This is equivalent to /shop reload.