Buying & Selling
Reading a Product
A product in a menu says what it costs and what it pays, for the player looking at it:
- Buy and Sell, for one lot, with the price before a discount or a bonus struck through beside it
- An arrow next to a dynamic price that has moved: ▲ above its base, ▼ below, once it is half a percent away
- What is left in stock, and when it restocks once it is out
- What the player may still buy or sell under its limit, and when that resets
- Why they may not trade it, when they may not: a permission, a world, play time, a rank, a currency the server does not have, an offer that is not on today
- What each click does, blinking like every button of the family: the buying lines in green, the selling ones in gold. A player who cannot afford one lot sees Not enough money in place of the buying lines
The name is the game's own, in each player's language, unless the product's file gives it a name. While a menu is open, it is drawn again every five seconds when something on it moves by itself: a price coming back to its base, a stock restocking, offers counting down.
Quick Clicks
clicks:
left: quantity # choose how many to buy
right: sell # sell one lot
shift-left: buy-stack # buy a stack
shift-right: sell-all # sell every unit of it you carry
| Action | Description |
|---|---|
buy | Buys one lot |
buy-stack | Buys a stack's worth, in whole lots: 64 of a lot of 1, four lots of 16 |
sell | Sells one lot |
sell-all | Sells every unit of that product the player carries |
quantity | Opens the quantity screen, to buy |
quantity-sell | Opens the quantity screen, to sell |
none | Does nothing |
The same clicks work in a shop and in the results of a search.
The Quantity Screen
Buttons that add and remove lots (one, sixteen and sixty-four by default), the product in the middle, and a confirm button that shows the total and the player's balance as the number changes, with a line when they cannot afford that many. As many as I can sets the most they can afford and carry or, when selling, everything they hold. Buy or sell switches between the two for a product that does both, and Back returns to the shop.
The steps are read from guis/quantity.yml by their names: a button named add-128 adds 128 lots, remove-8 takes 8 away. Add the ones you like; the plugin draws the rest. A purchase stops at a full inventory's worth, 2304 units, and a sale at what the player holds.
What Happens When You Buy
- The purchase is checked: the player may trade the product, has room for it, and it is in stock and within their limit. Fewer units are bought when fewer fit, are left or are allowed.
- The stock, the player's allowance and the product's place in its dynamic price are taken in the database in one go, with statements the database refuses when there is not enough. Two players clicking on the last unit get one "bought" and one "out of stock", even on two servers.
- The money is taken. If it is not there after all, everything taken in the step before is put back, and nothing else has happened.
- The trade is written to the log, then the items are handed over.
What no longer fits by the time the items arrive, because the inventory changed or the player left, goes to XCore's delivery, which hands it over at their next login. With buying.overflow-to-delivery: false it is dropped at their feet instead, and still delivered when they have left. Nothing paid for is lost.
- Are you sure? A purchase of
buying.confirm-aboveor more opens a confirmation screen first. 0, the default, never asks. - The price moved. Between the click and the moment the trade is written, other players' trades, here or on another server, can move a dynamic price. When the total would then come to more than
dynamic-pricing.slippage(2%) above what it was at the click, the purchase is refused and the menu shows the new price: The price just changed: it is now $81.60. Try again. - Edited meanwhile. A product whose item, lot or commands changed while its confirmation screen or form stayed open is not bought: the player is told it is not sold here any more.
- One trade at a time. A second click while the first is on its way to the database is refused, not queued: it was almost certainly the same click.
The Sell Chest
/sell, or the sell button of the menus, opens a chest. Items dropped in the rows above the last are listed with their price as they come in; the confirm button sells them, and what the shop does not buy is handed back. Closing the chest hands everything in it back, into the inventory and, when that is full, into XCore's delivery, which hands it over at the next login. The same happens on a disconnect, a reload or the plugin stopping: the items in the chest are the player's until they are sold. A player who dies with the chest open gets its items back when they respawn, or at their next login when they leave before respawning.
In the chest, a product is sold even when its file says sell-all: false: the player put it there on purpose. Renamed and enchanted items still need a product that names them exactly.
/sell hand, /sell all and /worth
/sell hand # the stack in your hand
/sell hand 16 # 16 of it
/sell all # everything the shop buys
/sell all cobblestone # every stack of one item
/worth # what the item in your hand sells for
/worth all # what everything you carry sells for
/sell alltakes what a sweep may take: items whose product leavessell-allon, and never an item somebody cares about (see below)./sell handsells what is in the hand, whateversell-allsays.- When several products buy the same item, in one shop or in several, the sale goes to the one that pays that player the most.
- A sale says what it paid, Sold 128 item(s) · +$32.00, with the detail one hover away: a line per product, up to
selling.summary-lines(10), then "and N more". - What could not be sold after all, a limit reached or a stock full, is handed back with the reason.
- A sale that would pay nothing, a single cobblestone at a fraction of a cent, leaves the item where it is.
- A balance at its cap (the
max-balanceof the currency) refuses the sale before anything is taken: Your balance is at its limit: the shop cannot pay you. /worth allgives one total per currency.
What Is Never Swept Up
A plain item is one nobody could tell from a fresh one, wear aside. A name, an enchantment, a lore, the data another plugin keeps on it: any of those makes it particular, and a particular item is only ever sold to a product that names it exactly. That holds for every way of selling, so /sell all never takes the sword somebody spent an evening enchanting, the pickaxe named after their dog, or the custom item another plugin made out of a diamond.
Used Tools and Armour
selling:
damaged-items: prorata # refuse, prorata or full
| Value | A used tool or armour piece |
|---|---|
refuse | Is never bought back |
prorata | Is bought back for the share of its durability that is left: a pickaxe with 40% left sells for 40% of the price |
full | Is bought back at full price |
This is about plain items. A shop may still sell, and buy back, an exact damaged item as it is.
Shulker Boxes
selling:
shulker-contents: false
With true, /sell all and sell wands also sell what the shulker boxes in the inventory or the container hold. The boxes stay, with whatever the shop did not buy still in them. A box the shop buys as an item is sold as a box.
Sell Wands
/xshop wand give Steve # unlimited uses, no bonus
/xshop wand give Steve 50 1.5 # 50 uses, paying 50% more
A right click with a wand on a chest, a trapped chest, a barrel or a shulker box of any colour sells everything the shop buys in it, as /sell all would: the player's limits and bonuses apply, the money is theirs, and the wand's multiplier comes on top, the whole held under guarantees.max-sell-multiplier.
- Uses: 1 to 1,000,000; left out, 0 or -1 for no limit. One use is counted per sale that went through, and a used-up wand disappears.
- Multiplier: 0.01 to 100, 1 by default.
- Protection: a click that a claim, a locked chest or a region refuses sells nothing: You may not open this container.
- Carried state: the uses and the multiplier are written on the wand itself, so it works on every server it is carried to.
wands:
material: BLAZE_ROD # what a wand is made of
cooldown: 1 # seconds between two uses by the same player
containers: # SHULKER_BOX stands for every colour
- CHEST
- TRAPPED_CHEST
- BARREL
- SHULKER_BOX
Giving one needs xshop.admin.wand and the player online (a full inventory sends it to the delivery); using one needs xshop.wand.use, which everybody has.
A wand made of something else than wands.material does nothing: choose the material before giving any.
Bedrock Players
Players on Bedrock, through Floodgate, get forms in place of the chest menus, which their client shows poorly: the list of shops as buttons, with a search button; a shop's products with their prices; then for one product: buy one lot, buy a stack, sell one lot or sell all they have, with their balance above. The search is a form with a text field. A purchase of buying.confirm-above or more asks for confirmation in a form first, and every purchase is held to the price its button showed: one that moved further than the slippage allows is refused, not charged. The texts are the bedrock-* keys of the language file.