Shop Developer Wiki

Aug 21, 2020
Shop Developer Wiki
  • (back to main page)

    Hooking into Shop:
    Add Shop as a soft depend in the plugin.yml of your plugin
    Code (yml (Unknown Language)):

    name: ExamplePlugin
    author: SnowGears
    softdepend: [Shop]

    Get an instance of the plugin
    Code (Java):

    private Shop getShop() {
        Plugin plugin = getServer().getPluginManager().getPlugin("Shop");
        // Shop may not be loaded
        if (plugin == null || !(plugin instanceof Shop)) {
            return null; // Maybe you want throw an exception instead
        return (Shop) plugin;

    Events you can listen for:

    PlayerCreateShopEvent - called when a player creates a shop

    PlayerInitializeShopEvent - called when a player initializes shop with an item
    PlayerDestroyShopEvent - called when a player destroys a shop
    PlayerExchangeShopEvent - called when a player performs a transaction with a shop
    PlayerResizeShopEvent - called when a player resizes a shop chest

    Code (Java):

    //set the shop items to meat if the player is too hungry
    public void onShopInitialize(PlayerInitializeShopEvent event){
        if(event.getPlayer().getFoodLevel() < 5){
            event.getShop().setItemStack(new ItemStack(Material.COOKED_BEEF));
            event.getPlayer().sendMessage("You are too hungry! The shop item has been set to meat!");
    Code (Java):

    //only allow players to break shops if they are holding an iron axe in their main hand
    public void onShopDestroy(PlayerDestroyShopEvent event){
        if(event.getPlayer().getItemInHand().getType() != Material.IRON_AXE){
            event.getPlayer().sendMessage("You must break shop signs with an Iron Axe!");
    Code (Java):

    //check if an entity (like an ArmorStand or an Item on the ground) is a Shop Display
    //this is good if plugins want to ensure that their plugin does not force wipe shop display items
    public void wipeEntitiesInRegion(){
        Shop shopPlugin = getShop();
        //get all entities in region
        //for all entities in list
            //only remove the entity if it is not a Shop display

  • Loading...
  • Loading...