Database
Table of Contents
Database Overview
XDiscordUltimate uses a relational database to store:
Linked Discord and Minecraft accounts
Verification codes
Support tickets and messages
Player statistics
Moderation logs
Activity rewards
Supported Databases
SQLite
✅ Built-in
Small servers (1-50 players)
MySQL
✅ Supported
Medium-Large servers (50+ players)
PostgreSQL
✅ Supported
Large servers (200+ players)
Database Selection Guide
SQLite (Default)
✅ No external dependencies
✅ Easy setup (file-based)
✅ Good for small servers
❌ Limited concurrent connections
❌ Not suitable for high-load scenarios
MySQL
✅ Production-ready
✅ Good performance
✅ Widely supported
❌ Requires MySQL server
❌ More complex setup
PostgreSQL
✅ Advanced features
✅ Excellent performance
✅ ACID compliance
❌ Requires PostgreSQL server
❌ Higher resource usage
Database Setup
SQLite (Default)
No setup required! SQLite database is created automatically on first run.
Database Location: {plugin-folder}/data.db
Configuration:
MySQL Setup
Step 1: Create MySQL Database
Step 2: Configure Plugin
Step 3: Connection Pool Settings
For high-load servers, adjust HikariCP settings in code or create hikari.properties:
PostgreSQL Setup
Step 1: Create PostgreSQL Database
Step 2: Configure Plugin
Database Schema
Table: verified_users
Purpose: Maps Minecraft accounts to Discord accounts for verification
minecraft_uuid
VARCHAR(36)
PRIMARY KEY
PK
Player UUID (hyphenated)
discord_id
VARCHAR(20)
NOT NULL, UNIQUE
UNIQUE
Discord user ID
verified_at
TIMESTAMP
DEFAULT CURRENT_TIMESTAMP
-
Verification timestamp
minecraft_name
VARCHAR(16)
-
-
Minecraft username
discord_name
VARCHAR(32)
-
-
Discord username
DDL:
Sample Data:
Table: verification_codes
Purpose: Temporary storage for verification codes
discord_id
VARCHAR(20)
PRIMARY KEY
PK
Discord user ID
code
VARCHAR(10)
NOT NULL, UNIQUE
UNIQUE
Generated code
username
VARCHAR(16)
-
-
Minecraft username
created_at
BIGINT
NOT NULL
INDEX
Creation timestamp (ms)
expires_at
BIGINT
NOT NULL
INDEX
Expiration timestamp (ms)
DDL:
Sample Data:
Table: tickets
Purpose: Support ticket management
id
INTEGER
PRIMARY KEY, AUTO_INCREMENT
PK
Ticket ID
minecraft_uuid
VARCHAR(36)
NOT NULL, FOREIGN KEY
INDEX
Player UUID
discord_channel_id
VARCHAR(20)
-
-
Discord channel ID
status
VARCHAR(20)
DEFAULT 'OPEN'
INDEX
OPEN, CLOSED, PENDING
created_at
TIMESTAMP
DEFAULT CURRENT_TIMESTAMP
-
Creation time
closed_at
TIMESTAMP
NULL
-
Close time
subject
TEXT
-
-
Ticket subject
DDL:
Sample Data:
Table: ticket_messages
Purpose: Messages within tickets
id
INTEGER
PRIMARY KEY, AUTO_INCREMENT
PK
Message ID
ticket_id
INTEGER
NOT NULL, FOREIGN KEY
INDEX
Ticket ID
sender_uuid
VARCHAR(36)
-
-
Sender UUID (if player)
sender_type
VARCHAR(10)
-
-
PLAYER or STAFF
message
TEXT
-
-
Message content
sent_at
TIMESTAMP
DEFAULT CURRENT_TIMESTAMP
-
Send time
DDL:
Table: moderation_logs
Purpose: Moderation action logging
id
INTEGER
PRIMARY KEY, AUTO_INCREMENT
PK
Log ID
action_type
VARCHAR(20)
NOT NULL
INDEX
BAN, KICK, WARN, MUTE, REPORT
target_uuid
VARCHAR(36)
NOT NULL
INDEX
Target UUID
moderator_uuid
VARCHAR(36)
-
INDEX
Moderator UUID
reason
TEXT
-
-
Action reason
timestamp
TIMESTAMP
DEFAULT CURRENT_TIMESTAMP
-
Action time
expires_at
TIMESTAMP
NULL
-
Expiration time (for temp bans)
active
BOOLEAN
DEFAULT TRUE
INDEX
Still active flag
DDL:
Sample Data:
Table: player_stats
Purpose: Player statistics tracking
minecraft_uuid
VARCHAR(36)
PRIMARY KEY
PK
Player UUID
joins
INTEGER
DEFAULT 0
-
Join count
messages_sent
INTEGER
DEFAULT 0
-
Chat messages
deaths
INTEGER
DEFAULT 0
-
Death count
playtime_minutes
INTEGER
DEFAULT 0
INDEX
Total playtime (minutes)
last_seen
TIMESTAMP
DEFAULT CURRENT_TIMESTAMP
-
Last activity
first_join
TIMESTAMP
DEFAULT CURRENT_TIMESTAMP
-
First join time
DDL:
Sample Data:
Table: activity_rewards
Purpose: Discord activity reward tracking
id
INTEGER
PRIMARY KEY, AUTO_INCREMENT
PK
Reward ID
discord_id
VARCHAR(20)
NOT NULL
INDEX
Discord user ID
reward_type
VARCHAR(50)
-
-
Type of reward
reward_data
TEXT
-
-
Reward data (JSON)
claimed
BOOLEAN
DEFAULT FALSE
INDEX
Claimed flag
created_at
TIMESTAMP
DEFAULT CURRENT_TIMESTAMP
-
Creation time
claimed_at
TIMESTAMP
NULL
-
Claim time
DDL:
Database Indexes
Purpose of Indexes:
Improve query performance
Speed up lookups
Enable efficient sorting
Indexes Created:
Configuration Overview
XDiscordUltimate uses YAML configuration files:
config.yml - Main plugin configuration
messages.yml - Customizable messages and text
Configuration File Locations
Configuration Loading Order
Plugin loads defaults from JAR
Creates files if they don't exist
Loads user's configuration
Merges with defaults
Validates configuration
Logs warnings for invalid values
Configuration Reference
config.yml Structure
Feature Configuration Details
Chat Bridge Module
Placeholders:
%player%- Minecraft player name%prefix%- Player prefix (LuckPerms)%suffix%- Player suffix (LuckPerms)%message%- Chat message%user%- Discord username
Verification Module
Commands:
/verify <code>- Verify account
Tickets Module
Commands:
/support <message>- Create support ticket
Moderation Module
Commands:
/report <player> <reason>- Report a player
Database Configuration
SQLite:
MySQL:
PostgreSQL:
Discord Bot Configuration
How to Get Channel IDs:
Enable Developer Mode in Discord (Settings → Advanced → Developer Mode)
Right-click channel → Copy ID
Paste into config.yml
Admin Console Configuration
Console Commands:
!tps- Check server TPS!list- List online players!restart- Restart server (requires restart script)!stop- Stop server (requires shutdown script)
Message Configuration
messages.yml Structure
Customizing Messages
Color Codes:
&0- Black&1- Dark Blue&2- Dark Green&3- Dark Aqua&4- Dark Red&5- Dark Purple&6- Gold&7- Gray&8- Dark Gray&9- Blue&a- Green&b- Aqua&c- Red&d- Light Purple&e- Yellow&f- White
Formatting Codes:
&l- Bold&o- Italic&n- Underline&m- Strikethrough&k- Obfuscated
Placeholders:
%player%- Player name%target%- Target player name%reason%- Reason text%user%- Discord username%message%- Message content%server%- Server name
Example Custom Configuration
Migration Guide
Upgrading from 1.0.x to 1.1.0
Breaking Changes:
Database schema updated (new tables added)
Configuration structure changed
Module names updated
Migration Steps:
Backup Database:
Update Plugin:
Replace JAR file
Start server
New Tables Created Automatically:
activity_rewards(for new modules)
Configuration Updated:
Old config backed up as
config.yml.oldNew config template loaded
Merge custom settings manually
Migrating from SQLite to MySQL
Step 1: Export SQLite Data
Step 2: Create MySQL Database
Step 3: Import to MySQL
Step 4: Update Configuration
Step 5: Restart Plugin
Restart server or reload plugin to apply changes.
Database Schema Migrations
v1.0.0 → v1.1.0:
Backup and Restore
Automated Backup Script
Create backup-xdiscord.sh:
Schedule with Cron:
MySQL Backup
Manual Backup:
Automated Backup:
Restore from Backup
SQLite Restore
MySQL Restore
Troubleshooting
Database Connection Issues
Error: "Database not initialized"
Cause: Database connection failed during initialization
Solution:
Check database credentials
Verify database server is running
Check network connectivity
Verify user has permissions
Debug Steps:
Error: "Table doesn't exist"
Cause: Plugin hasn't created tables yet or table creation failed
Solution:
Delete database file (SQLite)
Restart plugin (tables will be recreated)
Or manually run DDL from logs
Manual Table Creation:
Error: "Connection timeout"
Cause: Database server too slow or network issues
Solution:
Increase connection timeout:
Check database server load
Optimize database queries
Add indexes to frequently queried columns
Configuration Issues
Error: "Invalid configuration value"
Cause: Configuration value is wrong type or format
Solution:
Enable debug mode:
Check console for specific errors
Validate YAML syntax (use online YAML validator)
Compare with default config
Common Issues:
Missing quotes around strings with special characters
Wrong indentation
Typo in key names
Wrong data type (e.g., string instead of boolean)
Error: "Channel not found"
Cause: Discord channel ID is incorrect or bot doesn't have access
Solution:
Verify channel ID is correct
Enable Developer Mode in Discord
Right-click channel → Copy ID
Check bot has access to channel
Verify channel is in configured guild
Migration Issues
Error: "Column doesn't exist" after migration
Cause: Database schema not updated
Solution:
Check if migration scripts ran
Manually run schema updates
Verify database version
Check Schema Version:
Data Loss During Migration
Prevention:
Always backup before migration
Test migration on development server first
Verify data integrity after migration
Recovery:
Restore from backup
Identify what went wrong
Retry migration with fixes
Performance Issues
Slow Database Queries
Diagnosis:
Enable query logging:
Check slow queries in logs
Analyze query execution plans
Solutions:
Add indexes to slow columns
Optimize queries
Use connection pooling
Increase pool size:
High Memory Usage
Diagnosis:
Check database connection count
Monitor cache size
Check for memory leaks
Solutions:
Close database connections properly
Clear caches periodically
Reduce pool size
Increase server memory
This database and configuration reference provides comprehensive information for managing XDiscordUltimate's data layer and configuration. Keep this guide handy for troubleshooting and setup tasks!
Last updated
