Skip to content

TradeShop Addon Framework

KillerOfPie edited this page Feb 26, 2022 · 2 revisions

The TradeShop Addon Framework (TSAF) makes it possible to hook into the TradeShop plugin, and develop extra features, commands and shop types, and powers all of our official addons.

To use it, you simply add it to your project using Maven (see below), and consult the api docs (formerly here) for the full documentation.

Setup

To use the TSAF in your project you can handle Maven or Gradle dependencies like so:

Step 1. Add the JitPack repository to your build file

<repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>

Step 2. Add the dependency

<dependencies>
	<dependency>
	    <groupId>com.github.Tradeshop</groupId>
	    <artifactId>TradeShop</artifactId>
	    <version>Tag</version>
	</dependency>
</dependencies>

Note: Tag is a placeholder and should be replaced with the version of TradeShop that you would like to target.

Warning

At this point you are able to access all classes of the TradeShop plugin. However, it is highly recommended that you do not use any of them. Instead, setup listeners so that you can catch the plugin's events as they are fired. You can read live javadocs for the classes belonging to the framework here. You can also see a very short example on how to use the plugin on the wiki.

Example

Here is a small example on how to use it to create a little utility that tells administrators when somebody uses a shop to trade some items:

@EventHandler
public void onTrade(PlayerSuccessfulTradeEvent e) {
    Location loc = e.getClickedBlock().getLocation();
    Bukkit.broadcast(ChatColor.translateAlternateColorCodes('&',
                        String.format("&c%s &6just traded items from &c%s&6's shop at &7%d %d %d&6",
                                       e.getPlayer().getName(), e.getShop().getOwner().getName(), loc.getX(), loc.getY(), loc.getZ())),
                    "tradeshop.admin");
}

Since the class PlayerSuccessfulTradeEvent represents a custom Bukkit event, you have to register the class containing the above listeners just like any normal event listener.

Note: The PlayerSuccessfulTradeEvent event class used to be called just SuccessfulTradeEvent. Old addons might be affected by the change.

Official addons

A curated list of addons officially maintained and supported by the TradeShop Dev Team can be found below. We recommend taking a look at them in order to familiarize yourself with the TSAF. Contributions, bug reports and feature requests for the addons are very welcome, as are suggestions for new addons. Please reach out to us on Discord if you would like to talk.

  • TradeShopARM - Introduces support and fixes incompatibility with the AdvancedRegionMarket plugin. This addon was developed on user request and is open sourced (you can use it for free). You can build it from source by cloning the repository (see link) or download it from GitHub Releases.

  • TradeShopLOG - Introduces logging facilities for trade events. This addon was developed on user request and is open sourced (you can use it for free). You can build it from source by cloning the repository (see link) or download it from GitHub Releases.

Help and support

If you are unsure how to use the TSAF or you think something is not working as it should, please join our Discord server and reach out to us in the #addon-framework-support channel.

Wiki Index

Downloads

  • You may download the latest version here.
  • You may clone the source with the command git clone https://github.com/TradeShop/TradeShop.git
  • You may also clone the whole wiki to your computer with the command git clone https://github.com/TradeShop/TradeShop.wiki.git.

Contact

You may contact the developers for any reason on Discord or on GitHub.

License

The entire project is licensed under the Apache License v2.0.

Clone this wiki locally