Skip to content
On a Network

On a Network

What Is Shared

XShop shares its data across servers when XCore's cross-server sync is on and XShop's is too: cross-server.enabled in XCore's config.yml, and sync-addons.XShop in plugins/XCore/addons.yml. The servers also need one database between them, MySQL or PostgreSQL.

WhatSharedNot shared
Dynamic pricesOne price per product for the whole networkEach server its own
StockOne stock: the last unit goes to one player, whichever server they are onEach server its own
LimitsA player's allowance counts on every serverCounted per server
Boosters and sales started by handOn every serverOn the server that started them
Transactions, totals, leaderboardsOne log, each trade with its serverThe same

A product is <shop>.<product> on every server, and that name is the row the network shares. When XShop is not shared, every row starts with the server's name, so two servers on one database never see each other's prices, stocks or limits.

The Shop Files

Each server reads its own plugins/XShop/shops/. To sell the same products everywhere, give every server the same files. A product that exists on one server and not on another is simply not sold there, and its shared price, stock and limits wait for it.

  • An edit, from a command or the dashboard, changes the file of the server it is made on: the dashboard of each server edits that server's files.
  • The history is kept per server, and a version is restored on the server it came from.
  • A rotating shop draws the same offers on every server that has the same file and the same rotation.seed, without the servers talking.
  • Scheduled sales come from each server's own config.yml.

How It Holds

  • Every trade is decided by the database: the stock, the allowance and the place in a price are taken by statements it refuses when there is not enough, so two players on two servers cannot both buy the last unit.
  • Each server keeps prices, stocks and boosters in memory for its menus, and hears of every change on XCore's xshop channel: Redis, or the database without it. Every five minutes it reads the tables again, so a message that went missing cannot leave a wrong stock on show.
  • A dynamic price recovers by the clock, worked out when it is read: two servers show the same price with no task on either.
  • A restock happens once, on whichever server reaches it first.
  • A player's limits are read when they join and dropped when they leave, and a change made on another server reaches the menus at once.
  • A sell wand carries its uses and its multiplier itself, and works on every server.
  • A player who comes back under a new UUID keeps their trades, limits and boosters: XCore recognises them, and XShop moves its rows.

A sale started on one server runs on all of them, and each announces its start and end to its own players. Discord hears of it once: the server whose name comes first among those up posts it. Big trades are posted by the server they happen on.