π
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
β οΈ 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/unlinkslash 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 DBRole 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
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. Oneget/run/allAPI that works identically for both engines. WAL mode enabled for SQLite performancelinkedAccounts.jsβ CRUD for Minecraft β Discord pairs with upsert-on-conflictpendingCodes.jsβ Stores in-game generated codes with a 10-minute TTL and auto-purge on consumeplayerStats.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):
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
npm installFill in
.envwith your bot token, client ID, guild ID, and API secretReplace role IDs in
config.jsonnode src/deploy-commands.jsto register slash commandsnpm startPoint your Java pluginβs HTTP client at
http://localhost:3000with the shared secret
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);
});