Shops & Products
One File per Shop
Each shop is a YAML file in plugins/XShop/shops/, and its file name without .yml is its id: /shop ores opens ores.yml. An id is made of lower-case letters, digits, _ and -, 32 at most, and is what commands, placeholders and the database call the shop. A product is called <shop>.<product>: ores.diamond.
title: "<green>Ores"
icon: DIAMOND
description:
- "<gray>Ingots, gems and their blocks"
products:
diamond:
buy: 80
sell: 20
iron_ingot:
buy: 128
sell: 32
amount: 16
emerald:
buy: 40
That shop sells diamonds at 80 and buys them back at 20, sells iron in lots of 16, and sells emeralds without buying them back. Three ways to change it, all writing the same file:
- By hand, in a text editor, then
/xshop reload - In game, with
/xshop create,add,set,move,removeanddelete(see Editing in Game) - On the dashboard, on a grid that looks like the menu (see Dashboard)
Shop Keys
| Key | Default | Description |
|---|---|---|
title | the id | The shop's name, in MiniMessage, on its icon in the list. The title of its menu shows it without its colours, in the dark grey of every menu |
icon | CHEST | Its item in the list |
description | none | Lines under its name in the list, in MiniMessage |
slot | the next free place | Its place in the list, on the first page. Shops without one, or with one already taken, fill the free places in the order of their file names |
hidden | false | Left out of the list and of the search. It opens with /xshop open (for a player, from the console or an NPC), and with /shop for holders of xshop.admin. Its products are still bought back by /sell |
currency | default-currency | The currency of its products that name none: the id of an XCore currency, or vault for the economy registered with Vault |
permission | none | Needed to see the shop in the list, to open it and to trade its products |
worlds | every world | The worlds it opens in, by folder name, in any case |
rotation | none | Makes it a rotating shop: see A Rotating Shop |
products | none | The products, each under its own name |
Product Keys
A product's name, its key under products, is its id: lower-case letters, digits, _ and -, 48 at most. When a product names no item, data, spawner or commands, its name is its item: stone: alone sells stone.
| Key | Default | Description |
|---|---|---|
item | the product's name | The item sold, by its game name, in any case, with or without minecraft: |
data | none | One exact item, written by /xshop add (see Exact Items) |
spawner | none | A mob: the product is a spawner of that mob (see Spawners) |
commands | none | Commands the console runs when it is bought (see Command Products) |
icon | the item, else PAPER | The item a command product shows |
name | the game's name | The name shown, in MiniMessage. Without it, each player reads the item's own name in the language of their game |
lore | none | Lines shown above the prices, in MiniMessage |
buy | not for sale | The price of one lot |
sell | not bought back | What the shop pays for one lot. Zero is not bought back either |
amount | 1 | Units per lot, 2304 at most (a full inventory). The prices are for the whole lot. Always 1 for commands |
currency | the shop's | This product's own currency |
permission | none | Needed to buy or sell it |
worlds | every world | The worlds it can be traded in |
requires.playtime | none | Play time needed first, counted by XCore across sessions: 10h, 2d |
requires.group | none | A rank needed: the player holds group.<name>, or it is their primary group in LuckPerms or Vault |
page | 1 | The page it sits on |
slot | the next free slot | Its slot on that page (see Pages and Slots) |
dynamic | a fixed price | true, or a section with range, up, down, volume and recovery (see Dynamic Prices) |
stock | unlimited | A number, or a section with max, start, every, restock and fed-by-players (see Stock) |
limit | none | A section with buy, sell, period and tiers (see Limits per Player) |
sell-all | true | false keeps it out of /sell all, /worth all and sell wands: it is then sold from its own menu, by /sell hand and in the sell chest only. Always false for commands |
glow | false | Makes it glow in the menu, for the eye |
A price is a number, 12.5 or "12,5". A sell price above the buy price is a typo nine times out of ten: the console names the product, the audit lists it, and the shop never pays it (see Buying Back Never Pays).
Exact Items
Hold an item and run /xshop add <shop> <buy> <sell> [id], with - for no price. What is in your hand decides what the product is:
- A plain item, as it comes from the game:
item: STONE - A spawner that names its mob:
spawner: ZOMBIE - Anything else, an item with a name, enchantments, a lore, wear, or the data of Nexo, ItemsAdder or any other plugin: it is captured whole, as
data:, and the product hands over that exact item
/xshop add tools 500 - # the sword in hand, for sale, not bought back
/xshop add tools 500 120 relic # the same, bought back at 120, named "relic"
The number of items in your hand becomes the lot: holding 16, the prices are for 16. Without an id, the product is named after its item, with a number when that name is taken.
An exact product sells and buys back that item and nothing else, whatever the amount. The other way round, a plain product never takes an item somebody cares about: a renamed or enchanted diamond sword is not "a diamond sword" to a shop. In the menu, an exact item keeps its own lore, with the prices under it.
An item captured on a newer version of Minecraft cannot be read by an older server: the product is then left out, and the console and the audit say why. The dashboard picks plain items only; for anything else, use /xshop add with the item in hand.
Command Products
vip:
icon: NETHER_STAR
name: "<yellow>VIP rank"
commands: ["lp user {player} parent add vip"]
buy: 50000
limit: { buy: 1, period: forever }
- The console runs every command once per unit bought, on the server's own thread.
{player}(or%player%) is the buyer's name and{uuid}their UUID; a slash in front is taken off. - Nothing goes into the inventory, so a full one does not stop the purchase.
- Never bought back: a
sellprice is ignored, with a line in the console. A lot is always 1. - On the dashboard, writing or changing them needs the console's trust: see Who May Do What.
- A rank or a key is usually sold once: give it a limit, as above.
Spawners
zombie_spawner:
spawner: ZOMBIE
buy: 25000
limit: { buy: 2, period: daily }
The product hands over a spawner of that mob, and buys back, when it has a sell price, a spawner item that names the same mob. A spawner that names none, as one picked up with Silk Touch on a server that keeps no mob type, matches no product. The mob must be one this server can spawn; otherwise the product is left out.
Pages and Slots
A product that names a slot sits exactly there, on its page (1 by default), as long as the slot is one of the product slots of the shop menu and no other product has it. Every other product takes the next free slot, page after page, in the order of the file. A file that names no slot reads as a list; a file that places everything reads as a layout. A slot that is taken, or that is not a product slot, sends the product to the next free one, and the console says so.
The product slots are the slots list of guis/shop.yml: 0 to 44 by default, the five rows above the bar. Changing that list moves every product placed by number, so it is best set once.
/xshop move <shop> <product> <page> <slot> puts a product somewhere else, swapping it with whatever sat there. On the dashboard, Move does the same with a click on the destination.
Editing in Game
| Command | Description |
|---|---|
/xshop create <shop> [title] | A new, empty shop file, with a chest for icon |
/xshop add <shop> <buy> <sell> [id] | The item in your hand as a product; - for no price |
/xshop set <shop> <product> <field> <value> | Change one thing about a product (the fields below) |
/xshop move <shop> <product> <page> <slot> | Put it at that page and slot, swapping with what is there |
/xshop remove <shop> <product> | Take it out of the shop |
/xshop delete <shop> | Delete the shop's file. Its text stays in the history, from where it can be restored |
The fields of /xshop set, with - or none to clear one:
| Field | Value |
|---|---|
buy, sell | A price |
amount | Units per lot, 1 to 2304 |
currency | A currency of this server |
permission, name | Any text; the name in MiniMessage |
dynamic | true for the defaults of config.yml, a range such as 30%, or false |
stock | A maximum; - for unlimited |
limit-buy, limit-sell | Units per player per period; the period becomes daily when none is set |
limit-period | daily, weekly, monthly, forever or a duration |
sell-all | false to keep it out of /sell all; anything else puts it back |
page, slot | Where it sits |
Every edit needs xshop.admin.edit, except delete, which needs xshop.admin. The console logs each one with its author.
How the Files Are Kept
- Never merged. The starter shops are copied once, when the folder does not exist. An update never adds or changes a product, and a shop you delete stays deleted.
- A file with a YAML mistake is never written over. A tab in front of a list entry is enough to make a file unreadable. An edit from a command or the dashboard is then refused with the line where the mistake is, so what you were typing in your editor is never replaced by the shop as it was last read. While the server runs, the shop keeps what it read before the mistake, so players in it are not thrown out; at a start, it stays closed until the file is fixed. The audit lists it as an error.
- A line that cannot be used is left out, and named. An unknown item, a price that is not a number, a slot already taken: the console and the audit say which product and why, and the rest of the shop opens.
- Every change is written whole, or not at all. The file is read again as it is on disk, the change is applied to that, and the result is checked to be a readable shop, then written beside the file and moved over it in one step. A change that would break the file is refused.
History
Every change made from a command, the dashboard, an import or a restore keeps the text the file had before, with who changed it and what was changed; deleting a shop keeps its last text. The dashboard's History page lists them, shop by shop, with a button to bring a version back, and the version it replaces is kept in turn.
logs:
revisions-per-shop: 100 # earlier versions kept for each shop
A change made in a text editor is not an entry of its own, but the next change made from a command or the dashboard keeps the file as you left it. Each server keeps the history of its own files.