This is a fork of the original GUI Shop mod by UnsafeDodo. I adapted it to my requirements and added some features. I'm not planning to provide support (at this time), but feel free to make suggestions or fork it if you want.
A fabric server-side mod to create and manage GUI shops.
They can be later opened by using commands, allowing integration with NPC mods like Taterzens.
The mod supports LuckPerms for permissions.
Put the .jar file in the "mods" folder
(Requires Fabric API and (optionally) a supported Economy)
All commands can be used by admins (permission level 3) or by users/groups with the specific permission
Description | Command | Permission |
---|---|---|
Main command | /guishop |
guishop.main |
Create a shop | /guishop create <shopName> |
guishop.create |
Delete a shop | /guishop delete <shopName> |
guishop.delete |
Add an item in a shop | /guishop additem <shopName> <itemId> <buyPrice> <sellPrice> <currency> <description> |
guishop.additem |
Remove an item from a shop | /guishop removeitem <shopName> <itemName> |
guishop.removeitem |
Open a shop for a player | /guishop open <shopName> <playerName> |
guishop.open |
List all shops | /guishop list |
guishop.list |
List all items in a shop | /guishop list <shopName> |
guishop.list |
Force save config | /guishop forcesave |
guishop.forcesave |
Reload config file | /guishop reload |
guishop.reload |
Show balance for all currencies | /guishop balance |
guishop.balance |
Show balance for a currency | /guishop balance <currency> |
guishop.balance |
Send your money to another player | /guishop balance <currency> send <playerName> <amount> |
guishop.balance.send |
Increase a player's balance | /guishop balance <currency> add <playerName> <amount> |
guishop.balance.add |
Decrease a player's balance | /guishop balance <currency> remove <playerName> <amount> |
guishop.balance.remove |
Create a shop: /guishop create "Test shop"
"
Add item in a shop: /guishop additem "Diamond" minecraft:diamond[minecraft:enchantment_glint_override=true,minecraft:custom_name=hello] 250 100 guishop:credit "This is a Diamond\\An expensive diamond\\Shiny"
(you can split each description line by using "\\")
Item components are supported in the same way as in the
/give
command. You can use an item generator like mcstacker or the one from Gamergeeks to generate items with components like enchantments, custom names, etc. In-game, you'll also get suggestions for item components.
The buy and sell prices are without any formatting so say you configured 2 decimal places in your config and you want to sell an item for 1.50, you would use 150 as the sell price.
Remove item from shop: /guishop removeitem "Test shop" "Diamond"
Open a shop and show it to a specific player: /guishop open "Test shop" "Steve"
You can also add items only to be bought or sold in a shop. Items with a buy price of -1 can only be sold and items with a sell price of -1 can only be bought.
Guishop has a built-in optional economy provider that can be configured in the ./config/guishopeconomy.json
file.
{
"disabled": false,
"database": {
"type": "sqlite",
"currency": "./config/guishop.sqlite"
},
"economy": {
"currencies": {
"credit": {
"name": "Credits",
"prefix": "$",
"suffix": "",
"decimalPlaces": 2,
"icon": "minecraft:diamond"
}
},
"accounts": {
"account": {
"name": "Account",
"currency": "credit",
"icon": "minecraft:diamond"
}
}
},
"command": {
"disabled": false,
"alias": ""
}
}
You can find the main config file in ./config/guishop.json
.
In economyProviders
you can specify the economy provider you want to use.
This can be an external economy mod that uses the Common Economy API
or the built-in economy provider configured in guishopeconomy.json
.
The object is a mapping usually mod_id:currency_id
to a list of account_id
's.
To use the build-in economy provider, prefix your configured currency with guishop:
.
In shops
you can define your shops and their items.
Both the items' names and descriptions support Simplified Text Format.
You can both use the config file and in-game commands to add items to the shop.
Just remember to:
- reload the mod using
/guishop reload
after editing the config file, - save the in-game changes using
/guishop forcesave
to reflect them in the config file. - not to work in both the config file and in-game at the same time.
- If the in-game changes are saved, they will overwrite any cha 9814 nges made to the config file.
- If the config file is reloaded, it will overwrite any in-game changes.
- Be careful when making large-scale changes to the config file while the server is running as the mod will automatically save in-game changes every 30 minutes.
{
"economyProviders": {
"guishop:credit": [
"account"
]
},
"shops": [
{
"shopName": "Shop number one",
"items": [
{
"name": "The boat",
"itemId": "minecraft:acacia_chest_boat",
"description": [
"This is a nice boat",
"Very beautiful"
],
"buyPrice": 50,
"sellPrice": 25,
"currency": "guishop:credit",
"componentChanges": {}
},
{
"name": "Free BBQ Sword",
"itemId": "minecraft:diamond_sword",
"description": [],
"buyPrice": 0,
"sellPrice": -1,
"currency": "guishop:credit",
"components": {
"minecraft:enchantment_glint_override": true,
"minecraft:custom_name": "\"hello\""
}
},
{
"name": "Amethyst",
"itemId": "minecraft:large_amethyst_bud",
"description": [
"<red>Such a spectacular</red>",
"<purple>amethyst</purple>",
"<rainbow>SHINY</rainbow>"
],
"buyPrice": 200,
"sellPrice": 100,
"currency": "guishop:credit",
"components": {}
}
]
},
{
"shopName": "A second shop",
"items": []
}
]
}
From 1.4.5 and onwards, the mod supports any (combination of) economy mod that uses the Common Economy API. A great example is Common Bridge, which bridges multiple economy plugins to use the Common Economy API.
GuiShop also comes with its own economy provider which can be configured in the config file. This build-in economy provider can be configured with multiple currencies and accounts. (The multi-account per currency functionality has not been properly implemented yet.)
- Add unit tests
- Patbox also has some examples on how to write tests in:
- sgui
- polymer
- TextPlaceholderAPI
- Also see the mc-serverkit project for some examples
- Patbox also has some examples on how to write tests in:
- Consider what to do if a player is in spectator mode
- Patbox recently added something for this in sgui
- Add migration for config files
- Minecraft often changes how NBT data is stored.
For example, in 1.21.5, Mojang removed the
levels
parameter from theminecraft:enchantments
component. To advoid data loss on enchantments / custom names, we should add a migration to the config. - Add version field to the config file
- Write migration for 1.21.4 -> 1.21.5
-
enchantments={levels:{sharpness:2}}
->enchantments={sharpness:2}
-
{"text":"An unnecesary op shield","italic":false}
->{text:"An unnecesary op shield",italic:false}
-
- Minecraft often changes how NBT data is stored.
For example, in 1.21.5, Mojang removed the
1.21.4
/execute as rickiewars run guishop additem update_test enhancedItem shield[custom_name='["",{"text":"OP Shield","italic":true,"underlined":true,"bold":true}]',lore=['["",{"text":"An unnecesary op shield","italic":true}]'],rarity=epic,enchantments={levels:{bane_of_arthropods:5,fire_aspect:2,knockback:2,looting:3,mending:1,sharpness:5,smite:5,sweeping_edge:3,unbreaking:3,vanishing_curse:1}}] 100 100 guishop:credit "my description"
1.21.5
/execute as rickiewars run guishop additem update_test enhancedItem shield[custom_name=[{"text":"OP Shield","italic":false,"underlined":true,"bold":true}],lore=[[{"text":"An unnecesary op shield","italic":false}]],rarity=epic,enchantments={bane_of_arthropods:5,fire_aspect:2,knockback:2,looting:3,mending:1,sharpness:5,smite:5,sweeping_edge:3,unbreaking:3,vanishing_curse:1}] 100 100 guishop:credit "my description"
Give command for inport at https://gamersgeeks.net/apps/minecraft/give-command-generator (version 1.21.5)
give @p shield[custom_name=[{"text":"OP Shield","italic":false,"bold":true,"underlined":true,"color":"dark_red"}],lore=[[{"text":"An unnecesary OP shield","strikethrough":true}]],item_name=[{"text":"OP Shield","italic":false}],enchantments={aqua_affinity:1,knockback:2,looting:3,mending:1,sharpness:5,unbreaking:3,vanishing_curse:1},death_protection={death_effects:[{type:apply_effects,effects:[{id:resistance,duration:100,amplifier:9}]}]},unbreakable={}]