cxscripts
📎 1 file 2,757 chars
📄
pasted-code-1780349226564.txt
txt 4 lines
▶
📋 System OverviewThe Invest Dashboard is a custom inventory INVENTORY GUI menu designed for an economy-based Minecraft server (like Skyblock, Prison, or Towny). It allows players to lock away large sums of money in exchange for passive income over time.🛠️ Menu Structure & Item BreakdownThe INVENTORY GUI uses a standard chest inventory layout (usually 3 rows / 27 slots). Slots not in use are filled with background filler items (like Gray Stained Glass Panes). There are 4 functional items mapped to specific actions:1. 🧨 Delete Investments (TNT Block)Action: Acts as a hard reset for the player's investment profile.Risk Factor: High. It wipes out all invested money completely.Warning Lore: Explicitly states that the player will NOT get their money back upon deletion.2. ⏰ Invest Info & Upgrades (Clock)Action: Displays the player's current financial stats and opens the investment shop when clicked.Data Fields Needed: * Invested: Total amount of money locked into the system (e.g., $9T).Income: The rate at which money is being generated (e.g., $31M/s).Click Trigger: Opens a sub-menu where players can purchase more shares/upgrades to increase their Income rate.3. 🧈 Collect Income (Gold Block)Action: The manual payout button.Data Fields Needed:Generated: The unclaimed money that has accumulated since the last collection (e.g., $1B).Click Trigger: Transfers the Generated amount directly into the player's main server balance and resets the counter back to $0.4. 🟥 Autocollect Toggle (Red Concrete/Wool Block)Action: A quality-of-life feature that automates the collection process.Click Trigger: Toggles between two states:OFF State: Money accumulates manually inside the Gold Block.ON State: Bypasses manual collection and periodically dumps generated money straight into the player's balance automatically.⚙️ How It Works Behind the Scenes (Logic Flow)To build or program this, an AI needs to track three core variables per player in a database or data file:total_invested (The total baseline capital)income_per_second (The multiplier calculating how fast money grows)unclaimed_balance (The holding pot for generated income)The Background Loop (The Clock)Every second, the server runs a background task (a runnable loop) for online players:$$\text{unclaimed\_balance} = \text{unclaimed\_balance} + \text{income\_per\_second}$$If Autocollect is toggled ON:The loop skips the unclaimed_balance holding pot entirely and runs this command every second (or minute):$$\text{Player's Economy Balance} = \text{Player's Economy Balance} + \text{income\_per\_second}$$

and instead of having a invest shop after you click the clock you can type in chat how much money you want to invest but you have to have enough money for example 100m,1b,100k
Kodari AI
KodariJun 1 at 9:32 pm 20
InvestDashboard
A passive income investment system for economy-based Minecraft servers. Players lock money into an investment dashboard to earn income per second. Features a 27-slot GUI with four interactive buttons: delete all investments, invest more via chat input (supports k/m/b/t notation), manually collect accumulated income, and toggle autocollect for automatic payouts. Vault economy integration with persistent YAML data storage and a per-second background income task.

Plan:

  1. Core inventory GUI framework (Handler, Button, GUI, GUIManager, GUIListener)

  2. Data layer — PlayerInvestData + DataManager

  3. NumberUtil — parse/format k/m/b/t

  4. InvestManager — income task, invest/collect/delete logic

  5. InvestDashboardGUI — main 27-slot menu

  6. ChatInputListener — awaiting chat investment amount

  7. InvestCommand — /invest entry point

  8. Main plugin class + resources


Here’s a summary of what was built:

Commands

  • /invest — opens the 27-slot dashboard GUI

GUI Buttons

Slot
Item
Action
10
TNT
Deletes all investments & unclaimed income (with lore warning)
13
Clock
Shows invested/income stats → closes GUI, prompts chat input
16
Gold Block
Collects unclaimed balance into player wallet
22
Red/Lime Concrete
Toggles autocollect OFF↔ON

Chat Input Flow — after clicking the clock, the player types 100k, 5m, 2b, 1t, etc. Invalid format or insufficient funds gives a clear error. Type cancel to abort.

Income Task — runs every second for all online players. If autocollect is OFF, income accumulates in unclaimed_balance. If ON, income goes directly to their economy balance.

Config knobs (config.yml):

  • income-rate — fraction of total invested paid per second (default 0.000003 ≈ 0.0003%/s)

  • min-invest — minimum single investment amount (default 1000)

cxscripts

what is the invest thing like %invest_thing%

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
16 787
src/main/java/com/kodari/investdashboard/InvestDashboard.java
package com.kodari.investdashboard;

import com.kodari.investdashboard.commands.InvestCommand;
import com.kodari.investdashboard.inventory.gui.GUIListener;
import com.kodari.investdashboard.inventory.gui.GUIManager;
import com.kodari.investdashboard.listeners.ChatInputListener;
import com.kodari.investdashboard.managers.DataManager;
import com.kodari.investdashboard.managers.InvestManager;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

public class InvestDashboard extends JavaPlugin {
    private Economy economy;
    private GUIManager guiManager;
    private DataManager dataManager;
    private InvestManager investManager;
    private ChatInputListener chatInputListener;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        if (!setupEconomy()) {
            getLogger().severe("Vault economy not found! Disabling InvestDashboard.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        guiManager = new GUIManager();
        dataManager = new DataManager(this);
        dataManager.loadAll();
        chatInputListener = new ChatInputListener(this);
        investManager = new InvestManager(this);
        investManager.startTask();

        getServer().getPluginManager().registerEvents(new GUIListener(guiManager), this);
        getServer().getPluginManager().registerEvents(chatInputListener, this);

        getCommand("invest").setExecutor(new InvestCommand(this));
        getLogger().info("InvestDashboard enabled.");
    }

    @Override
    public void onDisable() {
        if (investManager != null) investManager.stopTask();
        if (dataManager != null) dataManager.saveAll();
        getLogger().info("InvestDashboard disabled.");
    }

    private boolean setupEconomy() {
        if (getServer().getPluginManager().getPlugin("Vault") == null) return false;
        RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
        if (rsp == null) return false;
        economy = rsp.getProvider();
        return economy != null;
    }

    public Economy getEconomy() { return economy; }
    public GUIManager getGuiManager() { return guiManager; }
    public DataManager getDataManager() { return dataManager; }
    public InvestManager getInvestManager() { return investManager; }
    public ChatInputListener getChatInputListener() { return chatInputListener; }
}