Traders and named items
A trader opens the real villager window. Each trade takes one or two items and gives one: heads for a pickaxe, coins for a pouch, four keys for a better key. Named items describe an item once, so trades and shops can point at it.
Named items (items/*.yml)
# items/box.yml
items:
ancient_coin:
material: GOLD_NUGGET
display-name: "<gradient:#F5D27A:#C8902E>Ancient Coin</gradient>"
lore:
- "<gray>Dug out of old ruins."
glint: true
custom-data: {myserver: ancient_coin} # the mark it is recognised by
ruby_sword:
material: DIAMOND_SWORD
display-name: "<gradient:#ff3b3b:#7a0000>[⚔] Ruby Sword [⚔]</gradient>"
enchants: {sharpness: 3}
unbreakable: true
custom-model-data: 7509
flags: [HIDE_UNBREAKABLE]
custom-data: {myserver: ruby_sword}
ruby_helmet:
material: DIAMOND_HELMET
trim: {pattern: rib, material: redstone}
enchants: {protection: 2}
custom-data: {myserver: ruby_helmet}
rockets:
material: FIREWORK_ROCKET
amount: 16 # a shop sells 16 per purchase
| Field | What it does |
|---|---|
material |
The vanilla item (required) |
amount |
How many make one unit (a trade result, one purchase in a shop) |
display-name, lore |
MiniMessage; not italic unless you ask for it |
enchants |
Any level, {sharpness: 6} included |
unbreakable, glint |
true / false |
custom-model-data |
For resource packs; the item still looks like its material without the pack |
trim |
Armour trim, {pattern: rib, material: redstone} (1.20+) |
skull-texture |
Head texture (the base64 value or a textures.minecraft.net URL) |
color |
#RRGGBB for leather armour |
flags |
Item flags (HIDE_ENCHANTS, HIDE_UNBREAKABLE…) |
custom-data |
Entries of the item's own custom_data: the mark |
pdc |
Bukkit container entries, {"plugin:key": value}: also a mark |
attributes |
Attribute modifiers, see below (1.17+ servers; the armor of an elytra, extra speed...) |
Attributes
kit_elytra:
material: ELYTRA
attributes:
- {attribute: armor, amount: 5, operation: add_value, slot: chest}
- {attribute: armor_toughness, amount: 1, slot: chest}
flags: [HIDE_ATTRIBUTES]
-
attribute:armor,armor_toughness,knockback_resistance,max_health,attack_damage,attack_speed,movement_speed... (no prefix;minecraft:andgeneric.are accepted). -
operation:add_value(default),add_multiplied_baseoradd_multiplied_total. slot:head,chest,legs,feet,hand,mainhand,offhand,armororany(default).-
Naming an attribute replaces the item's default for that attribute only; the rest of the defaults stay (a sword you give
armorstill hits for its normalattack_damage). -
Each modifier gets a fixed key
shopforge:<item>_<attribute>, so it is the same on every delivery. HIDE_ATTRIBUTEShides them from the tooltip; without it they show as in vanilla.- A bad entry (unknown attribute, slot or operation, amount not a number) is reported in the console with the file and item, and the item loads without it.
Marks
An item with custom-data (or pdc) is recognised by that mark alone, never by its name,
lore or texture. Reword the description later and the items players already hold still count.
custom-data is the same custom_data a datapack or a /give writes:
/give @p player_head[custom_data={myserver:"ancient_coin"}]
So a datapack can drop the coins and ShopForge takes them. /shop inspect shows the mark of the
item in your hand and which named item it matches. An item with no mark only pays when it is
identical to the one described.
Traders (shops/<id>.yml with type: trader)
id: wandering-trader
type: trader
display-name: "<gradient:#7FD1AE:#3E8E6E>Wandering Trader" # window title
npc-only: false # true: only from its NPC or /shop open
# permission: myserver.trader # optional, for the whole trader
trades:
- id: pouch
cost: [{item: ancient_coin, amount: 64}]
result: {item: coin_pouch}
- id: boots # two costs: the window has two slots
cost: [{item: coin_pouch, amount: 1}, {item: ancient_coin, amount: 16}]
result: {item: wayfarer_boots}
- id: emeralds # an item written in place
cost: [{item: ancient_coin, amount: 8}]
result: {material: EMERALD, amount: 3}
- id: better_key # CrateForge keys
cost: [{crateforge-key: vote, amount: 4}]
result: {crateforge-key: rare}
# permission: myserver.vip # optional, per trade (hidden without it)
# stock-per-player: 2 # optional: how many times each player can make this trade...
# stock-refill-hours: 24 # ...before the count resets (default 24)
-
A cost or a result is
item: <named item>,crateforge-key: <key id>or an item written in place with the fields above. A cost'samountmust fit in one slot (1-64, 1 for tools). -
CrateForge keys are recognised by CrateForge's own mark and handed out exactly as CrateForge makes them (they stack with keys from
/cf givekey). -
Opening:
/shop <id>, a Citizens NPC (select it, then/shop npc <id>), or/shop open <player> <id>from the console, a menu or an NPC command. -
Limits per player:
stock-per-player(+stock-refill-hours) caps how many times one player can make a trade. The count is kept in the database (it survives restarts and/shop reload); when it runs out the villager crosses the trade out and the player gets the usual sold-out message. After each trade the player is told how many are left. -
Picking a trade in the list moves the right items from the inventory into the slots.
Safe by design
The window only shows the trades. What pays and what comes out is decided on the server by the marks: every click on the result slot is handled by ShopForge, so shift-click, drag, double-click, number and drop keys cannot copy the result, and nothing is charged when the result has nowhere to go (shift-click with a full inventory says so). A one-item trade wants the other slot empty, as in vanilla.
Named items in shops
- id: ancient_coin
item: ancient_coin # shows it and only buys items carrying its mark
sell-price: 12
- id: rockets
item: rockets # amount 16 in items/: one purchase = 16 rockets
buy-price: 400
/sell hand and /sell all sell them like any other entry. An entry with a plain material
never buys an item that carries a named item's mark: a Ruby Sword is not sold as a diamond sword.
Sell prices are per item.