AashishShrestha007
πŸ“Ž 1 file 2,293 chars
πŸ“„
pasted-code-1774590365835.txt
txt 99 lines
β–Ά
Create a fully functional Minecraft plugin using Java (Spigot/Paper API) with the following advanced features:

PLUGIN NAME: NexusCore (or suggest a better name)

CORE FEATURES:

1. Rank Management System
- Create, assign, remove, and list ranks
- Ranks should support prefixes, suffixes, permissions, and priorities
- Integration with LuckPerms API (if available)
- Commands:
  /rank create 
  /rank set  
  /rank delete 
  /rank list

2. Account Linking System (Minecraft ↔ Discord)
- Generate unique linking codes in-game
- Discord bot verifies and links accounts
- Store linked accounts in database
- Commands:
  /link
  /unlink
- Use Discord API (JDA preferred)

3. Player Activity Tracking
- Track:
  - Playtime
  - Joins/leaves
  - Blocks mined
  - Mob kills
- Store stats in database (MySQL or SQLite)
- Commands:
  /stats 
  /playtime 
- Auto-save system

4. Database System
- Support both MySQL and SQLite
- Configurable in config.yml
- Efficient queries and connection pooling

5. INVENTORY GUI System
- Create clean inventory GUIs for:
  - Rank management
  - Player stats
- Use clickable items with lore and icons

6. Config System
- Fully customizable config.yml
- Messages.yml for all messages
- Support color codes (&)

7. Event Listeners
- PlayerJoinEvent
- PlayerQuitEvent
- BlockBreakEvent
- EntityDeathEvent

8. Permissions System
- Custom permission nodes:
  nexus.rank.admin
  nexus.stats.view
  nexus.link.use

9. Plugin Structure
- Use OOP best practices
- Separate packages:
  - commands
  - listeners
  - managers
  - database
  - utils

10. Extra Features (Optional but preferred)
- PlaceholderAPI support
- Leaderboards (top playtime, kills)
- Daily rewards system
- Anti-alt detection (basic IP check)
- Web API support (optional)

REQUIREMENTS:
- Use Java 17+
- Compatible with PaperMC 1.20+
- Clean, optimized, and well-commented code
- Include plugin.yml
- Include setup instructions
- Include Discord bot setup guide

OUTPUT:
- Full source code
- File structure
- Example config.yml
- Example messages.yml
- Instructions to compile and install

BONUS:
- Suggest future improvements
- Ensure scalability for large servers
Kodari AI
KodariMar 27 at 5:48 am 15,351 (v2)

⚠️ Environment Mismatch Detected

This environment is configured for Discord.js bot development (JavaScript/Node.js), not Java/Spigot plugin development. I cannot compile or generate a Java Minecraft plugin here.

However β€” your request includes a full Discord bot component (the Minecraft ↔ Discord account linking system). I can build that side of NexusCore completely here, which would pair with your Java plugin.


Here’s what I’ll build β€” the NexusCore Discord Bot:

  • /link <code> slash command β€” verifies a 6-digit code from in-game and links the Discord account to the Minecraft UUID

  • /unlink slash command β€” removes the Discord ↔ Minecraft association

  • /stats <player> slash command β€” fetches player stats from a shared MySQL/SQLite database

  • /playtime <player> slash command β€” fetches playtime from the shared DB

  • Role sync β€” automatically assigns a Discord role matching the player’s in-game rank on link

  • A REST API endpoint (Express) so the Minecraft plugin can push linking codes and stats

  • Full SQLite persistence for linked accounts (MySQL also configurable)

  • Embed-rich responses with color-coded rank displays

NexusCoreBot
Discord bot companion for the NexusCore Minecraft plugin. Handles Minecraft-to-Discord account linking via one-time codes, syncs in-game ranks to Discord roles, and exposes player stats (playtime, kills, blocks mined) via slash commands. Includes a REST API so the Minecraft server can push linking codes and stat updates. Supports both SQLite and MySQL for storage, with full embed-rich Discord responses.

Now let me create a comprehensive setup guide:


What was built

The full NexusCore Discord Bot β€” the Discord-side companion to your Minecraft plugin β€” across 20 files. Here’s a summary of every system:

πŸ—„οΈ Database Layer (src/database/)

  • database.js β€” Unified SQLite/MySQL abstraction. One get/run/all API that works identically for both engines. WAL mode enabled for SQLite performance

  • linkedAccounts.js β€” CRUD for Minecraft ↔ Discord pairs with upsert-on-conflict

  • pendingCodes.js β€” Stores in-game generated codes with a 10-minute TTL and auto-purge on consume

  • playerStats.js β€” Playtime, joins, kills, blocks with leaderboard queries

πŸ€– Slash Commands (src/commands/)

Command
Who
/link <code>
Anyone β€” verifies code, links account, assigns rank role
/unlink
Anyone β€” removes link, strips rank roles
/stats [player]
Anyone β€” rich embed with all stats + player head avatar
/playtime [player]
Anyone β€” playtime + last seen timestamp
/leaderboard <type>
Anyone β€” top 10 playtime / kills / blocks with medals
/whois <user>
Manage Guild β€” admin lookup with full account details
/syncrank <user>
Manage Guild β€” force re-sync Discord roles for a member

🌐 REST API (src/api/server.js)

Your Java Minecraft plugin communicates with the bot through this Express server using a shared secret (X-Nexus-Secret header):

Plain Text
POST /api/link/generate   ← Plugin sends generated code
POST /api/stats/join      ← Plugin logs player joins
POST /api/stats/playtime  ← Plugin reports session playtime
POST /api/stats/blocks    ← Plugin reports blocks mined
POST /api/stats/kills     ← Plugin reports mob kills
POST /api/rank/update     ← Plugin updates rank β†’ auto-syncs Discord role
GET  /api/linked/:uuid    ← Plugin checks if player is linked
GET  /health              ← No-auth health check

πŸ”— Role Sync (src/utils/roleSync.js)

Reads config.json rank→roleId mappings, strips all old rank roles, then assigns the correct one atomically. Triggered on link, unlink, rank update, and manual /syncrank.

πŸ“‹ Setup

  1. npm install

  2. Fill in .env with your bot token, client ID, guild ID, and API secret

  3. Replace role IDs in config.json

  4. node src/deploy-commands.js to register slash commands

  5. npm start

  6. Point your Java plugin’s HTTP client at http://localhost:3000 with the shared secret

Kodari can make mistakes. Review important code before using.
Files
src
config.json
package.json
SETUP.md
Code
25 1,207
src/index.js
const { Client, GatewayIntentBits, Collection } = require('discord.js');
const { loadCommands } = require('./handlers/commandHandler');
const { loadEvents } = require('./handlers/eventHandler');
const { initDatabase } = require('./database/database');
const { startApiServer } = require('./api/server');
require('dotenv').config();

const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMembers,
        GatewayIntentBits.GuildMessages
    ]
});

client.commands = new Collection();

async function main() {
    console.log('[NexusCore] Initializing database...');
    await initDatabase();
    console.log('[NexusCore] Database ready.');

    loadCommands(client);
    loadEvents(client);

    startApiServer(client);

    await client.login(process.env.DISCORD_TOKEN);
}

main().catch(err => {
    console.error('[NexusCore] Fatal startup error:', err);
    process.exit(1);
});