Post

Bazaar API: First Steps

First, you’ll want to register Bazaar as a dependency of your plugin.
To do that, open the plugin.yml of your plugin, then add Bazaar as a dependency to the depend option.

1
depend: [Bazaar]

To use the api you have to import the Bazaar.jar file to your project. The source code can be found here.

Now, to get the api:

1
2
3
import de.ancash.bazaar.Bazaar;
...
ICoreDAO coreDAO = Bazaar.getAPI();

The return object provides access to all the api functions:

  • ICoreDAO (access to all other DAOs, and more)
  • ITransactionDAO (used to create enquiries and manage instant sell/buy actions)
  • IPlaceholderDAO (not really inteded for third party use, you can still use this to automatically replace placeholders)
  • IStatisticsDAO (provides access to statistics about all recorded transactions)

It does not matter, whether Bazaar is configured to support sockets, or not. However, the plugin is designed to be efficient and fast to support a lot of transaction per time unit and since communication with a remote server can be time consuming, all method calls should be made asynchronously. All methods are by design thread safe, hence it’s possible for a method call to have to wait until another method call finishes (thus making all calls possibly blocking).

This post is licensed under CC BY 4.0 by the author.