Economy System
Learn how to integrate shops with virtual currency.
Create a comprehensive shop system where players can buy items, tools, and resources using in-game currency or items.
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"}
// 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\"}"
}
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"}
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"}}]
Learn how to integrate shops with virtual currency.
Create dynamic shop commands with parameters.
Style your shop messages and confirmations.