M

Create a professional premium-quality Minecraft Paper/Spigot plugin named MailBox by PrabhatPie.

File name when compile must be mails.jar Plugin Purpose:

A INVENTORY GUI-based player mail system that allows players to send offline/online mail to other players, manage incoming/sent/important mails, and supports permission-based hourly/daily mail limits.

Core Requirements:

  1. Commands:
  • /mail <player> <message> → Send normal mail
  • /mail important <player> <message> → Send important mail
  • /mail imp <player> <message> → Alias of important
  • /mails → Open mailbox INVENTORY GUI
  • /mail delete <id> → Delete specific mail by ID
  • /mail reload → Reload config
  • /mail clear <player> → Admin clears target mailbox
  1. Permissions:
  • mail.admin → Unlimited mail sending + admin commands
  • mail.important → Can send important mails
  • mails.hour.X → Max X mails per hour
  • mails.day.X → Max X mails per day
  • Highest permission node wins
  • If no permission found, use default config limit
  1. INVENTORY GUI System:

Main /mails INVENTORY GUI:

  • Incoming Mails button
  • Sent Mails button
  • Important Mails button

Incoming Mails INVENTORY GUI:

  • Show sender head
  • Display Mail ID
  • Preview of message
  • Timestamp
  • Read/Unread status
  • Left click = Read Mail
  • Right click = Delete Mail
  • Delete All Incoming button

Sent Mails INVENTORY GUI:

  • Show receiver head
  • Display Mail ID
  • Preview of message
  • Timestamp
  • Delivered/Unread status
  • Left click = View Mail
  • Right click = Delete Mail
  • Delete All Incoming button

Important Mails INVENTORY GUI:

  • Separate storage/category
  • Highlight/glow important mails
  • Display sender, ID, timestamp
  • Config option for undeletable important mails
  1. Join Notifications:
  • Notify player if unread mail exists on join
  • Separate stronger notification for important mail
  1. Config Options:
  • mail-limit-mode: HOUR or DAY
  • default-limit
  • join-notification true/false
  • important-mail glow true/false
  • important-mail sound true/false
  • important-mail undeletable true/false
  • auto-delete-days
  • max-message-length
  • cooldown-seconds
  1. Storage:
  • Use SQLite by default
  • Store:

- Mail ID - Sender UUID - Receiver UUID - Message - Timestamp - Read Status - Important Status - Deleted State

  • Ensure persistent across restarts
  1. Additional Requirements:
  • Every mail must have unique incremental ID
  • Support offline players
  • Prevent self-mail if configured
  • Async database operations for performance
  • Fully configurable messages.yml
  • Fully configurable INVENTORY GUI titles/items/lore in INVENTORY GUI.yml
  • Professional code structure and optimization
  • Compatible with latest Paper version
  • No bugs or placeholder logic
  • Add plugin.yml
  • Add comments in code for maintainability

Author:

Set plugin author to PrabhatPie

Kodari AI
KodariMay 5 at 1:05 pm 29,951 (v2)

I’ll create a comprehensive GUI-based mail system plugin with SQLite storage, permission-based limits, and professional architecture.

MailBox
Professional GUI-based player mail system allowing players to send offline/online mail with inbox, sent, and important mail categories. Features permission-based hourly/daily limits, SQLite storage, join notifications, admin commands, and fully customizable inventory GUIs. Supports mail IDs, timestamps, read status tracking, and configurable auto-deletion.

Now I’ll create the GUI framework components:

Now I’ll create the GUI implementations:


MailBox Plugin Created Successfully!

Professional GUI-based mail system with:

  • ✅ SQLite database storage with async operations

  • ✅ Complete GUI framework (Main, Incoming, Sent, Important, View)

  • ✅ Permission-based hourly/daily limits

  • ✅ Important mail category with glow effect

  • ✅ Join notifications for unread mails

  • ✅ Admin commands (reload, clear)

  • ✅ Player head skulls in mail items

  • ✅ Configurable auto-deletion

  • ✅ Fully customizable messages and GUI layouts

  • ✅ Cooldown system

  • ✅ MiniMessage color support

  • ✅ XSeries cross-version compatibility

  • ✅ Compiles to mails.jar

All configurations stored in config.yml, messages.yml, and gui.yml for easy customization.

M

Create a high-performance, production-ready Minecraft Paper/Spigot plugin named MailBox by PrabhatPie.

This plugin must be coded like a premium marketplace resource with clean architecture, scalability, and zero critical bugs.

────────────────────────────

🔧 CRITICAL FIXES & CORE LOGIC

  1. Mail ID System (IMPORTANT FIX)
  • Mail IDs MUST NOT reset on server restart
  • Use persistent incremental IDs stored in database
  • Implement:

- AUTO_INCREMENT (SQL) OR - Dedicated table "mail_meta" storing last_id

  • On server startup:

- Load last used ID - Continue incrementing safely

  • Ensure:

- No duplicate IDs - Thread-safe ID generation - Async-safe

────────────────────────────

💾 DATABASE DESIGN

Use SQLite by default (MySQL support optional)

Tables:

  1. mails
  • id (PRIMARY KEY, UNIQUE, NOT NULL)
  • sender_uuid
  • receiver_uuid
  • message
  • timestamp
  • is_read (BOOLEAN)
  • is_important (BOOLEAN)
  • is_deleted_sender (BOOLEAN)
  • is_deleted_receiver (BOOLEAN)
  1. mail_limits
  • player_uuid
  • sent_count
  • last_reset_time
  1. mail_meta
  • key (STRING)
  • value (STRING)

(Store last_mail_id)

Requirements:

  • Fully async DB operations
  • Connection pooling if MySQL
  • No main-thread blocking

────────────────────────────

📨 COMMAND SYSTEM

/mail <player> <message> /mail important <player> <message> /mail imp <player> <message> /mails /mail delete <id> /mail reload /mail clear <player>

Validation:

  • Prevent sending to self (config option)
  • Respect max message length
  • Respect cooldown
  • Respect permission limits

────────────────────────────

📊 PERMISSION SYSTEM

mail.admin → bypass all limits mail.important → send important mails

Dynamic limits:

  • mails.hour.1

mail.hour.2 mail.hour.3 mail.hour.4 till 25

  • mails.day.x

till 1-25 permissions

Logic:

  • Detect highest X value
  • Apply based on config mode (HOUR or DAY)
  • Reset counts properly using timestamps

────────────────────────────

🧠 PLACEHOLDER API SUPPORT (IMPORTANT)

Hook into PlaceholderAPI if installed.

Placeholders:

%mailbox_unread% %mailbox_total% %mailbox_important% %mailbox_sent%

%mailbox_limit% %mailbox_remaining%

Requirements:

  • Register expansion class
  • Safe fallback if PlaceholderAPI not installed
  • Real-time values (no caching issues)

────────────────────────────

🖥️ INVENTORY GUI SYSTEM (FULLY CONFIGURABLE)

All INVENTORY GUI elements must be configurable via INVENTORY GUI.yml

Main INVENTORY GUI (/mails):

  • Incoming Mails
  • Sent Mails
  • Important Mails

Incoming INVENTORY GUI:

  • Player head (sender)
  • Mail ID
  • Preview (first 30 chars)
  • Timestamp formatted
  • Read/Unread indicator
  • in both read And sent gu add next page and previous page buttons in the INVENTORY GUI

Click Actions:

  • LEFT → Read
  • RIGHT → Delete

Button:

  • Delete All Incoming

Sent INVENTORY GUI:

  • Player head (receiver)
  • Mail ID
  • Preview
  • Delivered/Unread

Button:

  • Delete All Sent

Important INVENTORY GUI:

  • Glow effect (configurable)
  • Optional undeletable
  • Special lore/formatting

────────────────────────────

🔔 JOIN NOTIFICATIONS

On player join:

  • Check unread mails

If normal mail: "You have X new mails! Use /mails"

If important mail: "You have IMPORTANT mail waiting!"

Must not spam (only once per join)

────────────────────────────

⚙️ CONFIG SYSTEM

config.yml:

  • mail-limit-mode: HOUR/DAY
  • default-limit
  • cooldown-seconds
  • max-message-length
  • prevent-self-mail
  • join-notification
  • auto-delete-days

important-mail: glow: true sound: true undeletable: false

────────────────────────────

📁 FILES

  • config.yml
  • messages.yml (ALL messages configurable)
  • INVENTORY GUI.yml (ALL INVENTORY GUI items configurable)

────────────────────────────

⚡ PERFORMANCE & SAFETY

  • Fully async DB operations
  • Use CompletableFuture or scheduler
  • No lag on INVENTORY GUI open
  • Cache lightweight data if needed
  • Clean memory usage
  • Handle offline players correctly
  • Null safety everywhere

────────────────────────────

🧪 EDGE CASE HANDLING

  • Player deletes mail → only hides for that side
  • Both delete → remove from DB (optional optimization)
  • Player offline → still receive mail
  • Server restart → no data loss
  • Invalid ID → proper error message
  • Prevent spam exploit

────────────────────────────

📦 FINAL REQUIREMENTS

  • Include plugin.yml
  • Clean OOP structure (managers, services)
  • Comments in code
  • Compatible with latest Paper version
  • No placeholder code
  • No TODOs
  • Production-ready quality

Author: PrabhatPie

Things to add - Permission till 1-25 of both day and hour Id should not be reset when restart Add Previous Page and Next Page option using Wools Should not have any error.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
24 2,601
src/main/java/com/prabhatpie/mailbox/MailBoxPlugin.java
package com.prabhatpie.mailbox;

import com.prabhatpie.mailbox.commands.MailCommand;
import com.prabhatpie.mailbox.commands.MailsCommand;
import com.prabhatpie.mailbox.database.Database;
import com.prabhatpie.mailbox.inventory.gui.GUIListener;
import com.prabhatpie.mailbox.inventory.gui.GUIManager;
import com.prabhatpie.mailbox.listener.PlayerJoinListener;
import com.prabhatpie.mailbox.manager.LimitManager;
import com.prabhatpie.mailbox.manager.MailManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;

/**
 * MailBox Plugin - GUI-based player mail system
 * Author: PrabhatPie
 */
@Getter
public class MailBoxPlugin extends JavaPlugin {
    
    private Database database;
    private MailManager mailManager;
    private LimitManager limitManager;
    private GUIManager guiManager;
    
    private FileConfiguration messagesConfig;
    private FileConfiguration guiConfig;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        loadConfigs();
        
        database = new Database(this);
        database.initialize();
        
        mailManager = new MailManager(this);
        limitManager = new LimitManager(this);
        guiManager = new GUIManager();
        
        registerCommands();
        registerListeners();
        
        startAutoDeleteTask();
        
        getLogger().info("MailBox has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (database != null) {
            database.close();
        }
        getLogger().info("MailBox has been disabled!");
    }
    
    /**
     * Load custom configuration files
     */
    private void loadConfigs() {
        File messagesFile = new File(getDataFolder(), "messages.yml");
        if (!messagesFile.exists()) {
            saveResource("messages.yml", false);
        }
        messagesConfig = YamlConfiguration.loadConfiguration(messagesFile);
        
        File guiFile = new File(getDataFolder(), "gui.yml");
        if (!guiFile.exists()) {
            saveResource("gui.yml", false);
        }
        guiConfig = YamlConfiguration.loadConfiguration(guiFile);
    }
    
    /**
     * Reload all configurations
     */
    public void reloadConfigs() {
        reloadConfig();
        
        File messagesFile = new File(getDataFolder(), "messages.yml");
        messagesConfig = YamlConfiguration.loadConfiguration(messagesFile);
        
        File guiFile = new File(getDataFolder(), "gui.yml");
        guiConfig = YamlConfiguration.loadConfiguration(guiFile);
    }
    
    /**
     * Register plugin commands
     */
    private void registerCommands() {
        getCommand("mail").setExecutor(new MailCommand(this));
        getCommand("mails").setExecutor(new MailsCommand(this));
    }
    
    /**
     * Register event listeners
     */
    private void registerListeners() {
        Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
        Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(this), this);
    }
    
    /**
     * Start automatic mail deletion task
     */
    private void startAutoDeleteTask() {
        int days = getConfig().getInt("auto-delete-days", 0);
        if (days > 0) {
            Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
                mailManager.autoDeleteOldMails(days);
            }, 20L * 60 * 60, 20L * 60 * 60 * 24);
        }
    }
}