Saurav1233444
📎 1 file 3,175 chars
📄
pasted-code-1784886680831.txt
txt 41 lines
▶
Create a Minecraft Spigot/Paper plugin (Java, Maven project) called Investor with the following functionality:

Core Mechanic:

Players can invest money (via Vault economy API) into a personal "investment balance."
Money grows over time based on the amount invested, using a scaling formula so that larger investments grow proportionally but the actual returns stay small/slow — this is NOT meant to let players get rich quickly. Growth should feel meaningful but modest (e.g. a player should take multiple real-world days to meaningfully profit, not hours).
Use a formula where the growth rate scales slightly better for higher invested amounts, but with diminishing returns (e.g. a logarithmic or tiered bonus, not a flat linear multiplier), so whales don't gain a disproportionate advantage and inflation stays controlled.
Revenue accumulates passively over time (real seconds), calculated even if the player is offline, but only credited/visible in the INVENTORY GUI — not auto-added to their balance. Players must manually claim it.

INVENTORY GUI Requirements (opened via /invest command or NPC interaction):
Build a chest-style inventory INVENTORY GUI with these buttons/sections:

Invest — opens a chat/anvil input prompt (or sign INVENTORY GUI) to enter an amount to invest, validated against configurable min-invest and max-invest.
Delete Invested Money — lets the player forfeit/reset their invested principal completely (with a confirmation step). This money is NOT refunded — it's a punishment/reset option only, clearly labeled with a warning (e.g. red glass pane, lore explaining it's irreversible).
Revenue Earned — displays current accumulated (unclaimed) revenue as a live/updated number in the item lore.
Claim — transfers accumulated revenue into the player's real economy balance via Vault, then resets the accumulated counter to 0.

Config file (config.yml) should include:

yaml
investment:
  base-rate: 0.00001       # base growth rate per second per coin invested
  bonus-scaling: true      # enable diminishing-returns bonus for larger investments
  bonus-cap: 1.5           # max multiplier bonus even for huge investments
min-invest: 1000
max-invest: 5000000        # keep this modest to prevent runaway inflation
currency-format: "#,##0.##"
INVENTORY GUI-titles:
  main: "&aInvestor Menu"
confirm-delete: true       # require a confirmation click before deleting invested money

Other requirements:

Use Vault for economy integration.
Persist player data (invested amount, accumulated revenue, last-updated timestamp) in a YAML or SQLite file, not in memory only, so it survives restarts.
Add permission nodes: investor.use, investor.admin (for reload/reset commands).
Add a placeholder API (PlaceholderAPI) expansion exposing %investor_invested%, %investor_revenue%.
Include clear comments explaining the growth formula so it's easy to rebalance later.
Prioritize economy stability over big numbers — the design goal is a slow-burn passive income system, not a get-rich-quick mechanic.

Please generate the full plugin.java structure (main class, listener, INVENTORY GUI handler, config manager, data storage) plus the config.yml and plugin.yml.
Kodari AI
KodariJul 24 at 9:56 am 6
InvestorPlugin
InvestorPlugin provides a slow-burn passive investment system for Spigot and Paper servers. Players invest Vault economy funds, accumulate modest revenue over real-world time while online or offline, and manually claim earnings through an inventory GUI. The plugin persists investment data across restarts, supports configurable growth and investment limits, includes irreversible principal deletion with confirmation, provides admin reload and reset commands, integrates with NPC-style interactions, and exposes invested and revenue values through PlaceholderAPI.
  1. Create the Maven project structure and plugin metadata.

  2. Implement persistent investment data, configuration access, revenue calculation, and Vault transactions.

  3. Add the inventory GUI, chat investment prompt, confirmation flow, and NPC interaction.

  4. Add commands, permissions, scheduled GUI updates, and PlaceholderAPI support.

Saurav1233444
📎 1 file 3,097 chars
📄
pasted-code-1784887213198.txt
txt 36 lines
▶
Here's an add-on prompt you can append to (or hand alongside) the previous one, specifically for the risk/loss mechanic:

PROMPT (Add-on Feature: Investment Risk / Loss Chance):

Add a risk system to the Investor plugin's growth mechanic with the following behavior:

Mechanic:

Each time revenue is calculated/ticked (e.g. per second or per configurable interval), there is a small configurable chance the player's investment loses money instead of growing.
By default, 98% of the time the investment grows normally per the existing rate formula; 2% of the time, a loss event triggers instead.
Both the loss chance and loss severity must be fully configurable — don't hardcode 2%.

Config additions (config.yml):

yaml
risk:
  enabled: true
  check-interval-seconds: 60      # how often a risk roll happens (not every tick, to avoid excessive loss frequency)
  loss-chance: 2.0                # percentage chance (0-100) of a loss event per check
  loss-amount:
    type: PERCENT                 # PERCENT or FIXED
    percent-of: INVESTED          # INVESTED or ACCUMULATED_REVENUE — what the loss is calculated from
    min-loss-percent: 1.0         # minimum % lost when a loss event triggers
    max-loss-percent: 5.0         # maximum % lost when a loss event triggers (randomized between min/max)
  notify-player: true             # send player a message/sound when a loss occurs
  loss-message: "&c⚠ Your investment took a hit! You lost {amount} coins."
  protect-principal: true         # if true, loss can only reduce accumulated (unclaimed) revenue, never go below 0 or eat into the original invested principal

Requirements:

The loss roll should happen on the same interval as growth ticks (or its own configurable interval) — don't check every single tick if that's too frequent (e.g. per-second checks with a 2% chance would trigger constant losses; consider defaulting the check interval to something like every 30–60 seconds, or make the loss chance apply per real-time period like "per hour" instead of per tick, and clearly document this in comments).
When a loss occurs, deduct a randomized amount (between min-loss-percent and max-loss-percent of the configured percent-of base) from the player's accumulated unclaimed revenue — not their already-claimed real balance, and (if protect-principal: true) never below 0 or into the original invested amount.
Send the player a configurable message and sound effect when a loss triggers (only if online; queue/log it if offline so they see it next login or in the INVENTORY GUI).
Update the INVENTORY GUI's "Revenue Earned" button lore to reflect both gains and losses transparently, e.g. showing a small history/log of the last few events (optional, but nice for trust/transparency).
Make sure the loss chance is clearly advertised to players (e.g. in the /invest help command or INVENTORY GUI lore: "98% chance to profit, 2% chance of a small loss every hour") so it doesn't feel deceptive.
Add an admin command /investor risk  to adjust the loss chance in-game without editing config, requiring investor.admin permission.
Kodari AI
KodariJul 24 at 10:08 am 32
  1. Add configurable risk settings and persistent risk-event tracking.

  2. Apply interval-based randomized losses without reducing protected principal, including offline calculations.

  3. Surface risk in the GUI/messages and add /investor risk <chance> for admins.

  4. Register any new event handling and preserve existing Vault, storage, and PlaceholderAPI behavior.

The risk fields were partially applied to the data class, so I’m correcting that incomplete constructor and the calculator return path before wiring notifications and metadata.1. Corrected the risk configuration accessors and admin chance command. 2. Replacing the incomplete data/calculator edits with complete compilable implementations. 3. Adding player notification/queued-loss visibility and finalizing risk configuration/metadata.

Implemented the configurable investment risk system.

Changes include:

  • Added persistent risk data:

    • Last risk-check timestamp

    • Last loss amount

    • Pending offline loss notifications

    • Risk event count

  • Added interval-based risk rolls using configurable chance and loss ranges.

  • Losses reduce accumulated unclaimed revenue only and never withdraw money from the player’s Vault balance.

  • Added offline notification queuing; pending losses are shown when the player next opens the investment menu.

  • Added GUI risk information and latest-loss display.

  • Added /investor risk <chance> for admins with investor.admin.

  • Added risk configuration defaults:

    • 60-second checks

    • 2% loss chance

    • 1–5% randomized loss

    • Principal protection enabled

  • Updated plugin permissions and command metadata.

Note: the project’s existing data class had become structurally incomplete during the incremental edit, so it was repaired with a complete constructor implementation.

Kodari can make mistakes. Review important code before using.
Files
src
config.yml
plugin.yml
pom.xml
Code
7 172