Skip to content
◆ TTS-STUDIO docs Discord

Plugins / ShopForge

‍ 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]

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)

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.

Keep reading