Promotion background
Halloween Season IS HERE!
10% off limited time offer!
limited time offer SAVE 10% NOW →

Build your own Phoenix Shop add-on

Premium API

Write add-ons that PhoenixShop loads from its addons folder, and listen to shop and chest shop events, including changing the price before a buy or sell. Custom add-ons load on Premium only; the shop events can be listened to on Lite and Premium.

Setup

Maven, exactly as documented on Custom Add-ons:

XML
<repositories>
  <repository>
    <id>phoenix</id>
    <url>https://repo.phoenixplugins.com/repository/maven-public/</url>
  </repository>
</repositories>
XML
<dependency>
  <groupId>com.phoenixplugins.sdk</groupId>
  <artifactId>api</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>com.phoenixplugins.phoenixshop</groupId>
  <artifactId>api</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>

Relocation

The PhoenixShop jar relocates the SDK, so your add-on has to point at the same package or it will not find the base class. Add the shade plugin with this relocation, without bundling anything:

XML
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>shade</goal>
      </goals>
      <configuration>
        <artifactSet>
          <includes>
            <include>${project.groupId}:${project.artifactId}</include>
          </includes>
        </artifactSet>
        <relocations>
          <relocation>
            <pattern>com.phoenixplugins.sdk</pattern>
            <shadedPattern>com.phoenixplugins.phoenixshop.sdk</shadedPattern>
          </relocation>
        </relocations>
      </configuration>
    </execution>
  </executions>
</plugin>

Gradle

The docs only show Maven snippets; no Gradle snippet is documented yet. Dependency details: see Custom Add-ons.

Add-on structure

addon.yml

Create an addon.yml file in your project resources folder.

YAML
name: AddonName
main: your.path.AddonExample
version: 1.0.0
description: Small description (optional)
color: "#3fb950"
Field Required What it does
name Yes The name of the add-on. Spaces are turned into underscores, and it names the add-on's data folder.
main Yes The full path to your class that extends Addon.
version Yes The version of your add-on.
description No A short description.
color No A hex color for the add-on's name in the console.

Main Class

JAVA
package your.path;

import com.phoenixplugins.phoenixshop.api.PhoenixShopAPI;
import com.phoenixplugins.sdk.api.plugin.addons.Addon;

public class AddonExample extends Addon {

    @Override
    public void init() {
    }

    @Override
    public void load() throws Exception {
    }

    @Override
    public void unload() {
    }

    @Override
    public void reload() throws Exception {
        unload();
        load();
    }

    @Override
    public String getRequiredPluginVersion() {
        return "1.0.0";
    }
}
Method When it runs
init Once, when the jar is read, before the plugin registers its hooks. Throwing here stops the add-on from loading.
load When the plugin starts, and again on every /pshop reload. Register commands, listeners and tasks here.
unload When the plugin stops, and before every reload. Undo everything load did.
reload Not called by the plugin, which runs unload and then load instead. Point it at the same two so the add-on behaves the same either way.
getRequiredPluginVersion The lowest PhoenixShop version the add-on runs on. On an older version it refuses to load.

getDataFolder() returns the add-on's own folder, and getResource(name) reads a file out of your jar, which is how an add-on writes its default config on first start. PhoenixShopAPI.getShopsManager() gives you the shops.

Install

  1. Build the jar with your usual build command.
  2. Move it into the PhoenixShop/addons folder.
  3. Restart the server.
  4. Check the console for Enabling addon followed by your add-on's name.

Source: Custom Add-ons.

Events

7 documented events, from Custom Add-ons. All are Bukkit events, listened to with @EventHandler.

EventFires whenCancellableReference
ShopPreTransactionEvent Before a buy or sell in a shop menu. The price can be changed. Yes Docs
ShopTransactionEvent After a buy or sell in a shop menu went through. No Docs
ShopEditEvent After a change made in the editor. No Docs
PlayerShopCreateEvent When a chest shop is made. No Docs
PlayerShopRemoveEvent When a chest shop is removed. No Docs
PlayerShopPreTradeEvent Before a chest shop trade, once every check has passed and right before money or items move. Yes Docs
PlayerShopTradeEvent After a chest shop trade went through. No Docs

Complete example

The docs don't have a complete example yet.

Registering a listener

The docs don't show listener registration inside an add-on yet.

Configuration

Shop File, verbatim from Shop Configuration File:

YAML
open-command: shop
display-name: '<gradient:#FF9A00:#E52D27>Phoenix Shop</gradient>'
conditions:
  checks:
    vip:
      type: permission
      permission: shop.vip
currency:
  type: VAULT
currency-format: ''
enabled: true
actions:
  buy:
  - '[SOUND] ENTITY_ITEM_PICKUP; 1; 1'
  sell:
  - '[SOUND] ENTITY_EXPERIENCE_ORB_PICKUP; 1; 1'
  deny:
  - '[SOUND] BLOCK_NOTE_BLOCK_BASS; 1; 1'
  click:
  - '[SOUND] UI_BUTTON_CLICK; 0.5; 1'
  next-page:
  - '[SOUND] ITEM_BOOK_PAGE_TURN; 1; 1'
  previous-page:
  - '[SOUND] ITEM_BOOK_PAGE_TURN; 1; 1'
  add:
  - '[SOUND] UI_BUTTON_CLICK; 0.4; 1.4'
  remove:
  - '[SOUND] UI_BUTTON_CLICK; 0.4; 0.8'
  fill:
  - '[SOUND] ITEM_BUNDLE_INSERT; 1; 1'
  back:
  - '[SOUND] ITEM_BOOK_PAGE_TURN; 1; 0.8'

Plain-text docs

For offline reading, scripts and tools, all Phoenix Shop docs are available as one text file. Any docs page can be read as plain markdown by adding .md to its URL.

My Cart
Spider

Your cart is empty

Looks like the spiders padded through here. Pick a plugin and it will show up here. Continue shopping