DPC Zettelkasten Open in the explorer

Currencies

An expansion letting factions mint physical local currencies as item stacks, and the reference example of a modern Medieval Factions expansion.

Currencies lets the owner of a Faction create and mint a local currency. Money is physical: a currency owns an ItemStack, and minting produces real items that players carry, drop, and lose.

Physical money

That choice has consequences the plugin then has to handle. Currency items can be renamed in an anvil, placed as blocks, and moved between inventories — hence PrepareAnvilListener, BlockPlaceListener, InventoryClickListener, and InventoryCloseListener. A large part of the codebase exists to stop players from counterfeiting or destroying money through ordinary Minecraft mechanics.

Alongside the physical form there is a Balance record and a coinpurse UI, so the abstract and concrete representations coexist.

Lifecycle tied to the faction

Currency carries a factionId and a CurrencyStatus. When a faction disbands, FactionDisbandListener — subscribed to Faction Events — walks that faction's currencies and saves each one with status RETIRED. Nothing is deleted.

Coins already minted therefore survive the state that issued them. That is both historically apt and the practical option: the money is ItemStacks spread across player inventories, chests, and the ground, and nothing in the plugin could recall them.

A faithful copy of the flagship's architecture

Currencies repeats the flagship's shape almost line for line: CurrencyId as a Value Class Identifier, a version column for Optimistic Locking, a CurrencyRepository interface with a JooqCurrencyRepository implementation, a Services registry, and its own Flyway migrations over its own Hikari pool.

The legacyId field is the tell that it, too, has been migrated from an earlier storage format.

See Expansion Plugin for the pattern in general, and Fiefs for the older style it replaced.

Sources

Linked from