DriftShop
A server shop that comes stocked and edits in game.
A server shop for Paper and Folia 26.3: categories of items players buy from and sell to the server, /sell,
/sellgui and /worth, price modifiers for ranks, daily limits, optional dynamic prices and an in-game editor.
There are no player shops (that's DriftAuction). Part of DriftSuite.
Features
- Categories as files: every shop is a file in
shops/with its own title, size, economy, permission and button in the/shopmain menu./shop <category>opens one straight away. - Comes stocked: blocks, ores, farming, mob drops, food, redstone, decoration, enchantments and spawners, with vanilla-ish prices. Everything that sells back sells for a quarter of its buy price.
- Buy and sell from the menu: left-click to buy, right-click to sell, shift-left for 1 to 9 stacks, shift-right
to sell every one you have. Each click can be changed in
config.yml. - Amount menu: -64, -16, -8, -1, +1, +8, +16, +64, "set to the most", and confirm. The buy menu has a stack picker, the sell menu a "sell all of this item" button.
- "Are you sure?" pop-up for anything above a set total.
- Item types: items (including Nexo, ItemsAdder and Oraxen items), enchanted books, permissions bought once, commands, DriftSpawners spawners and decoration.
- Every economy: each shop trades in Vault, any DriftEconomy currency, or XP levels.
/sell hand,/sell handall,/sell all,/sellguiand/worth, each item going to the shop that pays the most for it.- Price modifiers by permission (
driftshop.modifier.<name>), for every shop, one shop or one item. - Daily limits per player per item, for buying and selling.
- Dynamic prices (off by default): prices drop as an item is sold, rise as it's bought, and recover over time.
- In-game editor:
/shop editorchanges prices and slots, removes items and adds the item in your hand. - Price loop check: the console warns about any item that can be sold for more than it can be bought.
- Brings over DriftEconomy's
worth.ymlprices the first time it starts. - Developer API and PlaceholderAPI placeholders.
- H2 or MySQL/MariaDB storage, so limits are shared across a network.
- Folia supported.
Requirements
- Paper (or a fork like Leaf) or Folia 26.3, Java 25
- An economy: Vault with an economy plugin (DriftEconomy with
features.vault: trueworks), or DriftEconomy currencies, or nothing at all for shops that trade in XP levels - Optional: PlaceholderAPI, LuckPerms (for permission items), DriftSpawners (for spawner items), Nexo, ItemsAdder or Oraxen
Getting started
- Put
DriftShop-<version>.jarinplugins/and start the server. It works without any changes: the default shops are written toplugins/DriftShop/shops/and its own data toplugins/DriftShop/data/(see Folder layout). - Run
/shop. Prices can be changed in game with/shop editor, or in the shop files followed by/driftshop reload. - If you used DriftEconomy's
/sellbefore, update DriftEconomy to 1.8.0: DriftShop owns/selland/worthnow (/setworthis replaced by/shop editor), and itsworth.ymlprices are brought over on first start.
Commands
| Command | What it does |
|---|---|
/shop | Open the main menu. Alias /shops. |
/shop <category> | Open one shop, like /shop ores. |
/shop editor | The editor (staff). |
/sell hand | Sell the stack in your hand. /sell on its own does the same. |
/sell handall | Sell every one of the item in your hand. |
/sell all | Sell everything a shop buys. |
/sellgui | A menu to drop items into; they're sold when it closes. Alias /sellmenu. |
/worth [hand] | What the item in your hand sells for. |
/driftshop reload | Reload every file and shop. Alias /dshop. |
/driftshop version | Show the version. |
/driftshop help | The list of admin commands (click a line to fill it in). |
Every command can be renamed, given other aliases, a different permission or turned off in commands.yml.
DriftEconomy's old /setworth is replaced by /shop editor.
Permissions
| Permission | Default | What it allows |
|---|---|---|
driftshop.use | everyone | /shop |
driftshop.sell | everyone | /sell |
driftshop.sellgui | everyone | /sellgui |
driftshop.worth | everyone | /worth |
driftshop.admin | op | /driftshop, /shop editor, and seeing why a shop's economy isn't working |
driftshop.modifier.<name> | nobody | A price modifier from config.yml (not even ops get it by default) |
driftshop.bypass.gamemode | nobody | Selling in creative and spectator |
Each shop can also need its own permission (permission: in its file).
Making a shop
Copy any file in shops/ and change it. The file name is the shop's id (/shop <id>).
title: "<dark_gray>sʜᴏᴘ <dark_gray>» <color:#6ee7b7>Ores <dark_gray>(<page>/<pages>)"
rows: 6 # 2 to 6; the bottom row holds the page buttons
economy: vault # vault, xp, or a DriftEconomy currency like gems
permission: "" # needed to open it; empty for everyone
icon: # its button in the /shop main menu (slot -1 hides it)
slot: 12
material: DIAMOND
name: "<color:#6ee7b7><bold>Ores & Minerals</bold>"
lore: ["<gray>Items: <white><items>"]
# texture: "eyJ0ZXh0..." # with material: PLAYER_HEAD: a head skin (base64 value, texture URL or hash)
items:
diamond:
material: DIAMOND
buy: 200 # the price of ONE; leave out to stop it being bought
sell: 50 # leave out to stop it being sold
slot: 10 # 0 to 44 in a 6-row shop; leave out for the first free slot
page: 1
# For a PLAYER_HEAD: texture (base64 value, textures.minecraft.net URL or hash) or skull-owner (a player
# name). The head players buy keeps the skin, and only heads with that skin sell back.
limit: # optional daily limits per player
buy: 64
sell: 640
dynamic: true # false keeps the price fixed when dynamic prices are on
name and lore on an item only change how it looks in the menu. Items are matched exactly when sold: a renamed,
enchanted or damaged item only sells if the shop item is that same item (add it with /shop editor while holding it).
Item types
Set with type: (item if left out).
| Type | What it is | Extra settings |
|---|---|---|
item | An item to buy and sell | material: DIAMOND, or material: nexo:ruby / itemsadder:pack:ruby / oraxen:ruby |
enchantment | An enchanted book | enchantment: sharpness, level: 5 |
permission | A permission, bought once | permission: some.permission, plus a display item (material, name, lore) and optional commands |
command | Runs console commands when bought | commands: ["give {player} diamond {amount}"] and a display item |
spawner | A DriftSpawners spawner | mob: zombie. Hidden unless DriftSpawners is installed |
dummy | Decoration; clicking does nothing | a display item |
Permissions are given with LuckPerms when it's installed (lp user <uuid> permission set <permission> true), or with
permission-items.command in config.yml otherwise. In commands, {player}, {uuid} and {amount} are filled in.
Spawners come from DriftSpawners' API; if it has none, spawners.give-command is used and they can't be sold back.
Price modifiers
modifiers:
vip: # driftshop.modifier.vip
buy: 0.95 # 5% off
sell: 1.05 # 5% more when selling
shops:
ores: { buy: 0.9, sell: 1.1 }
items:
"ores:diamond": { buy: 0.85, sell: 1.2 }
The most specific setting counts (item, then shop, then the modifier's own). With several modifiers the best one for the player applies: the lowest buy and the highest sell. The modifier permissions are registered as nobody's by default, so operators don't get every discount.
Daily limits
limit.buy and limit.sell on an item cap how many one player can buy or sell of it a day. Days start at midnight
in daily-limits.timezone (the server's own if empty). /sell all and /sellgui sell up to the limit and give the
rest back, and the item shows what's left today.
Dynamic prices
Off by default (features.dynamic-prices). Every item sold lowers that item's price by step (0.1%) and every item
bought raises it; prices go back to normal by recover-percent-per-hour. Buy and sell prices always move together
and stay between floor and ceiling times normal. They're saved every save-seconds and when the server stops.
On a network each server keeps its own dynamic prices.
Moving from DriftEconomy's /sell
DriftEconomy 1.7.0 had /sell, /worth and /setworth with prices in worth.yml. From DriftEconomy 1.8.0 those
commands are gone and DriftShop has them. The first time DriftShop starts with plugins/DriftEconomy/worth.yml
there:
- items already in a shop get their
worth.ymlsell price, unless it would sell for as much as it costs (logged, the shop price is kept); - everything else goes into a new sell-only shop,
shops/imported.yml, paying in DriftEconomy'ssell-economy.
It runs once (a data/imported-drifteconomy-worth file is left behind; delete it to run it again).
Turning features on and off
At the top of config.yml:
| Switch | Default | What it does |
|---|---|---|
modifiers | true | Price modifiers by permission |
daily-limits | true | limit.buy / limit.sell on items |
dynamic-prices | false | Prices that move with trading |
import-drifteconomy-worth | true | Bring over DriftEconomy's worth.yml once |
placeholders | true | The PlaceholderAPI placeholders |
Settings
| Setting | Default | What it does |
|---|---|---|
clicks.buy / sell / stacks / sell-all | LEFT / RIGHT / SHIFT_LEFT / SHIFT_RIGHT | What each click on a shop item does |
sell-command.economy | empty | Only let /sell, /sellgui and /worth use shops paying in this economy |
amounts.max-buy | 2304 | The most of one item bought at once |
confirm.above | 10000 | Totals this big ask "are you sure?" first (-1 never) |
rules.no-selling-in-creative | true | No selling in creative or spectator |
permission-items.command | empty | How permissions are given without LuckPerms |
spawners.give-command | spawners give {player} {mob} {amount} | How spawners are given without DriftSpawners' API |
daily-limits.timezone | empty | When a day starts |
dynamic-prices.* | see the file | Step, floor, ceiling, recovery and saving |
storage.* | H2 | H2, or MYSQL/MARIADB to share limits across servers |
Can't be exploited
- Money before items, items before money. Buying takes the money before anything is handed over, and refuses when the items wouldn't all fit (nothing is ever dropped). Selling takes the items out first and only then pays; if the payment fails they go straight back.
- One thing at a time. Each player has one shop action running at once, so double clicks and macro spam can't buy or sell twice.
- Exact matching. Items with a custom name, lore, enchantments or damage only sell where the shop item is that exact item.
- No infinite money. On every load (and after every editor change) the console warns about any item that sells, with the best modifier and the dynamic price ceiling, for more than it can be bought for with the cheapest modifier and the floor.
- Rounded in the shop's favour. Buying rounds up, selling rounds down, and a sale that rounds down to nothing gives the items back instead of taking them.
- No creative or spectator selling.
- Permissions bought once are claimed in the database before paying, so a double click or a second server can't buy them twice; a failed payment undoes the claim.
- Locked menus. Nothing can be taken out of a shop menu.
/sellguiis emptied before anything is sold, also when the player leaves or the server stops, so its items can't be handed back twice. - Limits can't be skipped. Daily counts load on join; until they have, limited items can't be traded.
PlaceholderAPI
| Placeholder | What it shows |
|---|---|
%driftshop_worth_hand% | What the stack in your hand sells for |
%driftshop_sold_today% | What you've earned selling today (every economy added together) |
Developer API
double sell = DriftShopAPI.sellPrice(player, stack); // whole stack, -1 if nothing buys it
double buy = DriftShopAPI.buyPrice(player, stack); // whole stack at the cheapest shop, -1 if not for sale
String economy = DriftShopAPI.sellEconomy(player, stack);
List<ItemStack> unsold = DriftShopAPI.sellTaken(player, itemsYouAlreadyRemoved);
Call them on the player's own thread. Prices include the player's modifiers and dynamic prices. sellTaken pays for
items the calling plugin has already taken away, like /sell does, and hands back what didn't sell.
Configuration files
| File | What's in it |
|---|---|
config.yml | Feature switches, clicks, amounts, the confirm pop-up, modifiers, limits, dynamic prices and storage |
shops/*.yml | One file per shop |
commands.yml | Command names, aliases and permissions |
messages.yml | Every message, in MiniMessage |
menus.yml | The main menu, shop buttons and lore, amount, stack, sell and editor menus |
Every file starts with a boxed header saying how to apply changes, is split into sections, and has a note above
every option saying what it does, its unit and the values it takes. The prefix is DRIFTSHOP in bold solid
mint (#6ee7b7), followed by a dark grey ».
When you update, new options are added with their notes and everything you changed is kept. When the notes
themselves change, each file is rebuilt once with the new notes and your values written back in; the old file is
kept in data/backups/. Messages you never changed get the new default wording.
Mistakes in the files
A value DriftShop can't use never stops the plugin. The console says which file and option, what was wrong and what is used instead, for example:
[DriftShop] config.yml: amounts.max-buy "lots" isn't a whole number, using 2304
/driftshop reload tells you how many problems it found, so you know to look.
Folder layout
plugins/DriftShop/
config.yml settings, starting with the features: switches
messages.yml every message
menus.yml every menu
commands.yml command names, aliases and permissions
shops/ one file per shop category (yours to edit)
data/ the plugin's own files, no need to open them
database.mv.db daily limits, moving prices and sale stats (H2 storage)
backups/ old copies of files DriftShop replaced
*.version which version of each file you have
imported-drifteconomy-worth left by the one-time worth.yml import
Older versions kept data.mv.db, the .version markers and .imported-drifteconomy-worth next to
config.yml. They are moved into data/ the first time the new version starts (one console line per file),
and nothing is overwritten or deleted.