Develop Guide

Please note that UltimateShop is not a traditional shop plugin. It can dynamically display products and prices (and even the each single price amount), unlike other shop plugins where one ItemStack corresponds to one price.

Get shop object

ConfigManager.configmanager.shopConfigs.get(shopID);

Get product object

ObjectShop shop = ConfigManager.configmanager.shopConfigs.get(shopID);
if (shop == null) {
  return;
}
ObjectItem item = shop.getProduct("TEST");
List<ObjectItem> items = shop.getProductList();

Start buy a product

BuyProductMethod.startBuy(Inventory inventory, String shop, String product, Player player, boolean quick, boolean test, int multi);
  • inventory is Bukkit inventory object, for player's inventory, use player.getInventory() method.

  • shop is shop ID.

  • product is product ID.

  • quick is whether send message after buy (will still send if you enable send-message-after-buy option in config.yml)

  • test is whether take money or items from player, set it to true if you just want to know whether player has enough money or items.

  • multi is buy amount in one time, default set to 1.

Start sell a product

SellProductMethod.startSell(Inventory inventory, String shop, String product, Player player, boolean quick, boolean test, boolean ableMaxSell, int multi);
  • ableMaxSell is whether if player don't have enough money or items for now multi(amount) value, we will try to get max amount that player able to sell. Use for sell all command.

Get player cache object

CacheManager.cacheManager.playerCacheMap.get(player);

Can get player's buy times, sell times data and so on.

Get server cache object

CacheManager.cacheManager.serverCache;

Get price from ItemStack

ShopHelper.getBuyPrices(items, player, 1);
ShopHelper.getSellPrices(items, player, 1);

Get whether the price is Vault

All price/product configs follows EconomyFormat or ItemFormat.

Map<AbstractSingleThing, BigDecimal> resultMap = takeResult.getResultMap();
for (AbstractSingleThing singleThing : resultMap.keySet()) {
   if (singleThing.getSingleSection().getString("economy-plugin", "").equals("Vault") {
       return "This price includes Vault";
   }
}

Give GiveResult

This will not follow buy/sell limits, conditions check and so on. If you want to plugin check out whether player can buy or sell this item, you need use BuyProductMethod or SellProductMethod.

int sellUseTimes = ShopHelper.getSellUseTimes(item, player);
GiveResult giveResult = ShopHelper.getSellPrices(items, player, 1);
giveResult.give(sellUseTimes, 1, player, 1.01);

Take TakeResult

This will not follow buy/sell limits, conditions check and so on. If you want to plugin check out whether player can buy or sell this item, you need use BuyProductMethod or SellProductMethod.

int buyUseTimes = ShopHelper.getBuyUseTimes(item, player);
TakeResult takeResult = ShopHelper.getBuyPrices(items, player, 1);
if (!takeResult.getResultBoolean) return "Your money not enough";
takeResult.take(sellUseTimes, 1, player.getInventory(), player);

Get TakeResult from which product

ObjectItem item = takeResult.getThings().getItem();

Last updated