#
Developer API
You can import ExcellentShop to your project using Maven. Replace {VERSION}
with the latest version below:
<repository>
<id>nightexpress-releases</id>
<url>https://repo.nightexpressdev.com/releases</url>
</repository>
<dependency>
<groupId>su.nightexpress.excellentshop</groupId>
<artifactId>ExcellentShop-spigot</artifactId>
<version>{VERSION}</version>
</dependency>
#
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 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);