📄
Potato_Bank_Complete_Plugin_Prompt_FIXED.txt
txt
843 lines
▶
POTATO BANK — COMPLETE PRODUCTION PLUGIN SPECIFICATION
Create a complete, production-ready Minecraft Paper/Purpur plugin called
“Potato Bank” (final Java package/plugin name may be chosen by the
developer unless I specify otherwise).
IMPORTANT: This specification is the complete current requirement. Do
not remove, simplify, replace, or silently reinterpret any feature
described below. The plugin must be safe against duplication, money
loss, item loss, inventory exploits, race conditions, and
restart/data-loss issues.
The plugin must be designed cleanly so other plugins can connect to its
economy through a public API.
============================================================ 1. MAIN
IDEA ============================================================
The plugin is a central economy/banking system for a Minecraft server.
It has:
1. Personal player bank accounts.
2. Unique bank cards for players.
3. Player-to-player money transfers.
4. A Stonecutter-based “Potato Bank” GUI.
5. SELL and BUY systems for configured ores/items.
6. Configurable ore prices.
7. Three independent city treasuries.
8. Admin controls for city treasuries and ore prices.
9. Scoreboard compatibility.
10. A public API so other plugins can add/remove/read player money and
city treasury money.
11. Persistent data that survives restart/reload/disconnect.
12. Persian player-facing text.
The economy must use one consistent internal integer currency
representation. Do NOT use floating-point values for money. Store money
as a long/integer number of the smallest currency unit to prevent
rounding errors.
============================================================ 2.
STONECUTTER = POTATO BANK
============================================================
A normal VANILLA Minecraft Stonecutter is the physical entry point to
the bank.
When a player right-clicks a Stonecutter, open the custom Potato Bank
GUI.
The GUI title must clearly say:
“بانک پوتیتو”
Do NOT replace the Stonecutter with a custom block.
The Stonecutter itself remains a normal Stonecutter in the world.
Only the custom GUI interaction should be controlled. Do not globally
cancel unrelated inventory or block events.
============================================================ 3. BANK GUI
============================================================
The GUI must have two main sections:
SELL BUY
The visual style should be inspired by the supplied Minecraft inventory
reference: - chest/inventory-style GUI - clean Minecraft appearance -
clear sections - decorative locked slots where necessary - player
inventory visible below - appropriate icons - Persian player-facing text
The exact slot layout can be configured.
The GUI must be secure: - GUI buttons cannot be taken. - Shift-click
cannot steal GUI items. - Dragging cannot place items into protected GUI
slots. - Double-click cannot collect GUI buttons. - Number-key swapping
cannot move protected GUI items. - Offhand swapping cannot exploit the
GUI. - No duplication. - No item loss. - Normal interaction with the
player’s own inventory must continue to work. - Do not globally cancel
InventoryClickEvent or InventoryDragEvent for all inventories.
When a transaction succeeds, keep the GUI open and update it
immediately.
============================================================ 4. SELL
SECTION ============================================================
The SELL section has exactly three main transaction buttons:
1K 10K 100K
These represent money amounts to be credited to the player’s personal
bank.
The configured ore/item is removed from the player’s inventory and the
corresponding money is added to the player’s bank.
The plugin must first verify that the player has enough items.
The transaction must be atomic:
CHECK ITEMS → CALCULATE → REMOVE ITEMS → ADD MONEY
If any step cannot safely complete: - do not remove items - do not add
money - do not partially complete the transaction
Never create money without removing the required item amount.
Never remove items without giving the correct money.
============================================================ 5. BUY
SECTION ============================================================
The BUY section also has exactly three transaction buttons:
1K 10K 100K
These spend money from the player’s personal bank and give the player
the configured ore/item.
The transaction must be:
CHECK BALANCE → CALCULATE ITEM AMOUNT → CHECK INVENTORY CAPACITY →
REMOVE MONEY → GIVE ITEMS
If the player does not have enough money: - do nothing - show a Persian
error - keep GUI open
If the player does not have enough inventory space: - do not remove
money - do not give partial items - show a Persian error - keep GUI open
The plugin must calculate the full resulting inventory state before
changing the bank balance.
============================================================ 6. PRICE
MODEL — IMPORTANT
============================================================
Prices must be configurable per ore/item.
The configuration must support two useful concepts:
A) UNIT PRICE: The value of one item.
Example: DIAMOND = 6
Meaning one Diamond has a value of 6 currency units.
B) OPTIONAL EXACT TRANSACTION RATES: For cases where an exact
1K/10K/100K transaction cannot be represented by a whole number of
items, the configuration may define exact item quantities for each
transaction button.
Example concept:
diamond: unit-price: 6 sell: 1k: 10k: 100k: buy: 1k: 10k: 100k:
Do NOT silently round prices in a way that causes hidden money creation
or loss.
If only unit-price is configured, the plugin must use a deterministic
integer-safe calculation and clearly enforce the configured
rounding/exactness policy. Prefer rejecting an invalid configuration at
startup rather than silently producing an unfair transaction.
The developer may choose the cleanest exact implementation, but it must
never use floating-point money calculations.
The price displayed to players must always match the active
configuration.
============================================================ 7.
SUPPORTED ORES
============================================================
Initial money-related ores/items:
- IRON
- DIAMOND
- NETHERITE
- COPPER
- GOLD
The system must be expandable so more items can be added later.
Each item must have: - Minecraft material - configurable price -
configurable display name/icon if needed - optional custom-item
identification support
Do not hard-code these prices.
============================================================ 8. ORE
PRICE DISPLAY IN ITEM LORE
============================================================
When an ore is configured as a money-related item, its value should be
visible in its item description/lore when the player hovers over it.
Example:
Diamond
ارزش: 6$
The exact Persian wording can be configured.
The lore system must not corrupt normal Minecraft items.
If changing the lore of vanilla items is unsafe or conflicts with
another plugin/resource pack, use a safe implementation or configurable
display behavior.
The active price must be shown correctly.
============================================================ 9. PLAYER
BANK ACCOUNT
============================================================
Every player has a persistent personal bank balance identified by UUID.
The balance must survive: - server restart - plugin reload where
supported - player disconnect - reconnect
Never rely only on RAM.
Use safe persistent storage.
Money must be stored as an integer/long, never float/double.
The implementation must protect against negative balances unless an
explicit future feature enables debt.
============================================================ 10. /money
============================================================
Command:
/money
Show the player’s current personal bank balance.
Example:
موجودی بانک شما: 250K
The exact message must be configurable in Persian.
============================================================ 11. /money
card ============================================================
Command:
/money card
Show the player’s bank-card information in chat.
Example:
━━━━━━━━━━━━━━━━ کارت بانکی ━━━━━━━━━━━━━━━━ نام: mamad_mango بانک: بانک
جمهوری پوتیتو شماره کارت: 4821-7392-1546-8273 ━━━━━━━━━━━━━━━━
Every player must receive a unique bank-card number generated by the
plugin.
Requirements: - card numbers must be unique - card number must remain
unchanged after restart - card number must be stored persistently - a
player’s card is linked to their UUID - invalid/duplicate card numbers
must never be generated
The bank name should be:
“بانک جمهوری پوتیتو”
============================================================ 12. /money
pay ============================================================
Command:
/money pay
Example:
/money pay 4821-7392-1546-8273 10K
The sender pays the specified amount to the owner of the target card.
Requirements: 1. Validate card number. 2. Find target player account. 3.
Parse amount safely. 4. Check sender balance. 5. Prevent self-transfer
if configured as disallowed. 6. Remove money from sender. 7. Add money
to receiver. 8. Save both accounts safely. 9. Send Persian success
messages.
The transfer must be atomic.
Never remove money from the sender unless the receiver will receive it
successfully.
If the target card does not exist: - no money is removed.
If sender has insufficient funds: - no money is removed.
============================================================ 13. MONEY
AMOUNT FORMAT
============================================================
The money parser must support:
1 1K 10K 100K 1M 10M 100M 1B 10B 100B
Meaning:
1K = 1,000 10K = 10,000 100K = 100,000
1M = 1,000,000 10M = 10,000,000 100M = 100,000,000
1B = 1,000,000,000 10B = 10,000,000,000 100B = 100,000,000,000
Parsing should be case-insensitive, so k/K, m/M, b/B may be accepted.
The parser should also support plain integer values where appropriate.
Reject: - negative amounts - zero amounts - invalid text - overflow -
values larger than the internal supported maximum
Do not use floating-point parsing.
============================================================ 14. CITY
TREASURIES ============================================================
There are exactly three cities initially:
شهر 1 شهر 2 شهر 3
Each city has an independent treasury.
Example:
خزانه شهر 1: 500K خزانه شهر 2: 2M خزانه شهر 3: 75M
City treasury money is separate from personal player-bank money.
Do not mix these balances.
Each treasury must persist across server restarts.
============================================================ 15. PLAYER
TREASURY VIEW COMMAND
============================================================
Normal players can view treasury balances.
The treasury commands MUST use ASCII/Finglish command names so they are
easy to type and reliable in Minecraft command parsing.
Required commands:
/khazane shahr1
/khazane shahr2
/khazane shahr3
The player-facing output and usage/help text must remain Persian.
IMPORTANT: Every command and subcommand must provide in-game
TAB-completion/autocomplete. When the player types a command and presses
TAB, the game must show the valid next options so the player can select
them instead of having to remember or manually type them.
Examples:
/khazane → shahr1, shahr2, shahr3
/khazane shahr1 → add (only if the player has the required admin
permission; otherwise no admin-only option should be suggested)
Players can VIEW the treasury.
Normal players cannot add/remove treasury money.
Example output:
خزانه شهر 1 موجودی: 500K
============================================================ 16. ADMIN
TREASURY COMMANDS
============================================================
Admins have access to treasury management.
They must be able to add money to a selected city’s treasury.
Required command structure:
/khazane shahr1 add 100K
/khazane shahr2 add 1M
/khazane shahr3 add 10M
Also support the same command structure for viewing a treasury:
/khazane shahr1
/khazane shahr2
/khazane shahr3
TAB-completion is REQUIRED for every part of this command. The player
must be able to press TAB to receive valid suggestions for city names,
admin subcommands, and valid argument positions. Amount is a free-form
money value and must be validated by the command parser; do not suggest
unsafe or invalid values.
Permissions must be used so normal players cannot perform admin
operations.
Do not allow negative additions or malformed amounts.
All changes must be persisted.
The exact final admin command aliases can be configurable.
============================================================ 17. ORE
PRICE ADMIN COMMAND
============================================================
Admins need a money/ore price management command.
The REQUIRED command structure is:
/money price
Initial ores available for selection:
- iron
- diamond
- netherite
- copper
- gold
Example:
/money price diamond 6
The command MUST provide full in-game TAB-completion/autocomplete:
/money → card, pay, price
/money price → iron, diamond, netherite, copper, gold
/money price diamond → valid price argument position
Only ores that are actually configured/supported may be suggested.
Admin-only subcommands must only appear in TAB-completion for players
who have the required permission.
Admin must also be able to change existing prices.
Changing a price must update the active economy immediately and persist
it.
Do not require a server restart for normal price changes unless
technically unavoidable.
============================================================ 18. ORE
PRICE INFORMATION
============================================================
If an admin sets:
Diamond = 6
then the player’s Diamond item information should display its current
value.
Example:
Diamond ارزش: 6$
If the admin changes it to 10, the displayed active value must become
10$.
The economy must always use the current configured price.
============================================================ 19.
SCOREBOARD COMPATIBILITY
============================================================
The plugin must expose the player’s current money in a way that a
scoreboard plugin can read.
Example scoreboard:
━━━━━━━━━━━━━━ POTITO ━━━━━━━━━━━━━━ پول: 250K ━━━━━━━━━━━━━━
Do NOT force the plugin to replace or control an existing scoreboard
unless explicitly configured.
Instead, expose: - player balance getter - formatted balance - raw
numeric balance
A scoreboard or another plugin should be able to request the current
value.
If a Vault-style integration is practical, support it without making
Vault mandatory unless required by the final implementation.
============================================================ 20. PUBLIC
API / OTHER PLUGIN INTEGRATION
============================================================
This is a core requirement.
Other plugins must be able to connect to Potato Bank.
For example, a future Robbery plugin may need to steal money from a city
treasury.
The Robbery plugin should be able to call something conceptually like:
getPlayerBalance(UUID) setPlayerBalance(UUID, amount)
addPlayerMoney(UUID, amount) removePlayerMoney(UUID, amount)
getCityTreasury(city) setCityTreasury(city, amount)
addCityTreasury(city, amount) removeCityTreasury(city, amount)
The API must: - use integer/long money values - validate negative
amounts - prevent balances from becoming invalid - be thread-safe where
needed - provide success/failure results for operations - never silently
fail - be documented clearly enough for another plugin developer to use
Example future use:
Robbery plugin: “Remove 50K from City 1 treasury.”
Potato Bank: City 1 treasury decreases by exactly 50,000.
Another plugin: “Add 100K to City 2 treasury.”
Potato Bank: City 2 treasury increases by exactly 100,000.
============================================================ 21. FUTURE
ROBBERY COMPATIBILITY
============================================================
Do NOT implement the robbery system itself yet.
Only make Potato Bank capable of supporting it through the API.
A future robbery plugin might: - identify a bank belonging to a city -
request money from that city’s treasury - remove the stolen amount
through Potato Bank API
Potato Bank must not have hard-coded knowledge of a future robbery
plugin.
Use a clean API/event architecture.
============================================================ 22.
TRANSACTION SAFETY
============================================================
Every economy-changing operation must be safe.
For player-to-player payment:
VALIDATE → LOCK/TRANSACTION → REMOVE SENDER MONEY → ADD RECEIVER MONEY →
PERSIST BOTH → COMPLETE
For treasury operations:
VALIDATE → MODIFY TREASURY → PERSIST → COMPLETE
For SELL:
VALIDATE ITEMS → CALCULATE → REMOVE ITEMS → ADD BANK MONEY → PERSIST
For BUY:
VALIDATE BALANCE → CALCULATE ITEMS → CHECK INVENTORY SPACE → REMOVE BANK
MONEY → GIVE ITEMS → PERSIST
If anything fails, rollback where required.
Do not create money due to duplicate event firing.
Do not remove money twice.
Do not process a click twice.
Do not allow shift-click/drag/click spam to duplicate transactions.
============================================================ 23.
INVENTORY CAPACITY
============================================================
BUY operations must check whether the player can receive the complete
item quantity.
If not: - do not remove money - do not give partial items - show a
Persian message
SELL operations must remove exactly the configured amount.
If the player disconnects during a transaction, the operation must
remain consistent.
============================================================ 24. RESTART
/ CRASH SAFETY
============================================================
All balances, cards, prices, and treasuries must persist.
At minimum persist: - UUID - player name if useful - card number -
personal balance - city treasury balances - ore prices/configured
economy values
Do not lose transactions because of a server restart.
Use safe saving.
============================================================ 25.
PERMISSIONS ============================================================
Normal players: - /money - /money card - /money pay - view city
treasuries - use Stonecutter bank GUI
Admins: - change ore prices - add/manage treasury money - access
administrative economy information
Use separate permissions for: - player commands - price administration -
treasury administration - economy administration
Do not grant admin permissions to everyone.
============================================================ 26. PERSIAN
PLAYER-FACING LANGUAGE
============================================================
All player-facing text must be Persian.
Examples:
موجودی بانک شما: پرداخت با موفقیت انجام شد. موجودی شما کافی نیست. شماره
کارت پیدا نشد. این مقدار پول معتبر نیست. فضای کافی در اینونتوری ندارید.
این عملیات فقط برای ادمین است. قیمت الماس تغییر کرد. موجودی خزانه شهر ۱:
فروش با موفقیت انجام شد. خرید با موفقیت انجام شد.
Messages must be configurable.
Commands/permission nodes can use ASCII-safe internal identifiers when
necessary, but player-facing descriptions, GUI labels, errors, and
outputs should be Persian.
============================================================ 27. DATA
MODEL ============================================================
Use a clean persistent data model.
Suggested player record:
PlayerAccount: - UUID - cardNumber - balance
Suggested city record:
CityTreasury: - cityId - balance
Suggested ore record:
OrePrice: - material - unitPrice - optional sell transaction
quantities - optional buy transaction quantities
Do not use player names as the primary account identifier.
UUID is authoritative.
============================================================ 28.
CONFIGURATION
============================================================
Provide a clear configuration file.
It must allow configuration of: - GUI title - GUI slots - GUI icons -
messages - permissions - city names - city IDs - ore prices -
transaction values - supported materials - card-number format - economy
limits - language/messages
Example conceptual configuration:
cities: city1: name: “شهر 1” city2: name: “شهر 2” city3: name: “شهر 3”
ores: diamond: material: DIAMOND unit-price: 6 iron: material: IRON
unit-price: 1 gold: material: GOLD_INGOT unit-price: 3 copper: material:
COPPER_INGOT unit-price: 1 netherite: material: NETHERITE_INGOT
unit-price: 100
These values are examples only and must not be treated as final prices.
============================================================ 29.
IMPORTANT: NO HIDDEN ASSUMPTIONS
============================================================
Do not invent additional economy features such as: - loans - interest -
taxes - ATM system - offline fees - bank limits - debt - gambling -
automatic city taxes
unless they are explicitly added later.
Build the current requested system only.
============================================================ 30. ERROR
HANDLING ============================================================
Handle: - invalid command syntax - invalid card number - card not
found - insufficient balance - insufficient items - full inventory -
invalid amount - negative amount - zero amount - integer overflow -
invalid ore - invalid city - unauthorized admin command -
database/storage errors - duplicate transaction events - player
disconnect during transaction
Errors must be safe and Persian.
============================================================ 31.
SECURITY / EXPLOIT PREVENTION
============================================================
The plugin must specifically prevent: - double-click money duplication -
shift-click duplication - drag duplication - reconnect duplication -
restart duplication - negative payment - integer overflow - fake card
numbers - duplicate card numbers - modifying GUI buttons - withdrawing
items from decorative GUI slots - paying a nonexistent card - paying
without enough money - selling without enough items - creating money
through failed transactions - destroying money through failed
transactions
============================================================ 32. FINAL
FUNCTIONAL FLOW
============================================================
PLAYER BANK:
/money → view balance
/money card → view bank card
/money pay → transfer money
/money price → admin: set/change ore price
All commands MUST have in-game TAB-completion/autocomplete. The plugin
must register command suggestions through the appropriate Paper/Bukkit
command completion system. Suggestions must be context-aware, permission-
aware, and limited to valid commands, subcommands, ores, cities, and
other safe argument choices.
Examples:
/money → card, pay, price
/money pay → valid/known bank-card choices where safely available
/money price → iron, diamond, netherite, copper, gold
/khazane → shahr1, shahr2, shahr3
/khazane shahr1 → add (only for authorized admins)
Do not require players to memorize command names when a valid TAB
suggestion can be provided by the game.
All internal command names must be ASCII/Finglish. Player-facing
messages, help text, GUI labels, errors, and outputs remain Persian.
STONECUTTER:
Right-click Stonecutter → بانک پوتیتو → SELL / BUY
SELL: 1K / 10K / 100K → configured ore → remove ore → add money to
player’s bank
BUY: 1K / 10K / 100K → remove money from player’s bank → give configured
ore
CITY TREASURY:
/khazane shahr1 → view City 1 treasury
/khazane shahr2 → view City 2 treasury
/khazane shahr3 → view City 3 treasury
Admin: → add/manage treasury money
ORE PRICE:
Admin: → set/change ore price
Player: → hover configured ore → see current value in lore
EXTERNAL PLUGINS:
Other plugin → Potato Bank API → read/add/remove player money →
read/add/remove city treasury
SCOREBOARD:
Scoreboard plugin → Potato Bank API → read current player balance →
display it
============================================================ 33. QUALITY
REQUIREMENT ============================================================
The finished plugin must be production-ready.
Requirements: - clean architecture - maintainable code - no unnecessary
global event cancellation - no memory-only economy data - no
floating-point money - safe persistent storage - atomic transactions -
clear API - configurable GUI - configurable prices - Persian messages -
safe inventory handling - safe command parsing - safe restart behavior -
no duplication exploits
Before considering the plugin complete, test: 1. first player account
creation 2. card generation 3. /money 4. /money card 5. /money pay 6.
insufficient balance 7. invalid card 8. Stonecutter GUI 9. SELL 10. BUY
11. inventory full 12. GUI shift-click 13. GUI drag 14. GUI double-click
15. city treasury view 16. admin treasury add 17. ore price change 18.
lore price display 19. scoreboard balance reading 20. external API money
add/remove 21. external API treasury add/remove 22. server restart 23.
player disconnect/reconnect 24. transaction spam 25. duplicate event
protection
The implementation must not claim a feature works unless it is actually
implemented and tested.
============================================================ FINAL GOAL
============================================================
Build “Potato Bank” as the central economy of the Minecraft server.
The final system must connect:
PLAYER BANK + BANK CARD + PLAYER PAYMENTS + STONECUTTER BANK GUI + ORE
BUY/SELL + ORE PRICES + THREE CITY TREASURIES + ADMIN TREASURY
MANAGEMENT + SCOREBOARD COMPATIBILITY + PUBLIC API FOR OTHER PLUGINS
All money must use one consistent persistent economy.
All transactions must be secure and atomic.
All player-facing text must be Persian.
The system must be extensible so future plugins such as a
Robbery/Bank-Robbery plugin can safely connect to city treasuries
without rewriting the Potato Bank economy.
📄
pasted-code-1790867831186.txt
txt
310 lines
▶
============================================================ 34. MONEY TOP / CITY TOP
============================================================
Add a ranking system for both personal player money and city treasury
balances.
IMPORTANT:
This feature must be fully integrated with the existing Potato Bank economy.
Do not create a separate money system.
Use the same persistent player balances and city treasury balances already
used by Potato Bank.
============================================================ 34.1 /money top
============================================================
Command:
/money top
This command must display the TOP 10 richest players based on their current
personal Potato Bank balance.
Ranking must be calculated from the actual persistent player balances.
The ranking must contain exactly the first 10 players when at least 10
players/accounts exist.
Sort players from highest balance to lowest balance:
#1 = highest money
#2 = second highest
#3 = third highest
...
#10 = tenth highest
Example chat output:
━━━━━━━━━━━━━━━━━━━━━━━━
MONEY TOP
━━━━━━━━━━━━━━━━━━━━━━━━
🥇 1. PlayerName 250M
🥈 2. PlayerName 180M
🥉 3. PlayerName 120M
4. PlayerName 95M
5. PlayerName 80M
6. PlayerName 65M
7. PlayerName 50M
8. PlayerName 35M
9. PlayerName 20M
10. PlayerName 10M
━━━━━━━━━━━━━━━━━━━━━━━━
The exact visual format can be configurable, but the ranking order must
always be correct.
All player-facing text must remain Persian.
The command itself must remain:
/money top
The plugin must support TAB completion so that when a player types:
/money
the available subcommands are suggested, including:
card
pay
price
top
Admin-only subcommands must only be suggested to players who have the
required permission.
============================================================ 34.2 MONEY TOP RULES
============================================================
The ranking must:
- Use the current real player balance.
- Include offline players.
- Include online players.
- Never create or modify money while calculating the ranking.
- Never reset balances because of ranking calculations.
- Never use player names as the account identifier.
- Use UUID as the authoritative account identifier.
- Display the player's current/latest known name.
- Sort strictly by balance from highest to lowest.
- Display positions 1 through 10.
- If fewer than 10 accounts exist, display only the available accounts.
- Never display duplicate players.
- Never expose internal UUIDs.
- Never allow ranking calculations to cause an economy transaction.
- Be safe during concurrent money transactions.
If two players have exactly the same balance, use a deterministic tie-breaker
so the ordering does not randomly change between executions.
============================================================ 34.3 /money citytop
============================================================
Command:
/money citytop
This command must display the TOP 3 cities based on their current treasury
balance.
The three existing cities are:
شهر 1
شهر 2
شهر 3
Sort cities from the highest treasury balance to the lowest treasury balance.
Example:
━━━━━━━━━━━━━━━━━━━━━━━━
CITY TOP
━━━━━━━━━━━━━━━━━━━━━━━━
🥇 1. شهر 1 500M
🥈 2. شهر 3 300M
🥉 3. شهر 2 150M
━━━━━━━━━━━━━━━━━━━━━━━━
The city with the highest treasury must always be position 1.
The city with the second-highest treasury must always be position 2.
The city with the third-highest treasury must always be position 3.
Do not modify city treasury balances while calculating the ranking.
============================================================ 34.4 CITY TOP RULES
============================================================
City ranking must:
- Use the actual persistent city treasury balance.
- Include all three configured cities.
- Sort from highest treasury to lowest treasury.
- Always display the correct ranking.
- Never create or remove treasury money.
- Never transfer money between cities.
- Never modify player balances.
- Never reset treasury balances.
- Be safe during concurrent treasury transactions.
If two cities have exactly the same treasury balance, use a deterministic
tie-breaker based on city ID so the ordering remains stable.
============================================================ 34.5 COMMAND COMPLETION
============================================================
Both commands must have proper Minecraft Brigadier/tab completion.
Commands:
/money top
/money citytop
When the player types:
/money
the plugin must show the valid available subcommands.
The completion must be implemented as actual command completion, not as
instructions written in chat.
The plugin must correctly register command arguments and suggestions so
Minecraft itself displays the selectable options.
============================================================ 34.6 PERFORMANCE
============================================================
The ranking system must not scan or load unnecessary data repeatedly on every
single chat character or TAB press.
Use an efficient approach appropriate for the persistent storage system.
Ranking calculations must never block the Minecraft main thread with a large
database operation.
If caching is used, it must be invalidated or refreshed whenever a player's
balance or city's treasury balance changes so the displayed ranking does not
become incorrectly outdated.
The displayed ranking must reflect the latest valid economy state.
============================================================ 34.7 PERSISTENCE AND SAFETY
============================================================
Money Top and City Top are READ-ONLY features.
They must never modify:
- player balance
- city treasury
- bank cards
- ore prices
- inventory
- economy data
They must remain functional after:
- server restart
- plugin reload where supported
- player disconnect/reconnect
The ranking system must use the same persistent data source as the main
Potato Bank economy.
============================================================ 34.8 PERMISSIONS
============================================================
Normal players should be allowed to use:
/money top
/money citytop
No administrator permission should be required unless explicitly configured.
Add configurable permission nodes if desired, but normal players must be able
to use the ranking commands by default.
============================================================ 34.9 PERSIAN DISPLAY
============================================================
Although the commands are ASCII/Finglish:
/money top
/money citytop
all player-facing ranking text must be Persian.
For example:
━━━━━━━━━━━━━━━━━━━━━━━━
برترین بازیکنان
━━━━━━━━━━━━━━━━━━━━━━━━
🥇 ۱. mamad_mango — 250M
🥈 ۲. Player2 — 180M
🥉 ۳. Player3 — 120M
۴. Player4 — 95M
...
۱۰. Player10 — 10M
And:
━━━━━━━━━━━━━━━━━━━━━━━━
برترین شهرها
━━━━━━━━━━━━━━━━━━━━━━━━
🥇 ۱. شهر ۱ — 500M
🥈 ۲. شهر ۳ — 300M
🥉 ۳. شهر ۲ — 150M
All ranking messages must be configurable.
============================================================ 34.10 API COMPATIBILITY
============================================================
The ranking system must use the existing Potato Bank public API/data layer.
If another plugin adds or removes player money through the Potato Bank API,
the player's position in /money top must eventually reflect the updated
balance.
If another plugin adds or removes city treasury money through the Potato Bank
API, /money citytop must eventually reflect the updated treasury balance.
Do not create a second balance storage system for rankings.
============================================================ 34.11 FINAL COMMAND LIST
============================================================
Player commands:
/money
/money card
/money pay
/money top
/money citytop
Admin price command:
/money price
City treasury commands remain:
/khazane shahr1
/khazane shahr2
/khazane shahr3
Admin treasury operations remain available through the existing treasury
administration system.
All commands must support proper TAB completion and suggestions inside
Minecraft.
============================================================ END OF MONEY TOP / CITY TOP
============================================================
📄
pasted-code-1790867847280.txt
txt
205 lines
▶
============================================================ 35. STONECUTTER ORE ACCEPTANCE FIX
============================================================
IMPORTANT BUG FIX — DO NOT CHANGE ANY OTHER FEATURE.
There is currently a bug in the Potato Bank Stonecutter/Bank GUI:
The Stonecutter bank currently accepts ONLY DIAMOND.
This is incorrect.
The Stonecutter Bank GUI must accept ALL configured money-related ores/items
that are already defined in the Potato Bank specification.
The supported initial items are EXACTLY:
1. IRON
2. DIAMOND
3. NETHERITE
4. COPPER
5. GOLD
The player must be able to use ALL of these items in the Stonecutter Bank
SELL system.
============================================================
35.1 SELL ITEM SUPPORT
============================================================
The SELL system inside the Stonecutter Bank GUI must recognize:
IRON
DIAMOND
NETHERITE
COPPER
GOLD
Do NOT hard-code the SELL system to accept Diamond only.
The currently selected/configured ore or item must be determined from the
Potato Bank ore configuration.
If an item is configured as a supported money-related item, the Stonecutter
Bank SELL system must recognize it automatically.
Example:
ores:
iron:
material: IRON
diamond:
material: DIAMOND
netherite:
material: NETHERITE
copper:
material: COPPER_INGOT
gold:
material: GOLD_INGOT
The exact configured Material must be used.
Do NOT assume every configured item is a block.
Do NOT accept unrelated items.
============================================================
35.2 BUY SYSTEM
============================================================
The same configured items must also work in the BUY section.
If the player selects:
IRON → BUY → receive IRON
DIAMOND → BUY → receive DIAMOND
NETHERITE → BUY → receive NETHERITE
COPPER → BUY → receive COPPER
GOLD → BUY → receive GOLD
The BUY system must use the exact Material configured for that item.
============================================================
35.3 PRICE INTEGRATION
============================================================
Each supported item must use its own configured price.
Example:
IRON → its configured price
DIAMOND → its configured price
NETHERITE → its configured price
COPPER → its configured price
GOLD → its configured price
Never use Diamond's price for another item.
Never use a hard-coded Diamond price for all items.
When an admin changes an item's price using:
/money price
the Stonecutter Bank must immediately use the new price for that item.
No server restart should be required.
============================================================
35.4 STONECUTTER GUI ITEM SELECTION
============================================================
The Stonecutter Bank GUI must provide a clear way for the player to select
which configured ore/item they want to SELL or BUY.
The available items must be generated from the configured ore/item list.
At minimum, the initial list must support:
IRON
DIAMOND
NETHERITE
COPPER
GOLD
Do not create separate hard-coded transaction logic for Diamond.
All supported items must use the same secure transaction system.
============================================================
35.5 TRANSACTION SAFETY
============================================================
The existing transaction safety requirements MUST remain unchanged.
For SELL:
CHECK ITEM → CHECK CONFIGURATION → CALCULATE PRICE →
REMOVE EXACT ITEM AMOUNT → ADD EXACT MONEY → SAVE
For BUY:
CHECK BALANCE → CALCULATE ITEM AMOUNT → CHECK INVENTORY →
REMOVE MONEY → GIVE EXACT ITEM → SAVE
If anything fails:
DO NOT remove the player's items.
DO NOT remove the player's money.
DO NOT create money.
DO NOT give partial items.
All existing anti-duplication protections must remain active.
============================================================
35.6 DO NOT BREAK ANYTHING ELSE
============================================================
IMPORTANT:
This is ONLY a bug fix for the Stonecutter Bank ore/item acceptance.
DO NOT change:
- /money
- /money card
- /money pay
- /money top
- /money citytop
- /money price
- bank cards
- player balances
- city treasuries
- city commands
- scoreboard API
- public API
- database/storage
- permissions
- TAB completion
- Persian messages
- GUI security
- transaction safety
- restart protection
- existing price system
- existing configuration structure
Do not remove any existing feature.
Do not rewrite unrelated systems.
Do not introduce a second economy system.
Only fix the Stonecutter Bank so that ALL configured supported ores/items
work correctly instead of Diamond only.
============================================================
END OF STONECUTTER ORE ACCEPTANCE FIX
============================================================
📄
pasted-code-1790867913249.txt
txt
437 lines
▶
========================================
36. UNIVERSAL ECONOMY API & PLUGIN INTEGRATION
========================================
PotatoBank must provide a complete, production-ready public Economy API so other Bukkit/Paper plugins can safely add, remove, check, set, and transfer money using the SAME PotatoBank balance.
IMPORTANT:
There must NEVER be a second or separate balance system.
All plugins must use the exact same persistent PotatoBank account.
----------------------------------------
36.1 PUBLIC ECONOMY API
----------------------------------------
Create a clean public Java API, for example:
getBalance(UUID player)
hasBalance(UUID player, long amount)
deposit(UUID player, long amount)
withdraw(UUID player, long amount)
setBalance(UUID player, long amount)
transfer(UUID from, UUID to, long amount)
All amounts MUST use long/integer smallest currency units.
NEVER use double or float for money.
Example:
long balance = PotatoBankAPI.getBalance(uuid);
PotatoBankAPI.deposit(uuid, 500);
PotatoBankAPI.withdraw(uuid, 250);
----------------------------------------
36.2 SAFE MONEY OPERATIONS
----------------------------------------
Every deposit, withdrawal, set, and transfer operation must be atomic and thread-safe.
Rules:
- Never allow negative balances.
- Never allow negative transaction amounts.
- Never allow integer overflow.
- Never duplicate money.
- Never delete money accidentally.
- Never perform a partial transfer.
- If a transfer fails, both accounts must remain unchanged.
- All changes must be persisted safely.
- The API must work correctly with concurrent transactions.
- The API must use the existing PotatoBank storage.
- Do not create another database/table/file for external plugins.
----------------------------------------
36.3 OTHER PLUGINS MUST BE ABLE TO ADD MONEY
----------------------------------------
Other plugins must be able to call:
PotatoBankAPI.deposit(playerUUID, amount);
Example:
A quest plugin rewards:
+500 money
A shop plugin gives:
+1000 money
A voting plugin gives:
+250 money
A minigame plugin gives:
+5000 money
All of these MUST increase the player's actual PotatoBank balance.
----------------------------------------
36.4 OTHER PLUGINS MUST BE ABLE TO REMOVE MONEY
----------------------------------------
Other plugins must be able to call:
PotatoBankAPI.withdraw(playerUUID, amount);
Example:
Shop:
-500 money
Auction:
-1000 money
Teleport:
-250 money
Tax:
-100 money
The withdrawal must fail if the player does not have enough money.
Never allow the balance to become negative.
----------------------------------------
36.5 CHECK BALANCE
----------------------------------------
Other plugins must be able to safely check:
PotatoBankAPI.getBalance(playerUUID)
and:
PotatoBankAPI.hasBalance(playerUUID, amount)
Example:
if (PotatoBankAPI.hasBalance(uuid, 1000)) {
// allow purchase
}
----------------------------------------
36.6 TRANSFER API
----------------------------------------
Provide:
PotatoBankAPI.transfer(fromUUID, toUUID, amount);
The transfer must be atomic.
Example:
Player A:
1000
Player B:
500
Transfer:
300
Result:
Player A:
700
Player B:
800
Never allow duplication or loss of money.
----------------------------------------
36.7 PUBLIC BUKKIT SERVICE
----------------------------------------
Register PotatoBank as a Bukkit/Paper service so other plugins can access the economy without depending on internal implementation classes.
Use Bukkit ServicesManager.
Example concept:
Bukkit.getServicesManager().register(
PotatoBankEconomy.class,
economyAPI,
this,
ServicePriority.Normal
);
Other plugins should be able to obtain the service through ServicesManager.
Do not force external plugins to access private PotatoBank classes.
----------------------------------------
36.8 VAULT COMPATIBILITY
----------------------------------------
Add optional Vault compatibility.
If Vault is installed:
- Register PotatoBank as a Vault Economy provider.
- Vault plugins must be able to:
- get balance
- deposit money
- withdraw money
- transfer/pay money
- check if a player has enough money
- format money
Vault must use the SAME PotatoBank balance.
NEVER create a second Vault balance.
If Vault is not installed, PotatoBank must continue working normally.
Vault must be an optional dependency.
----------------------------------------
36.9 PLACEHOLDERAPI SUPPORT
----------------------------------------
If PlaceholderAPI is installed, register a PotatoBank PlaceholderAPI expansion.
Required placeholders:
%potatobank_balance%
%potatobank_balance_formatted%
Example:
Balance:
125000
Output:
%potatobank_balance%
→ 125000
%potatobank_balance_formatted%
→ 125K
The formatted placeholder must use the SAME money formatter already used by PotatoBank.
Do not create another balance source.
These placeholders must work in:
- TAB
- Scoreboard
- Chat plugins
- Holograms
- Other PlaceholderAPI-compatible plugins
----------------------------------------
36.10 SCOREBOARD INTEGRATION
----------------------------------------
The PotatoBank balance must be available in the scoreboard through:
%potatobank_balance%
and:
%potatobank_balance_formatted%
The scoreboard must automatically update when the player's balance changes.
Example:
Before:
MONEY
100K
Player receives 5000:
MONEY
105K
Player spends 2000:
MONEY
103K
Do not require the player to relog.
Do not require a server restart.
----------------------------------------
36.11 MONEY CHANGE EVENTS
----------------------------------------
Create public Bukkit events for money changes.
Example:
PotatoBankMoneyChangeEvent
The event should provide:
- Player UUID
- Previous balance
- New balance
- Amount changed
- Change type
- Source/reason if available
- Whether the transaction succeeded
Possible change types:
DEPOSIT
WITHDRAW
TRANSFER
SET
Other plugins must be able to listen to these events.
Example:
@EventHandler
public void onMoneyChange(PotatoBankMoneyChangeEvent event) {
// react to money changes
}
Events must only be fired after a successful atomic transaction.
----------------------------------------
36.12 TRANSACTION SOURCE / REASON
----------------------------------------
Allow external plugins to specify a transaction source/reason.
Example:
deposit(uuid, 500, "Quest Reward");
withdraw(uuid, 1000, "Shop Purchase");
deposit(uuid, 250, "Voting Reward");
This reason can be used by logging systems and admin/debugging tools.
Do not make the reason affect the amount or balance calculation.
----------------------------------------
36.13 ADMIN / DEBUG INFORMATION
----------------------------------------
Provide a way for administrators to identify external economy operations.
Example:
[PotatoBank] +500 from QuestPlugin
[PotatoBank] -1000 from ShopPlugin
Do not spam normal players with technical information.
----------------------------------------
36.14 PLUGIN DEPENDENCY SAFETY
----------------------------------------
PotatoBank must continue working if:
- Vault is missing.
- PlaceholderAPI is missing.
- Other optional plugins are missing.
Optional integrations must fail gracefully.
PotatoBank must never crash because an optional plugin is not installed.
----------------------------------------
36.15 API MUST USE THE SAME STORAGE
----------------------------------------
This is extremely important:
Commands:
/money
/money pay
/money top
Stonecutter transactions
Admin money operations
Vault
PlaceholderAPI
External plugin API
Scoreboard
TAB
ALL MUST READ AND WRITE THE SAME persistent PotatoBank balance.
There must be exactly ONE source of truth for player money.
----------------------------------------
36.16 NO DUPLICATION THROUGH API
----------------------------------------
Protect the economy API against:
- double deposits
- double withdrawals
- duplicate events
- repeated transaction callbacks
- concurrent transactions
- server restart during transaction
- plugin reload
- player logout during transaction
Use proper synchronization/atomic database operations where necessary.
----------------------------------------
36.17 COMPATIBILITY TARGET
----------------------------------------
Target:
Paper 1.21.11
Java 21
The API must be compatible with other Bukkit/Paper plugins.
Keep public API classes stable and documented.
Do not expose internal database implementation details as the public API.
----------------------------------------
36.18 FINAL REQUIREMENT
----------------------------------------
The finished PotatoBank plugin must function as the CENTRAL ECONOMY SYSTEM of the server.
Any compatible plugin must be able to:
ADD money
REMOVE money
CHECK money
SET money
TRANSFER money
READ formatted money
LISTEN for money changes
while always using the SAME PotatoBank balance.
The implementation must be production-ready, thread-safe, persistent, duplication-safe, restart-safe, and compatible with Paper 1.21.11.
Create the Paper plugin, SQLite-backed shared economy, public Bukkit service/API, and money-change events.
Add Persian commands, rankings, treasury administration, secure Stonecutter trading GUI, and live ore-price lore.
Add optional Vault and PlaceholderAPI integrations, defaults, permissions, and plugin metadata.
Created the PotatoBank Paper plugin with SQLite-backed accounts/cards/treasuries/prices, Persian commands and rankings, a protected Stonecutter trading GUI, live ore-price lore, a public Bukkit API with money-change events, and optional Vault/PlaceholderAPI integrations.
Verification: I did not compile or test this on a server, so it is not verified as production-ready. In particular, SQLite and Minecraft inventory persistence are separate systems; crash-safe atomicity across a GUI item transaction and a server power loss has not been established.
package dev.potatobank;
import dev.potatobank.api.PotatoBankAPI;
import dev.potatobank.command.MoneyCommand;
import dev.potatobank.command.TreasuryCommand;
import dev.potatobank.economy.OreRegistry;
import dev.potatobank.economy.PotatoBankEconomyService;
import dev.potatobank.gui.BankGui;
import dev.potatobank.integration.OreLoreListener;
import dev.potatobank.storage.BankStorage;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public final class PotatoBankPlugin extends JavaPlugin {
private BankStorage storage;
private OreRegistry ores;
private PotatoBankEconomyService economy;
private BankGui bankGui;
private OreLoreListener oreLoreListener;
private Object placeholderExpansion;
@Override
public void onEnable() {
saveDefaultConfig();
try {
storage = new BankStorage(this);
configureCities();
ores = new OreRegistry(this, storage);
ores.load();
} catch (SQLException exception) {
getLogger().severe("Could not initialize persistent bank storage: " + exception.getMessage());
getServer().getPluginManager().disablePlugin(this);
return;
}
economy = new PotatoBankEconomyService(this, storage);
getServer().getServicesManager().register(PotatoBankAPI.class, economy, this, ServicePriority.Normal);
bankGui = new BankGui(this, economy, ores);
getServer().getPluginManager().registerEvents(bankGui, this);
oreLoreListener = new OreLoreListener(this, ores);
getServer().getPluginManager().registerEvents(oreLoreListener, this);
MoneyCommand money = new MoneyCommand(this);
getCommand("money").setExecutor(money);
getCommand("money").setTabCompleter(money);
TreasuryCommand treasury = new TreasuryCommand(this);
getCommand("khazane").setExecutor(treasury);
getCommand("khazane").setTabCompleter(treasury);
if (getServer().getPluginManager().getPlugin("Vault") != null) {
try {
getServer().getServicesManager().register(net.milkbowl.vault.economy.Economy.class,
new VaultEconomyBridge(this, economy), this, ServicePriority.Normal);
getLogger().info("Vault economy provider registered.");
} catch (LinkageError error) {
getLogger().warning("Vault is present but its economy API could not be loaded: " + error.getMessage());
}
}
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) registerPlaceholderExpansion();
getLogger().info("PotatoBank enabled with " + ores.all().size() + " configured trade items.");
}
@Override
public void onDisable() {
getServer().getServicesManager().unregister(PotatoBankAPI.class, economy);
if (economy != null && getServer().getPluginManager().getPlugin("Vault") != null) {
getServer().getServicesManager().unregister(net.milkbowl.vault.economy.Economy.class, new VaultEconomyBridge(this, economy));
}
if (placeholderExpansion != null) {
try { placeholderExpansion.getClass().getMethod("unregister").invoke(placeholderExpansion); }
catch (ReflectiveOperationException ignored) { }
}
if (storage != null) {
try { storage.close(); }
catch (SQLException exception) { getLogger().severe("Could not close economy storage: " + exception.getMessage()); }
}
}
public PotatoBankAPI api() { return economy; }
public BankStorage storage() { return storage; }
public OreRegistry ores() { return ores; }
public PotatoBankEconomyService economy() { return economy; }
public BankGui bankGui() { return bankGui; }
public void refreshOreLoreDisplays() { if (oreLoreListener != null) oreLoreListener.refreshOnlinePlayers(); }
public List<String> cityIds() {
ConfigurationSection section = getConfig().getConfigurationSection("cities");
return section == null ? List.of() : new ArrayList<>(section.getKeys(false));
}
public String message(String key, String... replacements) {
String value = getConfig().getString("messages." + key, "&cپیام پیکربندی نشده است: " + key);
for (int i = 0; i + 1 < replacements.length; i += 2) {
value = value.replace("{" + replacements[i] + "}", replacements[i + 1]);
}
return ChatColor.translateAlternateColorCodes('&', value);
}
public void send(CommandSender sender, String key, String... replacements) {
sender.sendMessage(message(key, replacements));
}
private void configureCities() throws SQLException {
ConfigurationSection cities = getConfig().getConfigurationSection("cities");
if (cities == null || cities.getKeys(false).isEmpty()) throw new SQLException("No cities are configured");
for (String id : cities.getKeys(false)) {
String name = getConfig().getString("cities." + id + ".name", id);
storage.configureCity(id, name);
}
}
private void registerPlaceholderExpansion() {
try {
Class<?> expansionClass = Class.forName("dev.potatobank.integration.PotatoBankExpansion");
placeholderExpansion = expansionClass.getConstructor(PotatoBankPlugin.class).newInstance(this);
boolean registered = (boolean) expansionClass.getMethod("register").invoke(placeholderExpansion);
if (!registered) getLogger().warning("PlaceholderAPI expansion registration failed.");
} catch (ReflectiveOperationException | LinkageError exception) {
getLogger().warning("Could not register PlaceholderAPI expansion: " + exception.getMessage());
}
}
}