Currencies
On this page(19)
A currency is a balance every player has, such as money or souls. Each file of the currencies/ folder is one currency, and most currencies get a command of their own (/money). The zone mobs pay currencies, and the levels, stages, tiers, enchants and shops spend them. You add a currency by copying a file, with no restart.
| Files | currencies/ (one file per currency), the currencies: block of config.yml |
| Player commands | /money, /souls, /perktickets, /rebirthpoints (one root per currency) |
| Admin commands | /<currency> give|take|set|reset, /dungeons admin currencies log |
| Switch | Always on (core). Delete a file and run /dungeons reload to remove a currency |
How it works
- One file, one currency. The file name is the currency id:
money.ymlis the currencymoney. - A command per currency. Each currency with
commands-disabled: falsegets the root named incommands.main.command. - Balances load on join. A player's balances load when they join and save every
currencies.autosave-seconds, on quit and on shutdown. - Offline players work too. An admin change to an offline player is written to the database at once.
- No upper bound. Amounts use a mantissa and an exponent, so
1e500is a valid balance. - Every change is logged. While
currencies.log.enabledis true, each balance change becomes a row of the transaction log.
The currencies/ folder is created with its example files only when it does not exist at startup. A single file you delete never comes back. SnDungeons never updates these files, so a key you delete reads its default.
Currency ids
The id follows strict rules, because it is also used in placeholders, booster targets and log rows:
- lowercase letters, digits and
-, at most 64 characters, extension.yml; - never a word YAML reads as another type:
yes,no,on,off, a date, or a number with a leading0(010).
A file with any other extension is skipped with one console warning.
The shipped currencies
| Id | Command | What it is for |
|---|---|---|
money | /money | The main currency. The zone mobs pay it, and the stages and sword tiers cost it. It ships two pouches (t1, t2). |
souls | /souls | The enchant currency. The shipped enchants cost souls, and some pay them (Pinata). It ships with its shop on and one pouch (t1). |
experience | none | An internal currency (commands-disabled: true). The zone mobs pay it and the level track spends it. |
perk-tickets | /perktickets | One ticket pays one sword perk roll (Perks). It ships one pouch (t1). |
rebirth-points | /rebirthpoints (alias /rpoints) | The points of the rebirth leveling upgrades. pay, top and shop ship off. |
rebirth-points is not a booster target, so nothing multiplies it. Keep it out of targets.currencies of boosters.yml unless you want boosted points.
The currency file
Every currency file has the same keys. A key you leave out reads its default.
Root keys
| Key | Default | What it does |
|---|---|---|
display-name | the id | The name shown in messages, menus and placeholders. Color codes allowed. |
starting-value | 0 | The balance of a player who never had one. |
max-value | 0 | The largest balance. 0 means no limit. Accepts 1qa or '1e500'. |
commands-disabled | false | true makes an internal currency with no commands at all. |
shop | false | true gives the currency a shop menu. See Currency Shops. |
pouches | none | The pouch items of this currency. See Currency Pouches. |
Amounts in a currency file are plain numbers, a suffix of the number format (1.5K, 1qa) or an exponent (2.2e25). Quote an amount past about 1.8e308 ('1e500'), or YAML reads it as infinity.
The commands block
The commands: block names the root and its subcommands. Every subcommand block takes the same keys.
| Key | What it does |
|---|---|
main.command | The root name (money). An invalid name falls back to the currency id, with one warning. |
main.aliases | Other names of the root. Give each currency its own root aliases. |
main.permission | The permission to use the root at all. '' means none. |
<sub>.enable | false removes the subcommand: no tab completion, no help line, "unknown subcommand". |
<sub>.aliases | Other names of the subcommand (bal, remove). |
<sub>.permission | The permission of the subcommand. Without the key, the shipped default applies. |
balance.balance-other-permission | The permission to read another player's balance. Ships as sndungeons.balance.others. |
The shipped defaults when a permission key is missing:
| Subcommand | Default permission |
|---|---|
balance, pay, top, shop | none |
give, take, set, reset | sndungeons.balance.<sub> |
A subcommand without its block does not exist. Two exceptions: top and shop are on for everyone when their block is missing.
Name rules. Command names and aliases use lowercase letters, digits, _ and -. A leading / is dropped.
- Two currencies with the same command name: the second gets no command (one warning).
- An alias that names another SnDungeons command (a currency, a track,
dungeons) is ignored with a warning. - A subcommand alias of
help,reload,debugor another subcommand's name is ignored with a warning. - An unquoted
yes,no,on,off,trueorfalseis refused. Write''for "no permission".
When another plugin owns a name (Essentials' /money), SnDungeons takes it. That plugin keeps answering as /essentials:money. A server, vanilla or Brigadier command is never taken: the currency then answers only as /sndungeons:<name>.
A worked example: adding gems
Copy money.yml to gems.yml and edit the top of it:
currencies/gems.yml
display-name: '&bGems'
starting-value: 0
max-value: 0
commands-disabled: false
shop: false
commands:
main:
command: gems
aliases: []
permission: ''
# keep the balance, pay, give, take, set, reset, top and shop blocks of money.ymlRun /dungeons reload. /gems exists at once. To make the zone mobs pay gems, add them to a stage's rewards (Zone Files and Stages). To boost them, add gems under targets.currencies of boosters.yml (Boosters).
Edit or remove the pouches: block of the copy: its item names and lore still say Money.
Configuration (config.yml)
The currencies: block of config.yml applies to every currency. /dungeons reload re-reads it.
currencies
| Key | Default | What it does |
|---|---|---|
autosave-seconds | 60 | Seconds between saves of the changed balances of online players (10 to 3600). |
currencies.number-format
This block writes EVERY number of the plugin: menus, lore, messages, placeholders, holograms and bars. Raw forms stay raw (the _raw placeholders, item tags, debug lines). Levels, tiers and pages are always whole numbers.
| Key | Default | What it does |
|---|---|---|
decimals | 2 | Most decimals of an amount (0 to 6). |
suffixes | ['K', 'M', 'B', 'T', 'qa', 'qi', 'sx', 'sp', 'oc', 'no', 'dc'] | The suffix ladder. The first means thousands, each next one is 1000 times the previous. Keep them quoted. |
scientific | '{mantissa}e{exponent}' | The format of an amount past the last suffix (2.2e40). |
style | abbreviated | abbreviated writes 1.5K. grouped writes 1,500 up to 15 digits, then the suffixes. |
grouping-separator | ',' | The thousands separator of grouped numbers. One character. |
decimal-separator | '.' | The decimal separator. One character, different from the grouping one. |
rounding | half-up | How the last decimal is decided: half-up, down, up or half-even. |
multiplier-decimals | 2 | Decimals of multipliers (x1.5), 0 to 6. Trailing zeros are dropped. |
percent-decimals | 2 | Decimals of percents (12.5%), 0 to 6. |
Examples with the defaults:
| Value | Written as |
|---|---|
| 1500 | 1.5K |
| 4996 | 5K (half-up) or 4.99K (down) |
| 999996 | 1M (a rounding that reaches the next suffix moves to it) |
| 2.2 x 10^40 | 2.2e40 |
1500.25 in grouped with '.' and ',' | 1.500,25 |
Typed amounts. Commands and files accept 500, 1,5K, 1.5qa, 500t, 2.2e25 and 1e500. Suffixes ignore case. A typed amount never takes a thousands separator: 1,000 is refused as ambiguous.
Amounts keep 15 significant digits. Adding 1 to 1e20 leaves the balance as it was.
The decimals keys of other files still win for their own values. These are multiplier-decimals of boosters.yml and of the sword config. They are also value-decimals of the totems and crystals configs.
currencies.log
| Key | Default | What it does |
|---|---|---|
enabled | true | Writes the log rows. false logs nothing (balances still change). |
aggregate-window-seconds | 60 | Gameplay gains of one player, currency and cause are summed into one row per window (1 to 3600). |
flush-seconds | 5 | Seconds between writes of the pending rows to the database (1 to 60). |
time-format | 'yyyy-MM-dd HH:mm:ss' | The date format of /dungeons admin currencies log (a Java DateTimeFormatter pattern, server time zone). |
query-limit | 20 | Most rows /dungeons admin currencies log lists (1 to 100). |
The transaction log
Every balance change is a row of the table sndungeons_currency_log: time, player, currency, type, amount, final balance, cause and actor. Read a player's rows with /dungeons admin currencies log <player> [currency]. The currency may be one you already deleted.
Why it helps. When a player reports lost money, the log shows every change with what caused it.
Row types
| Type | What happened |
|---|---|
GIVE, TAKE, SET, RESET | An admin, a reward or a plugin changed the balance. |
PAY_OUT, PAY_IN | The two sides of a /money pay. |
PAY_REFUND | The part a receiver could not take went back to the payer. |
GAIN | A gameplay gain (zone mob kills, enchants), summed per window. |
COST | A purchase: a level-up, a stage, a tier, an enchant, a shop entry, an upgrade. |
LUCK_FREE | A cost that Luck waived. The balance did not move. |
The same table also holds other progress, each with its own "currency" column:
| Currency column | Types |
|---|---|
level:<track> | LEVEL_UP, LEVEL_GIVE, LEVEL_TAKE, LEVEL_SET, LEVEL_RESET (amounts are levels) |
zone:<zone> | STAGE_UNLOCK, ZONE_SET (amounts are stages) |
sword:tier | SWORD_UPGRADE, SWORD_RESET |
enchant:<id> | ENCHANT_GIVE, ENCHANT_UPGRADE, ENCHANT_SET, ENCHANT_PRESTIGE |
totem-upgrade:<id> | TOTEM_UPGRADE |
Causes
| Cause | Meaning |
|---|---|
command | A currency or leveling command. |
pay | The rows of a payment. |
mob-kill | The rewards of the zone mobs, summed per window. |
leveling:<track> | The COST of a level-up. |
leveling-reward | A reward tag: [give-currency], [set-currency], [reset-currency] and the other reset tags. |
leveling-points:<track> | The upgrade points a level-up gave. |
leveling-upgrade:<track>:<upgrade> | The COST of a leveling upgrade. |
auto | An automatic LEVEL_UP. |
pouch:<id>, pouch:multi | The GIVE of opened pouches, one row per open. |
shop:<entry> | The COST of a shop purchase. |
api:<cause> | Another plugin, through the developer API. |
A discrete change is one row. Gameplay gains are summed per player, currency and cause into one row per window. Rows are written in batches, before every balance save and at shutdown.
Rows are never deleted. On a big server, prune the table yourself from time to time.
Commands
The table uses /money as the example. Every currency with commands has the same set.
| Command | Permission | Description |
|---|---|---|
/money | none | Shows your balance. The console gets the help. |
/money balance [player] (alias bal) | none; another player needs sndungeons.balance.others | Shows your balance or another player's. |
/money pay <player> <amount> | none | Sends part of your balance to another player. Off for /rebirthpoints. |
/money give <player> <amount> | sndungeons.balance.give | Adds to a balance, up to the currency's max-value. |
/money take <player> <amount> (alias remove) | sndungeons.balance.take | Removes from a balance, down to 0. |
/money set <player> <amount> | sndungeons.balance.set | Sets a balance, kept between 0 and max-value. |
/money reset <player> | sndungeons.balance.reset | Sets a balance back to starting-value. |
/money top [page] | none | The players with the highest balance. Off for /rebirthpoints. |
/money shop | none | Opens the shop of the currency. Shown only while the currency has shop: true. |
/money help | none | Lists the subcommands you can use. |
/dungeons admin currencies log <player> [currency] | sndungeons.admin.currencies.log | The latest balance changes of a player, newest first. |
<player>is anyone who joined the server once, online or offline.pay,giveandtakeneed more than 0.setaccepts 0.- The answer shows the amount really moved. When a limit changed it, a second line shows what was asked.
payreaches an offline player only for a currency withoutmax-value. With a limit, the receiver must be online.- The
sndungeons.balance.*nodes are not inplugin.yml, so only operators hold them until you grant them.
Full list: Commands and Permissions.
SnLib adds its reload and debug subcommands to every root. Holders of sndungeons.admin.reload also see /money reload, the same as /dungeons reload.
Placeholders
The balances are in the sndungeons PlaceholderAPI expansion. Full list: Placeholders.
| Placeholder | Description |
|---|---|
%sndungeons_currency_<currency>% | Your balance, short formatted (like 1.5K) |
%sndungeons_currency_<currency>_raw% | Your balance as a plain number |
%sndungeons_currency_<currency>_name% | The currency's display name |
%sndungeons_top_currency_<currency>_<n>_name%, _<n>_value | The player at position n of the top and their balance |
Tips
- Give each currency a distinct color in
display-name: it shows in every message and menu. - An internal currency (
commands-disabled: true) still works everywhere else: rewards, costs, shops and placeholders. - Test a new currency with
/money give <you> 1e500, then check the format in a menu. - Switch to
style: groupedif your players prefer1,500,000over1.5M.
Default currencies/money.yml
# ============================================================
# SnDungeons - currency file (money)
# One file per currency; the currency id is the file name
# (money.yml = money): lowercase letters, digits and '-', at most 64
# characters, extension .yml. Copy this file under a new name to add a
# currency, delete it to remove one; /dungeons reload applies either.
# SnDungeons never updates this file, so a key you delete reads its default.
# The example files are created only when the currencies folder does not
# exist at startup; a single deleted file never comes back.
# Amounts are plain numbers, a suffix of currencies.number-format in
# config.yml (1.5K, 1qa) or an exponent (2.2e25); quote an amount past
# about 1.8e308 ('1e500'), or YAML reads it as infinity.
# ============================================================
# Name shown in messages (color codes allowed).
display-name: '&aMoney'
# Balance of a player who never had one.
starting-value: 0
# Largest balance; 0 means no limit.
max-value: 0
# true = internal currency with no commands at all.
commands-disabled: false
# true = this currency has a shop: /money shop opens the menu
# guis/shop-money.yml, created once from the plugin's template when it does
# not exist (startup or /dungeons reload; delete it and reload to get it
# back). Its shop: block sets what is sold, the prices, the limits per
# rotation and the rotating pool. Works with commands-disabled: true too
# (the menu then opens only through [shop] open money).
shop: false
# The commands of this currency. A permission of '' means no permission is
# needed. A subcommand with enable: false (or without its block) does not
# exist: it is not tab-completed, not listed in the help, and typing it
# answers "unknown subcommand".
commands:
# The root command: /money alone shows the sender's balance (the help when
# balance below is disabled or not allowed for them). If another plugin
# already has this name or an alias, SnDungeons takes it (command priority)
# and that plugin keeps answering as /<plugin>:<name> (/essentials:money).
# A server, vanilla or Brigadier command, or a root of another SnLib plugin
# with command priority, is never taken: then this one answers only as
# /sndungeons:<name>. To leave a name to another plugin, pick another one.
main:
# Command name.
command: money
# Other names of the command.
aliases: []
# Permission needed to use the command at all.
permission: ''
# /money balance [player]: shows a balance. Every subcommand block below
# takes the same keys.
balance:
# false = this subcommand does not exist.
enable: true
# Other names of the subcommand.
aliases: [bal]
# Permission needed; without this key the shipped default applies.
permission: ''
# Needed to see another player's balance.
balance-other-permission: 'sndungeons.balance.others'
# /money pay <player> <amount>: sends part of your balance to a player.
pay:
enable: true
permission: ''
# /money give <player> <amount>: adds to a balance (offline players too).
give:
enable: true
permission: 'sndungeons.balance.give'
# /money take <player> <amount>: removes from a balance, down to 0.
take:
enable: true
aliases: [remove]
permission: 'sndungeons.balance.take'
# /money set <player> <amount>: sets a balance.
set:
enable: true
permission: 'sndungeons.balance.set'
# /money reset <player>: sets a balance back to starting-value.
reset:
enable: true
permission: 'sndungeons.balance.reset'
# /money top [page]: the players with the most money (config.yml tops:). A file
# without this block has it on, for everyone.
top:
enable: true
permission: ''
# /money shop: opens the shop of this currency (shop: true above; with
# shop: false it is hidden and answers that there is no shop). A file
# without this block has it on, for everyone.
shop:
enable: true
permission: ''
# Currency pouches (0.45.0): items that give a random whole amount of this
# currency, evenly spread between min and max, when a player right clicks
# them (shift + right click opens every pouch of THIS currency in the
# inventory at once, any tier; pouches.bulk-limit of config.yml caps it).
# The money is given at once; the title reveal of pouches.animation in
# config.yml is only visual. One block per pouch; its id (lowercase
# letters, digits and '-', at most 32) is the item: the SnLib item
# pouch-<currency>-<id>. Give them with
# /dungeons admin pouch give <player> <currency>:<id> [amount]
# or the reward tag [give-pouch] <currency>:<id> [amount].
# min, max: amounts like the rest of this file (whole numbers).
# item: material, name, lore, glow, custom-model-data; {min}, {max} and
# {currency} are replaced in the name and lore. Opening reads min and
# max of now, so a change applies to the pouches already given (their
# lore keeps the old text, and they no longer stack with new ones).
# sn:extensible
pouches:
t1:
min: 100
max: 10000
item:
material: BUNDLE
name: '&aMoney Pouch &7(Tier 1)'
lore:
- '&7Contains between &a{min} &7and &a{max}'
- ''
- '&8Right click to open'
- '&8Shift + right click to open all'
glow: true
custom-model-data: 0
t2:
min: 10000
max: 1000000
item:
material: BUNDLE
name: '&aMoney Pouch &7(Tier 2)'
lore:
- '&7Contains between &a{min} &7and &a{max}'
- ''
- '&8Right click to open'
- '&8Shift + right click to open all'
glow: true
custom-model-data: 0Default currencies: block of config.yml
# ------------------------------------------------------------
# Currencies. Each file of the currencies/ folder is one currency.
# Re-read on /dungeons reload.
# ------------------------------------------------------------
currencies:
# Seconds between saves of the changed balances of online players (10 to 3600);
# a player's balances are also saved when they quit and when the server stops.
autosave-seconds: 60
# How amounts are written and read (1.5K, 2.2e40).
number-format:
# Most decimals shown (0 to 6); extra decimals are rounded as rounding
# says.
decimals: 2
# Suffix ladder: the first one means thousands (10^3) and each next one is
# 1000 times the previous. Amounts read from text accept them too (1.5M),
# ignoring case. Keep them quoted: YAML reads a bare no as false.
suffixes: ['K', 'M', 'B', 'T', 'qa', 'qi', 'sx', 'sp', 'oc', 'no', 'dc']
# Format of an amount past the last suffix; {mantissa} and {exponent} are
# filled in (2.2e40).
scientific: '{mantissa}e{exponent}'
# How every number of the plugin is written: abbreviated (1.5K, 2.3M, with
# the suffixes above) or grouped (1,500 and 2,300,000 up to 15 digits, then
# the suffixes).
style: abbreviated
# The thousands separator of grouped numbers and the decimal separator
# (one character each, different from each other): ',' and '.' write
# 1,500.25; '.' and ',' write 1.500,25. Typed amounts are read as before
# (1.5K or 1,5K; never a thousands separator).
grouping-separator: ','
decimal-separator: '.'
# How the last decimal shown is decided: half-up (4,996 -> 5K), down
# (4.99K, never more than the value), up, half-even.
rounding: half-up
# Decimals of multipliers (x1.5) and of percents (12.5%), 0 to 6.
multiplier-decimals: 2
percent-decimals: 2
# Transaction log: every balance change is a row of the table
# sndungeons_currency_log (time, player, currency, type, amount, final
# balance, cause, actor). Rows are never deleted.
log:
# Writes the rows; when false nothing is logged (balances still change).
enabled: true
# Gameplay gains of one player, currency and cause are summed into one row
# per this many seconds (1 to 3600).
aggregate-window-seconds: 60
# Seconds between writes of the pending rows to the database (1 to 60).
flush-seconds: 5
# Date and time format of /dungeons admin currencies log (Java
# DateTimeFormatter pattern, server time zone).
time-format: 'yyyy-MM-dd HH:mm:ss'
# Most rows /dungeons admin currencies log lists (1 to 100).
query-limit: 20