epicvolder
๐Ÿ“Ž 1 file 6,946 chars
๐Ÿ“„
pasted-code-1785170363212.txt
txt 413 lines
โ–ถ
you are an expert java developer specializing in minecraft paper plugins.

create a professional, optimized and configurable paper plugin for minecraft paper 1.21.11.

plugin name: foxyads

server name: foxynetwork

minecraft version: paper 1.21.11

java version: java 21

api: paper api 1.21.11

build tool: gradle

package:
com.foxynetwork.foxyads

make the plugin production ready, optimized, clean, modular, fully commented and easy to maintain.

the plugin is inspired by grand rp's lifeinvader advertisement system.

players should be able to create advertisements through a INVENTORY GUI instead of typing commands.

admins should be able to approve, reject, edit, delete and manage advertisements.

everything should be configurable.

commands:

/ads
opens the player advertisement menu.
permission:
foxyads.use

/ads admin
opens the admin panel.
permission:
foxyads.admin

when a player runs /ads, open a clean and modern INVENTORY GUI titled "foxyads".

the INVENTORY GUI should contain these options:

buy advertisement
material: emerald
description: i want to buy something.

sell advertisement
material: diamond
description: i want to sell something.

custom advertisement
material: book
description: create your own advertisement.

after selecting a category, begin a chat conversation asking these questions one by one.

question 1:
what is the product?

example:
netherite armor

question 2:
price

accepted values:
5000
25000
offers
negotiable
free
best offer

question 3:
budget (optional)

accepted values:
5000
10000
no budget
negotiable

question 4:
is the price negotiable?

answers:
yes
no

question 5:
additional description

example:
looking for max enchanted armor.
buying in bulk.
fast deal.

after all questions are answered, open a confirmation INVENTORY GUI with:

confirm
cancel

every advertisement must store:

advertisement id
uuid
player uuid
player name
category
product
price
budget
negotiable
description
created date
created time
status

statuses:

pending
approved
rejected
expired
cancelled

advertisement ids should automatically increase.

examples:

#0001
#0002
#0003

never reuse ids.

use vault economy.

configurable advertisement price.

example config:

ads:
  enabled: true
  cost: 5000
  currency: vault
  expiration-hours: 24
  cooldown-minutes: 10
  max-player-ads: 5

if the player does not have enough money, show:

you don't have enough money.

players should have a configurable cooldown before creating another advertisement.

players should have a configurable maximum number of active advertisements.

advertisements should automatically expire after the configured time.

store everything inside sqlite.

automatically create the database and tables.

save instantly.

load asynchronously.

never block the server thread.

every submitted advertisement should start as pending.

admins must approve advertisements before they are broadcast.

admin panel (/ads admin) should include:

pending ads
approved ads
rejected ads
expired ads
player search
statistics
settings
reload plugin

pending advertisements should display:

id
player
product
price
category
status
created date

left click:
approve

right click:
reject

shift left:
edit

shift right:
delete

middle click:
view details

advertisement details INVENTORY GUI should display every field and include:

approve
reject
edit
delete
back

approved advertisements should support:

delete
edit
expire
clone

rejected advertisements should support:

approve
delete

player search should allow searching by:

player name
uuid
advertisement id

statistics page should display:

total advertisements
pending advertisements
approved advertisements
rejected advertisements
expired advertisements
most active players
total advertisement revenue
average advertisements per day

approved advertisements should automatically broadcast every configurable amount of time.

example format:

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ“ข advertisement #0031

player: steve
category: sell
product: netherite armor
price: $50,000
negotiable: yes
description: full protection iv set
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

broadcast interval should be configurable.

broadcast advertisements in rotation.

permissions:

foxyads.use
foxyads.admin
foxyads.bypass.cooldown
foxyads.bypass.cost
foxyads.bypass.limit
foxyads.reload

config.yml should allow changing:

INVENTORY GUI titles
INVENTORY GUI size
materials
broadcast interval
advertisement cost
cooldown
expiration
messages
sounds
database settings
maximum advertisements
currency
broadcast format

messages.yml should contain every message.

examples:

advertisement submitted.
advertisement approved.
advertisement rejected.
advertisement expired.
insufficient funds.
cooldown active.
maximum advertisements reached.
no permission.
advertisement deleted.
advertisement edited.
plugin reloaded.

support minimessage.

sounds.yml should allow configuring sounds for:

submit
approve
reject
open INVENTORY GUI
close INVENTORY GUI
delete
error

INVENTORY GUI features:

prevent item stealing
prevent shift clicking
decorative glass panes
next page
previous page
refresh button
back button
close button
search button

support pagination for unlimited advertisements.

support sorting by:

newest
oldest
price high to low
price low to high
player name
category
status

integrate with vault.

compatible with essentialsx economy, cmi economy and any vault economy plugin.

support placeholderapi.

placeholders:

%foxyads_pending%
%foxyads_approved%
%foxyads_total%
%foxyads_player_ads%

all database operations must be asynchronous.

cache advertisements.

avoid unnecessary inventory updates.

avoid memory leaks.

use proper scheduler practices.

log important events:

plugin enabled
plugin disabled
database connected
vault detected
placeholderapi detected
warnings
errors

generate:

plugin.yml
config.yml
messages.yml
sounds.yml
build.gradle
readme.md

use java 21 features.

follow solid principles.

organize the project into these packages:

commands
INVENTORY GUI
database
manager
listener
model
utils
config
economy
placeholder
scheduler

do not use deprecated paper api methods.

do not use nms.

do not use reflection unless absolutely necessary.

the final plugin should feel like a polished grand rp lifeinvader system made specifically for foxynetwork, with a clean player experience, powerful admin tools, high performance, modern INVENTORY GUI design, configurable settings, vault economy support, sqlite storage, placeholderapi integration and full compatibility with paper 1.21.11 running on java 21.
Kodari AI
KodariJul 27 at 4:44 pm 15
FoxyAds
FoxyAds provides FoxyNetwork with a polished Lifeinvader-style advertisement system for Paper 1.21.11. Players create buy, sell, or custom advertisements through inventory menus and guided chat prompts. Advertisements use Vault economy payments, configurable cooldowns, limits, expiration, approval workflows, SQLite persistence, asynchronous database operations, caching, pagination, sorting, MiniMessage formatting, PlaceholderAPI support, scheduled broadcasts, administrative moderation tools, statistics, configurable sounds, and fully customizable messages and GUI settings.
epicvolder

edit the existing plugin only, do not recreate it.

make these changes:

  • when an admin approves an advertisement, it should immediately become live.
  • approved advertisements should automatically rotate in chat every configured interval.
  • format them professionally like:

๐Ÿ“ข selling product: netherite armor price: $50,000 budget: negotiable player: Steve (click to message) description: full prot 4 armor, ready to trade.

  • clicking the player name should run:

/msg <player>

improve the /ads INVENTORY GUI.

new menu:

๐ŸŸข create buy ad ๐Ÿ”ต create sell ad ๐ŸŸก create custom ad ๐Ÿ“‹ my ads ๐ŸŒ browse ads โŒ close

make the INVENTORY GUI cleaner, modern, symmetrical, use decorative glass panes, better icons, better lore, sounds and animations.

add a browse ads menu where players can view all approved advertisements with:

  • product
  • type
  • price
  • budget
  • owner
  • remaining time

clicking an advertisement should open a details page with a button to message the owner.

when a player submits an advertisement, automatically deduct 3000 from their Vault economy account by running the equivalent of:

/eco take <player> 3000

or directly through the Vault API (preferred).

if the player has less than 3000, cancel the advertisement and send a configurable "not enough money" message.

only charge the player once the advertisement is successfully submitted.

keep everything asynchronous, optimized and compatible with Paper 1.21.11.

Kodari AI
KodariJul 27 at 5:06 pm 99
  1. Make approved advertisements immediately live, rotate them on schedule, and format clickable chat broadcasts.

  2. Replace the player /ads menu with the modern create/my/browse/close layout and add browse/details flows.

  3. Charge 3000 through Vault only after successful submission, with configurable insufficient-funds handling.

  1. Live approval/rotation: preserved submitted ads as pending, added budget and clickable owner formatting to rotation, and reset rotation on scheduler restart.

  1. Player GUI: the main menu now has the requested six-entry layout and configuration keys; Iโ€™m adding the paginated approved-ad browse flow, player-owned ads view, and owner messaging details page.

Gadget

  1. Submission charging: the Vault withdrawal now occurs only after the SQLite insert succeeds; failed funds checks remove the just-created row and notify the player. Iโ€™m aligning the fallback cost with the required 3000 amount.

Implemented the requested FoxyAds updates:

  1. Approved advertisement lifecycle

    • New submissions remain PENDING until admin approval.

    • Admin approval updates the ad to APPROVED immediately.

    • Approved edits remain live.

    • Approval/rejection/expiration notifications and sounds are triggered.

  2. Automatic chat rotation

    • Approved ads rotate using the configured broadcast interval.

    • Rotation resets correctly after reload.

    • Broadcast format now includes:

      • advertisement category

      • product

      • formatted price

      • budget

      • player name

      • description

    • Player names are clickable and run /msg <player>.

  3. Improved player GUI

    • Added modern main menu options:

      • Create Buy Ad

      • Create Sell Ad

      • Create Custom Ad

      • My Ads

      • Browse Ads

      • Close

    • Added decorative panes, configured icons, lore, navigation, and sounds.

    • Added paginated Browse Ads menu.

    • Added My Ads menu.

    • Added player-facing advertisement details page with:

      • product

      • type

      • price

      • budget

      • owner

      • remaining time

      • description

      • Message Owner button

  4. Vault charging

    • Default advertisement cost is now 3000.

    • The player is charged only after the advertisement is successfully inserted into SQLite.

    • If the payment fails, the inserted advertisement is removed and the configurable insufficient-funds message is sent.

    • Existing bypass-cost permission remains supported.

  5. Configuration

    • Added browse, my-ads, and player-details GUI settings.

    • Added configurable browse and my-ad materials.

    • Added remaining-time calculation based on the configured expiration period.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
settings.gradle
Code
38 2,474
src/main/java/com/foxynetwork/foxyads/FoxyAdsPlugin.java
package com.foxynetwork.foxyads;

import com.foxynetwork.foxyads.commands.AdsCommand;
import com.foxynetwork.foxyads.config.ConfigManager;
import com.foxynetwork.foxyads.database.DatabaseManager;
import com.foxynetwork.foxyads.economy.EconomyManager;
import com.foxynetwork.foxyads.inventory.gui.GUIListener;
import com.foxynetwork.foxyads.inventory.gui.GUIManager;
import com.foxynetwork.foxyads.listener.ChatConversationListener;
import com.foxynetwork.foxyads.listener.PlayerListener;
import com.foxynetwork.foxyads.manager.AdvertisementManager;
import com.foxynetwork.foxyads.manager.ConversationManager;
import com.foxynetwork.foxyads.placeholder.FoxyAdsPlaceholder;
import com.foxynetwork.foxyads.scheduler.BroadcastScheduler;
import com.foxynetwork.foxyads.scheduler.ExpirationScheduler;
import com.foxynetwork.foxyads.utils.MessageService;
import com.foxynetwork.foxyads.utils.SoundService;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public final class FoxyAdsPlugin extends JavaPlugin {
    private ConfigManager configManager;
    private MessageService messageService;
    private SoundService soundService;
    private DatabaseManager databaseManager;
    private EconomyManager economyManager;
    private AdvertisementManager advertisementManager;
    private GUIManager guiManager;
    private ConversationManager conversationManager;
    private BroadcastScheduler broadcastScheduler;
    private ExpirationScheduler expirationScheduler;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("messages.yml", false);
        saveResource("sounds.yml", false);

        configManager = new ConfigManager(this);
        messageService = new MessageService(this);
        soundService = new SoundService(this);
        databaseManager = new DatabaseManager(this);
        economyManager = new EconomyManager(this);
        guiManager = new GUIManager();
        advertisementManager = new AdvertisementManager(this);
        conversationManager = new ConversationManager(this);

        Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
        Bukkit.getPluginManager().registerEvents(new ChatConversationListener(conversationManager), this);
        Bukkit.getPluginManager().registerEvents(new PlayerListener(conversationManager), this);

        AdsCommand adsCommand = new AdsCommand(this);
        getCommand("ads").setExecutor(adsCommand);
        getCommand("ads").setTabCompleter(adsCommand);

        economyManager.setup();
        if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
            new FoxyAdsPlaceholder(this).register();
            getLogger().info("PlaceholderAPI detected.");
        }

        databaseManager.initialize().thenRun(() -> {
            advertisementManager.loadCache();
            getLogger().info("Database connected.");
        }).exceptionally(error -> {
            getLogger().severe("Database initialization failed: " + error.getMessage());
            return null;
        });

        broadcastScheduler = new BroadcastScheduler(this);
        expirationScheduler = new ExpirationScheduler(this);
        broadcastScheduler.start();
        expirationScheduler.start();

        getLogger().info("FoxyAds enabled for FoxyNetwork.");
    }

    @Override
    public void onDisable() {
        if (broadcastScheduler != null) {
            broadcastScheduler.stop();
        }
        if (expirationScheduler != null) {
            expirationScheduler.stop();
        }
        if (conversationManager != null) {
            conversationManager.clear();
        }
        if (databaseManager != null) {
            databaseManager.close();
        }
        getLogger().info("FoxyAds disabled.");
    }

    public void reloadPlugin() {
        reloadConfig();
        configManager.reload();
        messageService.reload();
        soundService.reload();
        if (broadcastScheduler != null) {
            broadcastScheduler.restart();
        }
    }
}