-
Notifications
You must be signed in to change notification settings - Fork 0
API Document
TRCStudioDean edited this page Sep 20, 2025
·
7 revisions
This document mainly introduces the usage of APIs in the open part of the plugin jar.
Package: studio.trc.bukkit.globalmarketplus.api
Conventional
studio.trc.bukkit.globalmarketplus.api
Events
studio.trc.bukkit.globalmarketplus.api.event
-
AddItemEvent- Triggered when the plugin gives item to the player's inventory. -
AuctionBidEvent- Triggered when a player bids for a auction. -
AuctionEndEvent- Triggered upon auction completion or closure. -
AuctionStartEvent- Triggered when a player start an auction. -
MailboxDataLoadedEvent- Triggered when loading mailbox data. -
MailPickupEvent- Triggered when picking up mails. -
MerchandiseBuyEvent- Triggered when putting purchasing type's merchandise on the market. -
MerchandiseSellEvent- Triggered when putting selling type's merchandise on the market. -
MerchantDataLoadedEvent- Triggered when loading merchant data. -
NewMailEvent- Triggered when sending an mail. -
ProcessMerchantNoticesEvent- Triggered when processing player notifications. (offline transaction notifications) -
ProcessMerchantTasksEvent- Triggered when processing player tasks. (offline transaction money given) -
TransactionEvent- Triggered when a player makes a transaction. -
TransactionResultEvent- Triggered after player transaction.
studio.trc.bukkit.globalmarketplus.api.GlobalMarket:
- Use
GlobalMarket.getGlobalMarket()to get instance.
/**
* Reload market data.
*/
public void reloadMarket();
/**
* Save market data.
*/
public void saveMarket();
/**
* Perform self inspection on all merchandises (filter out all expired merchandises)
*/
public void checkMerchandises();
/**
* Get amount of merchandises
* @return
*/
public int getAmountOfMerchandises();
/**
* Get amount of merchandises of target merchant.
* @param uuid Merchant's UUID
* @return
*/
public int getAmountOfMerchandises(UUID uuid);
/**
* Generate a new UID.
* @return
*/
public long makeUID();
/**
* Save a merchandise's data.
* @param uid Merchandise's UID
* @param newKey
* @return
*/
public boolean saveMerchandise(long uid, String newKey);
/**
* Remove a merchandise
* @param uid Merchandise's UID
* @return Whether successful
*/
public boolean removeMerchandise(long uid);
/**
* Remove all merchandise
* @return Whether successful
*/
public boolean removeAllMerchandises();
/**
* Download merchandise data to local directory
* @param file File instance
* @param uid Merchandise's UID
* @return Whether successful
*/
public boolean download(File file, long uid);
/**
* Upload merchandise data to local directory
* @param json Merchandise's meta data (JSON)
* @param rewrite When the merchandise does not exist, should it be rewritten to enter the database.
* @return Whether successful
*/
public boolean upload(JSONObject json, boolean rewrite);
/**
* Add a new merchandise(instance) to global market.
* @param merchandise
* @return
*/
public boolean addMerchandise(Merchandise merchandise);
/**
* Add a new merchandise into global market.
* @param ownerUUID Merchandise owner's UUID
* @param ownerName Merchandise owner's name
* @param item ItemStack instance
* @param merchandiseType Merchandise's type
* @param uploadTime System milliseconds of upload time
* @param expireTime System milliseconds of expire time
* @param price Price/Deposit
* @param currency Currency unit
* @param taxed Taxed amount
* @param isRetail Whether is retail
* @return Merchandise instance
*/
public Merchandise addMerchandise(UUID ownerUUID, String ownerName, ItemStack item, MerchandiseType merchandiseType, long uploadTime, long expireTime, double price, GlobalMarketEconomy currency, double taxed, boolean isRetail);
/**
* Add a new auction into global market.
* @param ownerUUID Merchandise owner's UUID
* @param ownerName Merchandise owner's name
* @param item ItemStack instance
* @param merchandiseType Merchandise's type
* @param uploadTime System milliseconds of upload time
* @param expireTime System milliseconds of expire time
* @param price Price/Deposit
* @param currency Currency unit
* @param taxed Taxed amount
* @return Auction instance
*/
public Auction addAuction(UUID ownerUUID, String ownerName, ItemStack item, MerchandiseType merchandiseType, long uploadTime, long expireTime, double price, GlobalMarketEconomy currency, double taxed);
/**
* Get merchandise by UID.
* @param uid
* @return
*/
public Merchandise getMerchandise(long uid);
/**
* Get MerchantStore instance.
* @param merchant
* @return
*/
public MerchantStore getMerchantStore(Merchant merchant);
/**
* Get all MerchantStore instances.
* @return
*/
public List<MerchantStore> getMerchantStores();
/**
* Get all Merchandise instances.
* @return
*/
public List<Merchandise> getMerchandises();
/**
* Get all Merchandise instances of a target player.
* @param uuid Player's UUID
* @return
*/
public List<Merchandise> getMerchandises(UUID uuid);
/**
* Get all Merchandise instances.
* @param filter
* @return
*/
public List<Merchandise> getMerchandises(Predicate<Merchandise> filter);
/**
* Get all Merchandise instances.
* @return
*/
public Map<Long, Merchandise> getMerchandisesWithUID();studio.trc.bukkit.globalmarketplus.api.Mailbox
- Use Mailbox.getMailbox() to get instance.
/**
* Reload mailbox data.
*/
public void reloadMail();
/**
* Perform self inspection on all mails (filter out all expired mails)
*/
public void checkMails();
/**
* Remove mail by UIDs
* @param mailUID
*/
public void removeMail(long... mailUID);
/**
* Generate a new UID.
* @return
*/
public long makeMailUID();
/**
* Save mailbox data.
* @param newKey
* @return Whether successful
*/
public boolean saveMail(String newKey);
/**
* Download mailbox data to local directory.
* @param file File instance
* @return Whether successful
*/
public boolean download(File file);
/**
* @return
*/
public UUID getOwnerUUID();
/**
* @return
*/
public String getKey();
/**
* @return
*/
public String getOwnerName();
/**
* Add a new mail.
* @param ownerUUID Mail receiver's UUID
* @param ownerName Mail receiver's Name
* @param mailType Mail's type
* @param sendingTime System milliseconds of sending time
* @param expireTime System milliseconds of expire time
* @param item ItemStack instance
* @return ItemMail instance
*/
public ItemMail addMail(UUID ownerUUID, String ownerName, ItemMailType mailType, long sendingTime, long expireTime, ItemStack item);
/**
* Add a new mail.
* @param ownerUUID Mail receiver's UUID
* @param ownerName Mail receiver's Name
* @param mailType Mail's type
* @param sendingTime System milliseconds of sending time
* @param expireTime System milliseconds of expire time
* @param item ItemStack instance
* @param senderUUID Mail sender's UUID
* @param senderName Mail sender's name
* @return ItemMail instance
*/
public ItemMail addMail(UUID ownerUUID, String ownerName, ItemMailType mailType, long sendingTime, long expireTime, ItemStack item, UUID senderUUID, String senderName);
/**
* Add a new mail.
* @param ownerUUID Mail receiver's UUID
* @param ownerName Mail receiver's Name
* @param mailType Mail's type
* @param sendingTime System milliseconds of sending time
* @param expireTime System milliseconds of expire time
* @param item ItemStack instance
* @param senderUUID Mail sender's UUID
* @param senderName Mail sender's name
* @param amount Amount of ItemStack
* @return ItemMail instance
*/
public ItemMail addMail(UUID ownerUUID, String ownerName, ItemMailType mailType, long sendingTime, long expireTime, ItemStack item, UUID senderUUID, String senderName, int amount);
/**
* Get mail instance by UID
* @param uid
* @return
*/
public ItemMail getItemMail(long uid);
/**
* Get all mail instances
* @return
*/
public List<ItemMail> getItemMails();
studio.trc.bukkit.globalmarketplus.api.Merchant
- Use Merchant.getMerchant() to get instance.
/**
* Reload merchant data.
*/
public void reloadData();
/**
* Refresh merchant data.
*/
public void refreshData();
/**
* Set merchant's balance of Default(UnitName) currency
* @param money
*/
public void setDefaultBalance(double money);
/**
* Get merchant's balance of Default(UnitName) currency
* @return
*/
public double getDefaultBalance();
/**
* Get merchant's balance by designated currency unit.
* @param currency
* @return
*/
public double getBalance(GlobalMarketEconomy currency);
/**
* Set merchant balance in the specified currency unit.
* @param currency
* @param money
* @param recordType
* @param trader
* @param addtional
* @return
*/
public boolean setBalance(GlobalMarketEconomy currency, double money, BalanceChangeType recordType, Merchant trader, String addtional);
/**
* Save merchant's data.
* @param newKey
* @return Whether successful
*/
public boolean saveData(String newKey);
/**
* Download mailbox data to local directory.
* @param file File instance
* @return Whether successful
*/
public boolean download(File file);
/**
* @return
*/
public boolean isExecutingTasks();
/**
* @return
*/
public UUID getPlayerUUID();
/**
* @return
*/
public String getKey();
/**
* @return
*/
public String getPlayerName();
/**
* @return
*/
public Player getPlayer();
/**
* @return
*/
public Mailbox getMailbox();
/**
* @return
*/
public MerchantCache getCache();
/**
* @return
*/
public MerchantProfile getProfile();
/**
* @return
*/
public MerchantStore getStore();
/**
* @return
*/
public MerchantGroup getGroup();
/**
* @return
*/
public JSONObject serialize();
/**
* Get all merchandises of merchant.
* @return
*/
public List<Merchandise> getMerchandises();
/**
* Get all merchandises of merchant by specific type.
* @param merchandiseType
* @return
*/
public List<Merchandise> getMerchandises(MerchandiseType merchandiseType);
studio.trc.bukkit.globalmarketplus.api.APIUtils
/**
* Check if the specified ItemStack instance is on the market blacklist
* @param sender Player (command sender), used to detect if there is permission to bypass the blacklist
* @param item
* @return
*/
public static boolean checkItemInGlobalMarketBlacklist(CommandSender sender, ItemStack item);
/**
* Check if the specified ItemStack instance is on the mailbox blacklist
* @param sender Player (command sender), used to detect if there is permission to bypass the blacklist
* @param item
* @return
*/
public static boolean checkItemInMailboxBlacklist(CommandSender sender, ItemStack item);
/**
* Get an instance of the category to which the item belongs.
* @param item
* @return
*/
public static Category getCategory(ItemStack item);
/**
* Get an instance of the category to which the mail belongs.
* @param mail
* @return
*/
public static Category getCategory(ItemMail mail);
/**
* Get an instance of the category to which the merchandise belongs.
* @param merchandise
* @return
*/
public static Category getCategory(Merchandise merchandise);
/**
* Check if price over limit
* @param merchandiseType Merchandise's type
* @param group Merchant user group, use Merchant.getMerchant(Player player).getMerchantGroup() to get the group of the specified player
* @param currencyUnit Currency unit
* @param price Price/Deposit
* @return
*/
public static boolean checkPriceOverLimit(MerchandiseType merchandiseType, MerchantGroup group, GlobalMarketEconomy currencyUnit, double price);
/**
* Get configuration for specified file name
* @param configFileName Configuration file name
* @return YamlConfiguration instance
*/
public static YamlConfiguration getConfig(String configFileName);
/**
* Get the item blacklist
* @return
*/
public static Map<String, ItemStack> getBlacklistItems();
/**
* Get the item collection
* @return
*/
public static Map<String, ItemStack> getItemCollection();