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

Database
Status
Recommended For

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

Column
Type
Constraints
Index
Description

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

Column
Type
Constraints
Index
Description

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

Column
Type
Constraints
Index
Description

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

Column
Type
Constraints
Index
Description

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

Column
Type
Constraints
Index
Description

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

Column
Type
Constraints
Index
Description

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

Column
Type
Constraints
Index
Description

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:

  1. config.yml - Main plugin configuration

  2. messages.yml - Customizable messages and text

Configuration File Locations

Configuration Loading Order

  1. Plugin loads defaults from JAR

  2. Creates files if they don't exist

  3. Loads user's configuration

  4. Merges with defaults

  5. Validates configuration

  6. 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:

  1. Enable Developer Mode in Discord (Settings → Advanced → Developer Mode)

  2. Right-click channel → Copy ID

  3. 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:

  1. Backup Database:

  1. Update Plugin:

    • Replace JAR file

    • Start server

  2. New Tables Created Automatically:

    • activity_rewards (for new modules)

  3. Configuration Updated:

    • Old config backed up as config.yml.old

    • New 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:

  1. Check database credentials

  2. Verify database server is running

  3. Check network connectivity

  4. Verify user has permissions

Debug Steps:

Error: "Table doesn't exist"

Cause: Plugin hasn't created tables yet or table creation failed

Solution:

  1. Delete database file (SQLite)

  2. Restart plugin (tables will be recreated)

  3. Or manually run DDL from logs

Manual Table Creation:

Error: "Connection timeout"

Cause: Database server too slow or network issues

Solution:

  1. Increase connection timeout:

  1. Check database server load

  2. Optimize database queries

  3. Add indexes to frequently queried columns

Configuration Issues

Error: "Invalid configuration value"

Cause: Configuration value is wrong type or format

Solution:

  1. Enable debug mode:

  1. Check console for specific errors

  2. Validate YAML syntax (use online YAML validator)

  3. 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:

  1. Verify channel ID is correct

  2. Enable Developer Mode in Discord

  3. Right-click channel → Copy ID

  4. Check bot has access to channel

  5. Verify channel is in configured guild

Migration Issues

Error: "Column doesn't exist" after migration

Cause: Database schema not updated

Solution:

  1. Check if migration scripts ran

  2. Manually run schema updates

  3. Verify database version

Check Schema Version:

Data Loss During Migration

Prevention:

  1. Always backup before migration

  2. Test migration on development server first

  3. Verify data integrity after migration

Recovery:

  1. Restore from backup

  2. Identify what went wrong

  3. Retry migration with fixes

Performance Issues

Slow Database Queries

Diagnosis:

  1. Enable query logging:

  1. Check slow queries in logs

  2. Analyze query execution plans

Solutions:

  1. Add indexes to slow columns

  2. Optimize queries

  3. Use connection pooling

  4. Increase pool size:

High Memory Usage

Diagnosis:

  1. Check database connection count

  2. Monitor cache size

  3. Check for memory leaks

Solutions:

  1. Close database connections properly

  2. Clear caches periodically

  3. Reduce pool size

  4. 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