Seems to me that the only thing you need is a simple scoreboard setup. Add a money objective and then use this for other interactions. I definitely wouldn't use
/trigger because that way players might be able to cheat.
- /scoreboard objectives add money dummy "Player credits"
- /scoreboard objectives setdisplay sidebar money
Now we have a money system set up. Let's give all players 100 credits:
- /scoreboard players add @a money 100
Now you'll probably also finally see the sidebar popping up (it doesn't show unless there's actually something to display).
So now what... allow players to buy stuff? Let's sell an Acacia boat for 5 credits. You're going to need a series of command blocks to pull this off:
Buying a boat
Normal command blockexecute if entity @p[scores={money=5..}] as @p run give @s minecraft:acacia_boatChain conditional command block (always active)scoreboard players remove @p money 5So when a player clicks on the button to buy an acacia boat they'll trigger this command block sequence which will give them a boat and subtract 5 cash
if they have 5 (or more) cash on them. Although this setup works it's not ideal: I'd probably tag the player first and then only work with the tagged player (eventually also removing the tag). Takes up more command blocks though.
Selling a boat
Basically the reverse of what we did before. Of course in true economic fashion we'll sell for more than we buy. So lets say we'll buy the boat back for 3 credits. Now we need to check that the player actually has the item in their inventory before removing it and giving them their 3 credits...
Normal command blockexecute if entity @p[nbt={Inventory:{id:"minecraft:acacia_boat",Count:1b}]}] as @p run clear @s minecraft:acacia_boat 1Chain conditional command block (always active)scoreboard players add @p money 3So now players can also sell a boat for 3 credits at the local server shop :)
As you can see you really don't really need a datapack for this, all you need is to create a scoreboard objective and then set up the right commands in your world to facilitate buying and selling. Of course the downside here is that these features are server-sided only. As in: only an operator can set up this stuff.
Anything beyond this (players selling to players for example) should be handled by a mod, not a datapack.