Shop System

Create a comprehensive shop system where players can buy items, tools, and resources using in-game currency or items.

Basic Item Shop

Create simple item purchases:

/cmd add buy_diamond give ${player} diamond 1 && tellraw ${player} {"text":"Bought 1 diamond!","color":"green"}
/cmd add buy_sword give ${player} diamond_sword 1 && tellraw ${player} {"text":"Bought diamond sword!","color":"green"}

Custom Syntax Shop

// In syntax.json
{
  "buy": {
    "pattern": "/buy  ",
    "description": "Buy items from the shop"
  }
}

// In aliases.json
{
  "buy_diamond": "give ${player} diamond ${buy_amount} && tellraw ${player} {\"text\":\"Bought ${buy_amount} diamonds!\",\"color\":\"green\"}",
  "buy_emerald": "give ${player} emerald ${buy_amount} && tellraw ${player} {\"text\":\"Bought ${buy_amount} emeralds!\",\"color\":\"green\"}"
}

Economy Integration

Integrate with an economy system:

/cmd add buy_diamond execute if score @s money matches 10.. run give @s diamond 1 && scoreboard players remove @s money 10 && tellraw @s {"text":"Bought diamond for 10 coins!","color":"green"} || tellraw @s {"text":"Not enough coins!","color":"red"}

Shop GUI (Advanced)

Use functions for complex shop interfaces:

// Create shop.mcfunction
tellraw @s {"text":"=== SHOP ===","color":"gold"}
tellraw @s ["",{"text":"[Buy Diamond - 5 coins]","color":"green","clickEvent":{"action":"run_command","value":"/buy_diamond"}}]
tellraw @s ["",{"text":"[Buy Sword - 20 coins]","color":"green","clickEvent":{"action":"run_command","value":"/buy_sword"}}]