ExcellentShop
  • 🏠 General
    • 🔌 Getting Started
    • 📄 Commands
    • ⛔ Permissions
    • 🧩 Compatibility
    • ❓ Common Questions
    • ❗ Common Issues
    • 🪛 Developer API
  • ⭐ Features
    • 🪙 Multi-Currency
    • 🧮 Price Types
    • 📤 Product Stock
    • 🎭 Purchase GUI
  • 💻 Virtual Shop
    • 🔨 Creating Shop
    • 🔗 Shops GUI
    • 🛒 Shop Types
    • 📦 Product Types
    • 🎨 Shop Layouts
  • 📦 Chest Shop
    • 🪓 Creating Shop
    • 🚚 Infinite Storage
  • 🧰 Utility
    • Placeholders
Powered by GitBook
On this page
  • Global Events
  • Virtual Shop
  • Chest Shop
  1. 🏠 General

🪛 Developer API

Global Events

ShopTransactionEvent

Called when player purchases or sells an item in a shop.

The event is not cancellable, however you can cancel the transaction itself (make sure to send custom error message):

event.getTransaction().setResult(Transaction.Result.FAILURE);

To determine which shop is used in transaction, you can use instanceof:

event.getShop() instanceof VirtualShop // Virtual Shop transaction.
event.getShop() instanceof ChestShop // Chest Shop transaction.

Virtual Shop

Get module instance:

VirtualShopModule module = ShopAPI.getVirtualShop()
if (module != null) {
  // Do something.
  // This may return null if module is disabled in the config.
}

Get shop by ID:

StaticShop staticShop = module.getStaticShopById(id); // Search for static shops only.
RotatingShop rotatingShop = module.getRotatingShopById(id); // Search for rotating shops only.
VirtualShop shop = module.getShopById(id); // Search for all, static and rotating, shops.

Get product by ItemStack:

Get the most profitable product for purchase for the given ItemStack:

VirtualProduct product = module.getBestProductFor(player, item, TradeType.BUY);

Get the most profitable product for selling for the given ItemStack:

VirtualProduct product = module.getBestProductFor(player, item, TradeType.SELL);

This method does not includes products that can not be bought or sold by given player.

Chest Shop

ChestShopCreateEvent

Called when player is about to create a new chest shop. Cancellable.

ChestShopRemoveEvent

Called when player is about to remove a chest shop. Cancellable.

Get module instance:

ChestShopModule module = ShopAPI.getChestShop()
if (module != null) {
  // Do something.
  // This may return null if module is disabled in the config.
}

Get all shops:

Collection<ChestShop> shops = module.getShops();

Get shops created by a player:

Set<ChestShop> shops = module.getShops(player);

Get shop by block or location:

ChestShop shop = module.getShop(block);
ChestShop shop = module.getShop(location);

Last updated 11 months ago