Developer API
Query plots from your own plugin and register custom chest-shop cleanup providers.
AT-ShoppingMall exposes a small public API so other plugins can read plot data (owner, tenant, status, region bounds) and plug in cleanup for shop plugins it doesn't support out of the box.
The API lives in the cc.arrowtan.aTShoppingMall.api package. Compile against the
AT-ShoppingMall jar (scope it provided / compileOnly). Don't shade it.
Getting the API
Soft-depend on the plugin
So your plugin loads after AT-ShoppingMall, add it to your plugin.yml:
softdepend: [AT-ShoppingMall]Grab it from the services manager
The plugin registers ShoppingMallAPI with Bukkit's services manager on enable.
import cc.arrowtan.aTShoppingMall.api.ShoppingMallAPI;
import org.bukkit.plugin.RegisteredServiceProvider;
ShoppingMallAPI api = null;
RegisteredServiceProvider<ShoppingMallAPI> rsp =
getServer().getServicesManager().getRegistration(ShoppingMallAPI.class);
if (rsp != null) {
api = rsp.getProvider();
}Use it
A null registration means AT-ShoppingMall isn't installed, so guard for it. Query methods
return null for an unknown plot id.
if (api != null && api.isRented("shop1")) {
UUID tenant = api.getTenant("shop1");
getLogger().info("shop1 is rented by " + tenant);
}Query methods
| Method | Returns |
|---|---|
isPlot(String id) | true if a plot with that id exists. |
getPlot(String id) | The Plot, or null if unknown. |
getPlots() | All plots on the server. |
getOwner(String id) | Owner UUID (or null). |
getTenant(String id) | Tenant UUID (or null). |
getRegion(String id) | The plot's PlotRegion (world + bounding box). |
getStatus(String id) | Status name: AVAILABLE, RENTED, PURCHASED, or UNAVAILABLE. |
isRented(String id) | true if the plot is currently rented. |
A PlotRegion gives you the world and bounds: getWorld(), getWorldName(),
getMinX()…getMaxZ(), plus getCenter() and getEntrance() locations.
Custom shop cleanup providers
When a plot is reset or a tenant is evicted, AT-ShoppingMall asks every registered
ChestShopProvider to delete shops inside the plot bounds. The built-in QuickShop hook
is the reference implementation. Ship your own to support ChestShop, EconomyShopGUI,
ShopChest, and others without modifying this plugin.
Implement three methods:
import cc.arrowtan.aTShoppingMall.api.ChestShopProvider;
import cc.arrowtan.aTShoppingMall.models.PlotRegion;
public class MyShopProvider implements ChestShopProvider {
@Override
public String getName() {
return "MyShopPlugin";
}
@Override
public boolean isAvailable() {
return getServer().getPluginManager().getPlugin("MyShopPlugin") != null;
}
@Override
public int deleteShopsInRegion(PlotRegion region) {
// Remove every shop inside the bounding box. Called on the main thread.
// Return the number of shops deleted.
return 0;
}
}Register it once AT-ShoppingMall is up (e.g. in your onEnable, after fetching the API):
api.registerShopProvider(new MyShopProvider());deleteShopsInRegion is always called on the main server thread. Don't block it: do
any heavy lookups cheaply, and never call it yourself off-thread.
| Method | Purpose |
|---|---|
getName() | Human-readable name of the shop plugin (e.g. "QuickShop"). |
isAvailable() | Whether the backing shop plugin is installed and ready right now. |
deleteShopsInRegion(PlotRegion) | Delete all shops in the region; return how many were removed. |
Manage registrations with registerShopProvider(provider),
unregisterShopProvider(provider), and getShopProviders().